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 


onPostLoadTable (executed after CheatTable file is loaded)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sat Jul 27, 2013 5:37 am    Post subject: onPostLoadTable (executed after CheatTable file is loaded) Reply with quote

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
View user's profile Send private message MSN Messenger
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Sat Jul 27, 2013 5:54 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sat Jul 27, 2013 6:02 am    Post subject: Reply with quote

"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
View user's profile Send private message MSN Messenger
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Sat Jul 27, 2013 6:05 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sat Jul 27, 2013 6:14 am    Post subject: Reply with quote

heh, I found address, but this solution is better Razz

Edit:
I will try to add recently opened files inside File submenu.

_________________
Back to top
View user's profile Send private message MSN Messenger
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sat Jul 27, 2013 4:54 pm    Post subject: onPostLoadTable function. Reply with quote

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
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