 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
predprey Master Cheater
Reputation: 24
Joined: 08 Oct 2015 Posts: 486
|
Posted: Fri May 20, 2016 11:23 pm Post subject: Enumerating list of Lua objects created? |
|
|
Suppose I created a form previously in Lua engine named "Form". If I run the script to create the form again, the previous form is not overwritten but a new form named "Form_1" is created.
These forms do not seemed to be assigned to CE as they do not show up when enumerating through all the getForm().Name.
Is there a way to find out all the list of global variables and objects created previously?
Another question I have is what is the flag "DoNotSaveInTable" for? I thought if set to false, it meant the form would appear inside "Table" submenu of CE's main window.
------------------------------------------------------------
EDIT: Ok, I read up on Lua environment. We can get the list of global variables through:
Code: | for n in pairs(_G) do print (n) end |
Though it would be easier if we can distill it down to those created by the user, but I guess that would be more complex.
Regarding "DoNotSaveInTable", it seems to dictate whether a form is saved together with the .CT file and doesn't affect if it is displayed as a menu item.
|
|
Back to top |
|
 |
Redouane Master Cheater
Reputation: 3
Joined: 05 Sep 2013 Posts: 363 Location: Algeria
|
Posted: Sat May 21, 2016 4:57 am Post subject: Re: Enumerating list of Lua objects created? |
|
|
To loop through all the user-created forms, you could write something like this:
Code: | for i,v in pairs(_G) do -- use _G or _ENV
if type(v) == 'userdata' and v['getClassName'] and v.getClassName() == 'TCEForm' then print(i);
end
end |
Also, you could create the form only once in your script, and show it when the script runs (Check if the form exists, if it does, show it, otherwise, create the form and save it in a global variable, then show it).
No idea about the doNotSaveInTable flag (never found it necessary to use it)
|
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 150
Joined: 06 Jul 2014 Posts: 4651
|
|
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 May 21, 2016 2:28 pm Post subject: |
|
|
to keep all the forms in some variable you can override original function:
Code: | collectedLuaCreatedForms = {}
if createFormOrig==nil then createFormOrig=createForm end
function createForm(...)
local newForm=createFormOrig(...)
collectedLuaCreatedForms[#collectedLuaCreatedForms+1] = newForm
return newForm
end
function destroyAllLuaCreatedForms()
for _,v in ipairs(collectedLuaCreatedForms) do
v.destroy()
end
collectedLuaCreatedForms = {}
end |
Then calling destroyAllLuaCreatedForms() will destroy all of them.
Or without overriding. You can use myCreateForm() to create forms. And destroyAllMyForms() to destroy all of them:
Code: | collectedMyForms = {}
function myCreateForm(...)
local newForm=createForm(...)
collectedMyForms[#collectedMyForms+1] = newForm
return newForm
end
function destroyAllMyForms()
for _,v in ipairs(collectedMyForms) do
v.destroy()
end
collectedMyForms = {}
end |
_________________
|
|
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
|
|