View previous topic :: View next topic |
Author |
Message |
mgr.inz.Player I post too much
Reputation: 221
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sat Jul 27, 2013 5:37 am Post subject: onPostLoadTable (executed after CheatTable file is loaded) |
|
|
onPostLoadTable here
OLD:
Can we somehow create onLoadTable event function?
Table opened manually with "File -> Open", or "CTRL+O", or second icon click.
Table loaded with loadTable(filename, merge OPTIONAL) or "Load the associate table" should be ignored. Or better, extra case parameter:
Code: | function onLoadTable(case)
if case='lua' then .....
else if case='associate' then .....
else if case='manual' then .....
end
end |
Edit:
change topic. And add link to onPostLoadTable release 1.
_________________
Last edited by mgr.inz.Player on Sat Jul 27, 2013 4:56 pm; edited 2 times in total |
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 468
Joined: 09 May 2003 Posts: 25706 Location: The netherlands
|
Posted: Sat Jul 27, 2013 5:54 am Post subject: |
|
|
Not really, but you can intercept the button clicks and function. But there is no way with the button clicks to see what the name of the lua file is. Just check the changes in the addreslist or structure list
Code: |
if OldOpenClick==nil then
OldOpenClick=getMainForm().LoadButton.OnClick
end
function MyNewOpen(sender)
print("Before Open");
OldOpenClick(sender)
print("After Open(Check the table if it got changed...");
end
getMainForm().LoadButton.OnClick=MyNewOpen;
getMainForm().Load1.OnClick=MyNewOpen;
------
if OldLoadTable==nil then
OldLoadTable=loadTable
end
function loadTable(filename, merge)
local r;
print("loadTable from lua");
r=OldLoadTable(filename, merge)
print("after loadTable from lua");
return r
end
|
_________________
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 |
|
 |
mgr.inz.Player I post too much
Reputation: 221
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sat Jul 27, 2013 6:02 am Post subject: |
|
|
"there is no way with the button clicks to see what the name of the lua file is"
You meant ct file?
Anyway, even with readStringLocal function ?
_________________
|
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 468
Joined: 09 May 2003 Posts: 25706 Location: The netherlands
|
Posted: Sat Jul 27, 2013 6:05 am Post subject: |
|
|
Oh wait yes, I forgot about the opendialog object
Code: |
getMainForm().OpenDialog1.Filename
|
holds the filename
_________________
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 |
|
 |
mgr.inz.Player I post too much
Reputation: 221
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sat Jul 27, 2013 6:14 am Post subject: |
|
|
heh, I found address, but this solution is better
Edit:
I will try to add recently opened files inside File submenu.
_________________
|
|
Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 221
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sat Jul 27, 2013 4:54 pm Post subject: onPostLoadTable function. |
|
|
Finally I made onPostLoadTable function. Add this script to autorun folder. From now on, you can use onPostLoadTable.
function onPostLoadTable(filename,oltc,result)
If this function is defined it will be called whenever cheat engine loads a CheatTable.
filename: filename (full path) of last opened CheatTable file
oltc: possible values are: oltcManual - file loaded manually (icon click, menu click, ctrl+o), oltcLua - file loaded with Lua
result: possible values are: true, false when loaded with Lua (true means it loaded); mrOK and mrCancel when loaded manually.
Note: true, false when loaded with Lua doesn't work with ce6.3 because original "loadTable" doesn't return any result (maybe in ce6.4)
Code: | -- #### create onPostLoadTable function
oltcManual = 0
oltcLua = 1
if not LoadButtonOnClick then LoadButtonOnClick = getMainForm().LoadButton.OnClick end -- manually
if not LuaLoadTable then LuaLoadTable = loadTable end -- lua
function openWithButtonOrMenu(sender)
LoadButtonOnClick(sender)
local drOffset = cheatEngineIs64Bit() and 0xB8 or 0x64
--mrOK, mrCancel
local dialogResult = readIntegerLocal(userDataToInteger(getMainForm().OpenDialog1)+drOffset)
local filename = getMainForm().OpenDialog1.Filename
onPostLoadTable(filename,oltcManual,dialogResult)
end
function openWithLua(filename,merge)
local result = LuaLoadTable(filename,merge)
onPostLoadTable(filename,oltcLua,result)
return result
end
getMainForm().LoadButton.OnClick = openWithButtonOrMenu -- button
getMainForm().Load1.OnClick = openWithButtonOrMenu -- menu
loadTable = openWithLua
-- example,
function onPostLoadTable(filename,oltc,result)
if oltc==oltcLua then
-- result can be true or false (true=loaded successfuly, false=fail)
-- yourcode here
elseif oltc==oltcManual then
-- result can mrOK and mrCancel
-- yourcode here
end
end
-- ### |
@DB,
I used this trick to get dialog result. Maybe there is better method?
Code: | local drOffset = cheatEngineIs64Bit() and 0xB8 or 0x64
local dialogResult = readIntegerLocal(userDataToInteger(getMainForm().OpenDialog1)+drOffset) |
And, you wrote:
Code: | function loadTable(filename, merge)
local r;
print("loadTable from lua");
r=OldLoadTable(filename, merge)
print("after loadTable from lua");
return r
end |
But I don't see any lua_push* inside lua_loadTable function. But I added this anyway.
_________________
|
|
Back to top |
|
 |
|