| View previous topic :: View next topic |
| Author |
Message |
tdr2012 Cheater
Reputation: 0
Joined: 02 Nov 2014 Posts: 26
|
Posted: Mon Nov 02, 2015 11:25 am Post subject: Autorunning a lua script in a saved .exe Trainer |
|
|
| Is there a way to run a LUA table script (not in the Cheat Table) that's part of the trainer when the trainer.exe file is launched?
|
|
| Back to top |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Mon Nov 02, 2015 8:31 pm Post subject: |
|
|
Use notepad to writing your code (as a function).
Save it as a Lua fle (example : code.lua)
Next, add that file code.lua to your trainer with Table > Add file in CE.
in your trainer script add this function (** Credit to Panraven **)
| Code: |
function loadTableCode(n)
local t = findTableFile(n)
if t ~= nil then
local s = t.Stream
local c = readStringLocal(s.Memory,s.Size)
return c ~= nil and loadstring(c) -- return a function
end
end
--
local f = loadTableCode('code.lua')
print(type(f))
if type(f) == 'function' then f() else print('not loaded') end
|
Sample of code.lua file
| Code: |
function load_myCode()
..
..
..
your script here...
end ----- end of function load_myCode()
|
Next on your trainer script should be like this :
| Code: |
f = createForm(false)
b = cerateButton(f)
..
...
.. your other trainer script
..
if bla bla bla then
..
..
end
load_myCode() ------ load your code from code.lua file
..
..
|
After you did all, try run your trainer and if everything you think is okay, then save tour trainer as stand alone exe file.
|
|
| Back to top |
|
 |
tdr2012 Cheater
Reputation: 0
Joined: 02 Nov 2014 Posts: 26
|
Posted: Mon Nov 02, 2015 11:43 pm Post subject: |
|
|
| Corroder wrote: | Use notepad to writing your code (as a function).
Save it as a Lua fle (example : code.lua)
Next, add that file code.lua to your trainer with Table > Add file in CE.
in your trainer script add this function (** Credit to Panraven **)
| Code: |
function loadTableCode(n)
local t = findTableFile(n)
if t ~= nil then
local s = t.Stream
local c = readStringLocal(s.Memory,s.Size)
return c ~= nil and loadstring(c) -- return a function
end
end
--
local f = loadTableCode('code.lua')
print(type(f))
if type(f) == 'function' then f() else print('not loaded') end
|
Sample of code.lua file
| Code: |
function load_myCode()
..
..
..
your script here...
end ----- end of function load_myCode()
|
Next on your trainer script should be like this :
| Code: |
f = createForm(false)
b = cerateButton(f)
..
...
.. your other trainer script
..
if bla bla bla then
..
..
end
load_myCode() ------ load your code from code.lua file
..
..
|
After you did all, try run your trainer and if everything you think is okay, then save tour trainer as stand alone exe file. |
Awesome.
I was able to do all of the above steps, and yes, it does autorun the script when I launch the standalone .exe trainer file now. I do have one other question though.
When the trainer .exe file runs with the call to load_myCode() function (after doing all the steps above), a Lua Engine window appears each time. Is there a way to make it so this windows doesn't appear on launch each time?
Thanks so much, again.
|
|
| Back to top |
|
 |
lolAnonymous Expert Cheater
Reputation: 1
Joined: 19 Jul 2015 Posts: 154
|
Posted: Tue Nov 03, 2015 1:05 am Post subject: |
|
|
Put This In The Starting Of Your Trainer Script
| Code: | getLuaEngine().cbShowOnPrint.Checked=false
getLuaEngine().hide() |
|
|
| Back to top |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Tue Nov 03, 2015 7:12 am Post subject: |
|
|
Question solved by MasterHacking...
Regard
|
|
| Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Tue Nov 03, 2015 8:16 am Post subject: |
|
|
"Lua Engine window appears each time"
because of a print line, one before last, in Corroder post. just remove this line.
Better do not hide "Lua Engine". If something goes wrong, you won't get any feedback. Just write a script the proper way.
An example, my script which adds Redo (undo) functionality into CE's "Disassembler View":
http://forum.cheatengine.org/viewtopic.php?t=585076
Script looks and works pretty good. Today I found out that I forgot to handle some "unexpected" situations. The problem occurs when AA script tries to alter some bytes on non-writable memory page.
I got feedback in Lua Engine window. I updated my script to version 1.04 today, now my script is even better than before.
_________________
|
|
| Back to top |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Tue Nov 03, 2015 7:33 pm Post subject: |
|
|
mgr.inz.Player,
Is this "Undo" function should work only in AA or for whole we changed in CE?. I mean, example : We do manually scan for an AOB and replace it with our code. Can we "undo" the AOB return back to their original with the function ?. Sorry, I am not try it yet.
Thank you and regard
|
|
| Back to top |
|
 |
lolAnonymous Expert Cheater
Reputation: 1
Joined: 19 Jul 2015 Posts: 154
|
Posted: Tue Nov 03, 2015 7:42 pm Post subject: |
|
|
Hey Corroder,
Yes Corroder I think we can undo the Aob we change but remember u should know the place of that aob in memory viewer I mean when u scan a aob click on it and press Ctrl+D then do the change what u want... It will help u to know from where this aob came...
Thanks[/list]
|
|
| Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
|
| Back to top |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Wed Nov 04, 2015 10:28 am Post subject: |
|
|
Thank Zanzer,
So if I am not wrong,
this :
local pattern = "48 83 EC 28 E8 ?? ?? ?? ?? 48 83 C4 28"
local replace = "?? ?? ?? ?? 90 90 90 90 90 ?? ?? ?? ??"
will replace "E8 ?? ?? ?? ??" with "90 90 90 90 90" for every match pattern found in whole process memory get opened ignoring the addresses too.
Then it should work too if I am use same function to return back the AOB pattern as their original AOB (Like toggle on/off function), right ?.
Regard
|
|
| Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Wed Nov 04, 2015 6:01 pm Post subject: |
|
|
| That is correct.
|
|
| Back to top |
|
 |
tdr2012 Cheater
Reputation: 0
Joined: 02 Nov 2014 Posts: 26
|
Posted: Fri Nov 06, 2015 11:21 am Post subject: |
|
|
| mgr.inz.Player wrote: | "Lua Engine window appears each time"
because of a print line, one before last, in Corroder post. just remove this line.
Better do not hide "Lua Engine". If something goes wrong, you won't get any feedback. Just write a script the proper way.
An example, my script which adds Redo (undo) functionality into CE's "Disassembler View":
h?ttp://forum.cheatengine.org/viewtopic.php?t=585076
Script looks and works pretty good. Today I found out that I forgot to handle some "unexpected" situations. The problem occurs when AA script tries to alter some bytes on non-writable memory page.
I got feedback in Lua Engine window. I updated my script to version 1.04 today, now my script is even better than before. |
Thanks for the share. This is pretty good! And yes, you're right, it probably is better to leave the lua engine window to open. I just found that one of my scripts was stuck in an endless loop, but was still performing what I wanted it to do. If I didn't leave the Lua engine window open, I wouldn't have seen the repeated call to one of my functions.
|
|
| Back to top |
|
 |
|