Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


The basics

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
VicTT
How do I cheat?
Reputation: 0

Joined: 28 Nov 2014
Posts: 4

PostPosted: Fri Nov 28, 2014 1:19 am    Post subject: The basics Reply with quote

I've been using Cheat Engine for a few years now (I don't even remember how long it's been), but only its basic functionality (like searching for values by different criteria, changing them - just things that require a minimal amount of prior research).
I've thought about learning to use it 'properly' (which is to say anything that starts injecting code) but somehow never got around to doing it until I decided a short while ago that today is 'the day'.
The problem is that I'm trying to understand the architecture, and I don't know exactly where to start. I can code LUA, but I'm not sure how to interface it with CheatEngine.
Let's assume that I'm trying to achieve the following:
1) I want to write a LUA script, that is to be interpreted by the LUA interpreter (lua.exe), not inside CheatEngine that, for the sake of it:
2) Loads up CheatEngine
3) Loads a process by PID (located in variable inside the LUA script)
4) Searches for a value within the memory of the process
5) Returns a table of addresses that contain the value at the time of the search
OR
4')Searches for a value larger than 7
5')Modifies that value by adding 5 to it
(...)

The point is that I'm not sure how exactly that would work. What would my LUA script have to include in order to access the functions of CheatEngine?
Any and all help is welcome. A step-by-step guide would be greatly appreciated, but a link to a tutorial is great too. I just don't know where to start.
Note: I can already code LUA, that's not the problem. It's automating CheatEngine with the help of LUA/interfacing a LUA script with CheatEngine that I have no idea how to achieve.
Thank you in advance.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8517
Location: 127.0.0.1

PostPosted: Fri Nov 28, 2014 3:17 am    Post subject: Reply with quote

1 is not possible if you plan to use functions that are made by Cheat Engine and exposed to Lua. The normal lua.exe interpreter has no knowledge of the functions that are implemented into Cheat Engine, which means if you attempt to do anything Cheat Engine has made available to its Lua engine in another Lua engine, you will just get errors.

I think you misunderstand how Lua works. Lua offers applications the ability to expose their own functions to Lua scripts. However, this is specific to that application only, and not Lua as a whole.

What you are attempting to do will have to be fully done in Cheat Engine unless you plan to compile part of Cheat Engine separate just to have access to its Lua engine and custom functions.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
VicTT
How do I cheat?
Reputation: 0

Joined: 28 Nov 2014
Posts: 4

PostPosted: Fri Nov 28, 2014 6:14 am    Post subject: Reply with quote

I'm aware of the limitations of such an implementation.
I was merely hoping that someone had written a wrapper in generic LUA...for CheatEngine LUA. So that I could possibly write (at least) something like:
require("CheatEngineLUA");
parseandexecute("path\to\someCheatEngineLUAScript.lua");
This is probably best accomplished by use of command-line arguments in the CheatEngine executable (any knowledge of those?).
Alternatively, I saw that there is a folder with lua scripts set to autorun on startup. But how exactly I would achieve the CheatEngineLUA equivalent of:
On startup, without any user-interaction:
[PSEUDOCODE]
Open process by PID (or Window name - PID is fine too)
Read/Write Data Structure from/at Address into/from a LUA variable for further processing.
[END PSEUDOCODE] is still a mystery to me.
(Seriously, how do I do that? What file do I write to, and what do I write in it?)
Worst-case scenario, I can automate the On startup process through simulating keypresses, mouse clicks, menu selections and the like, automatically copy&pasting the code inside CheatEngine's LUA Console, but I was hoping I didn't have to do all that.
I also noticed that there's a 'trainer generator' that CAN output a .exe, and there's advice on 'learning LUA and compiling the EXE yourself'. What is the trainer script written in? Is it translated to LUA and then compiled separately? If so, then there is a way to obtain a plain-LUA library-equivalent of the CheatEngineLUA. If not, then there must be a separate compiler that compiles just this 'script-code' that must use a (stripped-down?) version of the CheatEngine API. Perhaps that's more amenable. I'm not sure, because the one thing I completely lack in the case of CheatEngine is a clear view on its architecture.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25288
Location: The netherlands

PostPosted: Fri Nov 28, 2014 6:59 am    Post subject: Reply with quote

Go to table->lua script and write the code there that you want to execute (e.g openProcess(pid) and then read/write and whatever else)

Now save your .ct with the extention .cetrainer and when you doubleclick that file ce will execute the lua script in there (the ce gui won't even show, so your script has to close CE when it isn't needed anymore)

The Autorun folder works the same. The .lua scripts there get executed when ce starts so you can do what you want there as well (the gui will show unless you explicitly hide CE with your code)

As for coding this check main.lua (which also gets executed at launch) for a list of all the functions and classes


(CE's exe trainer is just a .exe that extracts cheat engine and a .cetrainer and runs that)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites