 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Kvist How do I cheat?
Reputation: 0
Joined: 11 Aug 2022 Posts: 6
|
Posted: Tue Aug 30, 2022 3:06 am Post subject: Accessing a Cheat Table's main Lua script from Lua |
|
|
I'm writing an AA template that queries the user for a full Mono method address. In the case that class name or method name are ambiguous, the user has to resolve the ambiguity manually, e.g. by comparing to the full class name or method signature.
To make this as straightforward as possible, I want the AA template to automatically generate a function skeleton for each of these cases, then add that function to CE's main Lua script file, very much like what adding an event handler to a button via the form builder does.
However, everything I found about manipulating Lua scripts inside CE digging around celua.txt were getLuaEngine/createLuaEngine, and while these would generally work, they would require the user to copy-paste the functions out of the engine into the main script, which I want to avoid.
Searching for the solution had me also learn a lot more about Pascal than anticipated just by staring at the Lua implementations in CE's source code, but even with the most furious of staring, I wasn't able to figure out how the event handlers are done so I'm a bit lost here. If anybody could give me a nudge that'd be greatly appreciated.
Alternatively, is it safe to use CE's XML classes to modify the Cheat Table file itself? If that were an option, I could simply extract the script's tag from the XML and simply append the generated function to the script string before writing it back.
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25838 Location: The netherlands
|
Posted: Tue Aug 30, 2022 3:19 am Post subject: |
|
|
| Code: |
function getLuaScriptLines()
for i=getFormCount()-1,0,-1 do
local f=getForm(i)
if (f.ClassName=='TfrmAutoInject') and (f.IsEditing==false) and (f.ScriptMode=='smLua') then
return f.Assemblescreen.Lines
end
end
end
getLuaScriptLines().add('Something')
getLuaScriptLines().add('Something else')
getLuaScriptLines().add('another line')
getLuaScriptLines().add('done')
|
And the xml editing tools should be able to edit ce tables as well. (saveTable to stream, convert stream to test, edit with the xml functions, convert text to stream and then loadTable from stream )
_________________
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 |
|
 |
Kvist How do I cheat?
Reputation: 0
Joined: 11 Aug 2022 Posts: 6
|
Posted: Tue Aug 30, 2022 3:57 am Post subject: |
|
|
Awesome! If I knew it were that simple, actually. Thank you so much!
Good to know about the XML stuff as well, could be quite interesting to work with this.
If you have time for another question regarding TStrings, maybe:
According to celua.txt, TStrings.addText should be capable of adding multiple texts at once, but from testing around and from what the implementation does, it also seems to be accepting only one string, or am I just using it wrong?
Edit: Nevermind, figured that one out. For the record, addText works with Lua multiline strings -> script.addText([[some multiline string]])
Another thing I don't quite understand with TStrings is why I need to use function access when calling their methods, e.g.
| Code: |
script.add("someline") -- function access
|
but can use the method access syntactic sugar when calling most other stuff, e.g.
| Code: |
f = findTableFile("somefile")
data = f:getData() -- method access
|
I'm asking because in the source, both are added to their respective classes in the same way:
| Code: |
luaclass_addClassFunctionToTable
|
Should probably go into another thread, but I thought I might use the opportunity to ask.
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25838 Location: The netherlands
|
Posted: Tue Aug 30, 2022 6:02 am Post subject: |
|
|
TStrings is a base class. The object of the assembleScreen is a synedit, but the methods .add and .getText only support default text, not highlighted.
Also, I'm not sure how synEdit stores thedata in memory, but I expect it's not in one big datastream. Likely it has the text itself, and then a list of highlight information which starts at position x,y in the text, and has the attribute aKeyWord, or aLabel, for xxx characters long. So even if you had access to just the data, it's be pretty hard to interpret, and might even break the next version.
_________________
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 |
|
 |
Kvist How do I cheat?
Reputation: 0
Joined: 11 Aug 2022 Posts: 6
|
Posted: Tue Aug 30, 2022 6:21 am Post subject: |
|
|
| Aha, I see. Thanks for the info. I should probably get to know the Pascal base classes a bit better in order to save me some headaches. Spent at least an hour hunting for TObject the other day until it finally clicked.
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25838 Location: The netherlands
|
Posted: Tue Aug 30, 2022 6:27 am Post subject: |
|
|
tip: hold down shift when clicking on a classname
_________________
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 |
|
 |
Kvist How do I cheat?
Reputation: 0
Joined: 11 Aug 2022 Posts: 6
|
Posted: Tue Aug 30, 2022 9:13 am Post subject: |
|
|
I assume you mean in Lazarus? I haven't downloaded it yet, but I figured it to be more useful when trying to grasp the source than just searching through the text using VSCode without any Pascal extensions.
I've spent a good part of the last week converting the info in celua.txt into type information for one of the better Lua extensions for VSCode, referring to the source where the signatures were unclear. Now that I'm learning there are different ways of calling methods, I'll have to rework this a bit and will definitely need to get Lazarus to get everything right.
|
|
| Back to top |
|
 |
|
|
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
|
|