Joined: 09 May 2003 Posts: 25287 Location: The netherlands
Posted: Tue Jun 14, 2016 8:34 am Post subject:
Almost all objects have a Tag property that can contain an integer
you can use that as an index into an array of objects you may with to use.
I often use createRef()/getRef() , but you could just as well create an custom table like mydata and use the Tag object as an index into that array ( mydata[Object.Tag] )
e.g at http://forum.cheatengine.org/viewtopic.php?p=5677212#5677212 I use createRef to add the Ultimap form to the registry table. (it returns an index into that table)
with getRef I am then able to get the ultimap Form at a later time. (Which I also pass on to the MenuItem object's Tag so that menu click can find the form as well)
Note that you can also encapsule multiple objects into one.
e.g:
data={}
data.form=myform
data.valuex=123
data.test="something"
createRef(data) will return a single integer which you can assign to the Tag property.
getRef can be used on that integer to get that data table _________________
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
In that example, since the timer's OnTimer function and menu item's OnClick function are within the scope of the form f passed to the formAddNotification function, wouldn't it be fine to use that reference instead?
Code:
registerFormAddNotification(function(f)
if f.ClassName=="TfrmUltimap" then
--spawn a timer that runs as soon as the gui is responsive again
local t=createTimer(nil)
t.Interval=1
t.OnTimer=function(t)
--add a copy selection to clipboard menuitem
f.ListView1.MultiSelect=true --enable multiselect
local mi=createMenuItem(f.PopupMenu1)
mi.Caption="Copy selection to clipboard"
mi.OnClick=function(m)
--code to copy to clipboard
local i
local lv=f.ListView1
local sl=createStringlist()
for i=0,lv.Items.Count-1 do
if lv.Items[i].Selected then
sl.add(lv.Items[i].Caption..' - '..lv.Items[i].SubItems[0]..' - '..lv.Items[i].SubItems[1])
end
end
writeToClipboard(sl.Text)
sl.destroy()
end
f.PopupMenu1.Items.add(mi)
t.destroy()
end;
end
end)
_________________
I don't know where I'm going, but I'll figure it out when I get there.
Joined: 09 May 2003 Posts: 25287 Location: The netherlands
Posted: Tue Jun 14, 2016 10:27 am Post subject:
Not sure exactly how lua handles this, but all I know is that the OnClick function will execute a long time after this script has finished (so likely also cleaned up some local vars)
Perhaps it works as it's in the context, but I don't know if that's to be trusted _________________
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
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