Difference between revisions of "Lua Basics"

From Cheat Engine
Jump to navigation Jump to search
(Lua Engine)
(Redirected page to Tutorials:Lua:Basics)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
LUA interaction is done two main ways in Cheat Engine.  First you have the Lua Engine window which you access from "Tools->Lua Engine" (or CTRL+L) in the Memory Viewer, second is a LUA script associated with your cheat table that you access by "Table->Show Cheat Table Lua Script" (or CTRL+ALT+L) from the main window.  You can also load and execute other scripts.
+
#REDIRECT [[Tutorials:Lua:Basics]]
=== Lua Engine ===
 
From the memory viewer, hit CTRL+L to open the Lua Engine window.  The Lua Engine window contains the Output of all of your scripts (from print() calls) as well as an interactive script box to let you execute commands.  You can open or save a script from here.
 
 
 
[[File:LuaEngine1.png]]
 
 
 
=== Cheat Table Lua Script ===
 
From the main Cheat Engine window, click on "Table->Show Cheat Engine Lua Script".  This script is associated with your cheat table.  When you open your cheat table you will get a message box informing you that your table has a script associated with it and asking you if you want to execute it.  From here you can click File->New Window to open other script windows.
 
 
 
=== Script Windows ===
 
You can have as many script windows open as you want.  If you save these scripts as .LUA files in the same directory as your cheat table, you can run them from other scripts using the functions "require" which will only run a script the first time and "dofile" which will run a script every time you call it.  Note that you do not use the extention with require, ".lua" is assumed, but you do need it with dofile:
 
 
 
<pre>
 
-- test script
 
print ("Script2 Executing...")
 
print ("Calling require...")
 
require("Script1")
 
print ("Calling dofile...")
 
dofile("Script1.lua")
 
print ("Calling require...")
 
require("Script1")
 
print ("Calling dofile...")
 
dofile("Script1.lua")
 
</pre>
 
 
 
Output (require calls not shown because it had already been run):
 
<pre>
 
Script2 Executing...
 
Calling require...
 
Calling dofile...
 
Script1 Executing...
 
Calling require...
 
Calling dofile...
 
Script1 Executing...
 
</pre>
 

Latest revision as of 07:53, 17 March 2017