|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
GodKratos Cheater Reputation: 0
Joined: 18 Jul 2011 Posts: 29
|
Posted: Wed Aug 10, 2011 5:40 am Post subject: Useful LUA functions |
|
|
I've just found the Lua scripting functionality in CE so have been looking through the tutorials to figure out how to use it.
Here are some useful functions I have started collating that seem to be quite common for a lot of scripts that I thought would be useful to have in one place.
Many of these are copies of functions I have adapted from various posts in this forum (mainly from DB, geri and Wiccaan) so I hope they don't mind I've been using them
Automatically attach your script to a process
Just alter the process name in both parts of this function and attach it to a timer object on your form.
UPDATE: Ignore this one, this is deprecated by using strings_add(getAutoAttachList(), "Process.exe")
Code: | -- Attach to timer to auto open process.
function findProcessTimer(sender)
if getProcessIDFromProcessName("process.exe") ~= nil then
object_destroy(sender)
openProcess("process.exe")
end
end |
Search for byte pattern and return address or label
This is a handy search function for AOBScan.
Send it the search you want and which one from the results to return and it will map that address to the label you give it.
The function returns nil if the search failed or the address of the result if it succeeded.
Code: | -- Scan for bytes and map to an address label
-- varSearch is the string to search for
-- varCount is the index of the scan to find (1 based)
-- varLabel is the label to create from the address found
function globalScanAndLabel(varSearch, varCount, varLabel)
local varResults = AOBScan( varSearch );
local bFound = false
if (varResults ~= nil) then
local varTotal = stringlist_getCount(varResults)
if (varTotal >= varCount) then
local varAddress = stringlist_getString(varResults, varCount - 1)
registerSymbol(varLabel, varAddress)
bFound = true
end
object_destroy(varResults)
varResults = nil
end
if ( bFound ) then
return varLabel
else
return nil
end
end |
Display value on form
This function will set the text of a form control to the value of a specific memory address.
Handy for displaying game values in your form.
Currently it is only working for integer values until someone can tell me how to use the readBytes function correctly.
I'm not sure what object type that function returns as every time I use it I only seem to get the value of the first byte.
Code: | -- Update the Caption or Text attribute of a specific control.
-- Usually best called from a timer object.
-- varAddress The address to return a value from
-- varBytes the number of bytes to read from that address
-- varControlCaption the control you wish to alter the caption of
function globalDisplayValue(varAddress, varBytes, varControl)
local varValue = readInteger(varAddress) --, varBytes) --need to use readBytes
control_setCaption(varControl, varValue)
end |
I will update this post with more useful things as I can.
---------------------------------------------------------------------
Dammit I can't double post so I'll add this here....
Strange I've just created an executable trainer from a script I was working on that has the following functions:
Code: | function TmrProcessFindTimer(sender)
if getProcessIDFromProcessName("ff7.exe") ~= nil then
object_destroy(sender)
openProcess("ff7.exe")
end
end
function TmrUpdateFormTimer(sender)
if (getOpenedProcessID() == 0) then
return
end
if not (wincontrol_focused(FF7Trainer_TxtGil)) then
globalDisplayValue("ff7.exe+9C08B4", 4, FF7Trainer_TxtGil)
end
end
-- Update the Caption or Text attribute of a specific control.
-- Usually best called from a timer object.
-- varAddress The address to return a value from
-- varBytes the number of bytes to read from that address
-- varControlCaption the control you wish to alter the caption of
function globalDisplayValue(varAddress, varBytes, varControl)
local varValue = readInteger(varAddress) --, varBytes) --need to use readBytes
control_setCaption(varControl, varValue)
end
form_show(FF7Trainer)
function FormClose(sender)
closeCE()
return caHide --hide, not destroy
end |
If I save this from CE as a .CT table file I can open that file and when CE launches I click yes to launch the lua script and it attaches to the process and updates the gil text box with my amount of gil from the timer.
However, when I save the trainer as an .exe file when I open it the gil value (originally a 1 on the form) just gets blanked out instead.
The process is attaching correctly or else the value wouldn't change at all but for some reason its not reading the correct data when its an exe ??
|
|
Back to top |
|
|
Pyscho Newbie cheater Reputation: 0
Joined: 24 Mar 2012 Posts: 23
|
Posted: Sat Mar 24, 2012 7:04 pm Post subject: |
|
|
Wow these a pretty useful thanks!
|
|
Back to top |
|
|
Invader Advanced Cheater Reputation: 0
Joined: 19 Mar 2012 Posts: 78
|
Posted: Sun Aug 05, 2012 2:50 pm Post subject: |
|
|
Thanks It was useful To me
|
|
Back to top |
|
|
federan How do I cheat? Reputation: 0
Joined: 25 Jan 2011 Posts: 3 Location: ARGENTINA
|
Posted: Mon Dec 17, 2012 11:56 pm Post subject: |
|
|
Thank you so much for the readInteger thingie, that is awesome for my actual trainer.
|
|
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 cannot download files in this forum
|
|