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 


Expanding on a script by Freiza...

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
mg_01
How do I cheat?
Reputation: 0

Joined: 28 Jan 2018
Posts: 8

PostPosted: Mon Feb 12, 2018 8:18 am    Post subject: Expanding on a script by Freiza... Reply with quote

Hi, I've been wanting to create a custom form to see certain addresses' values update in real time.

I've been adding onto Freiza's script from an old post:

Code:
openProcess([[processnamehere]])  --put process name here

addresslist = getAddressList()
myform= createForm()
label1 = createLabel(myform)
label2 = createLabel(myform)
value1 = nil
value2 = nil
local t=createTimer(nil)

description1= [[Description of memoryrecord1]]   -- put description of memory record 1 here
local memrec1=addresslist_getMemoryRecordByDescription(addresslist, description1)


description2= [[Description of memoryrecord2]]   -- put description of memory record 2 here
local memrec2=addresslist_getMemoryRecordByDescription(addresslist, description2)

function changing()

value1=memoryrecord_getValue(memrec1)

control_setPosition(label1, 10,10)
control_setCaption(label1, value1)

value2=memoryrecord_getValue(memrec2)

control_setPosition(label2, 10,30)
control_setCaption(label2, value2)

return true
end

function start(memoryrecord, before, currentstate)
  timer_onTimer(t, changing)
  timer_setInterval(t,100) --really short wait (setting the speed on open won't work)
  timer_setEnabled(t, true)

return true

end

memoryrecord_onActivate(memrec1, start)
memoryrecord_onActivate(memrec2, start)


I just wanted to know if it's possible to have it display the static name of the description somewhere in there. I'm really new to this and I was gonna try to write another form with just the names, but I got lost trying to find that too.

Any help would be appreciated.
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater
Reputation: 30

Joined: 09 Aug 2013
Posts: 711

PostPosted: Mon Feb 12, 2018 8:23 am    Post subject: Reply with quote

at a guess memoryrecord_getDescription(mr), but I've never really used those functions since I started scripting after DB added the OOP syntax (mr.Value / mr.Description)


edit: hm, or are you asking for the code to add more labels so you can set them? I'd say just use the form editor to setup what you want visually and then use the lua code to reference it (CE will automatically create a variable for the formname, so if the name of the form is "MyForm" CE will set the global variable MyForm aka _G['MyForm'] to that form object, the label named MyLabel would be accessed via MyForm.MyLabel).
Back to top
View user's profile Send private message
mg_01
How do I cheat?
Reputation: 0

Joined: 28 Jan 2018
Posts: 8

PostPosted: Mon Feb 12, 2018 8:38 am    Post subject: Reply with quote

Oh, I just wanted to see the Descriptions next to the changing values. I think the bottom lines are what get posted into the form right? Could "memoryrecord_getDescription(mr)," be used there?

So i'd see:
Code:

Description1    *changing values*
Description2    *changing values*


Also, to terminate the script, could I create a form with a button to stop the script somehow?

Edit, I added 5 items to that list -- was there a way to view the form that the Lua script created in the form editor inside of CE?
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater
Reputation: 30

Joined: 09 Aug 2013
Posts: 711

PostPosted: Mon Feb 12, 2018 9:16 am    Post subject: Reply with quote

memoryrecord_getDescription(mr) would get the description/name of the memory record, though now that I think about it since you have those in the script to get the memory record in the first place I'm not sure it's really necessary, you could probably just do control_setCaption(label1, description1 .. ' ' .. value1)

To open a script created form in the editor... I suppose you could save it and then load it
Code:
form_saveToFile(myform, os.getenv('userprofile')..'\\Desktop\\form.frm')
probably be just as quick to simply remake it if all you have is a few labels however...

as for a button toggling the update
Code:
button1 = createButton(myform)
function toggle()
  timer_setEnabled(t,not timer_getEnabled(t))
end
control_onClick(button1, toggle)
Back to top
View user's profile Send private message
mg_01
How do I cheat?
Reputation: 0

Joined: 28 Jan 2018
Posts: 8

PostPosted: Mon Feb 12, 2018 12:11 pm    Post subject: Reply with quote

Thank you! I wasn't sure where to add the ".." to join stuff, and it was a pain to keep having to close the CE to rerun the script.

I ended up writing an Excel thing to make me my own script every time using descriptions of my choosing -- so I was going to just keep running it from Lua directly.

However, I ran into a silly problem. The form isn't tall enough to show all the descriptions I have. I'm not sure how to add a scrollbar or change the height of the form through Lua.

Edit**: Found out where to declare the height/width.
Code:

myform= createForm()
myform.Height = 700
myform.Width = 400
Back to top
View user's profile Send private message
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