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 


Click on button event to enable Lua script (help)

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

Joined: 07 Jan 2019
Posts: 8

PostPosted: Mon Jan 07, 2019 11:37 am    Post subject: Click on button event to enable Lua script (help) Reply with quote

So basically I have a LUA script and have made a CheckBox which should enable my lua script. By checkbox I mean the one which you can add from scripting your trainer. What code should I put between function and end? I was wondering if I could just make it enable the script as I have attached the Cheat Table with the trainer. Can I just make it work with a few lines of code or do I have to write the entire code like normal.

Edit :

Heres the Script Code
Code:
 

[ENABLE]

{$lua}
function disableSelf(sender)
  sender.destroy()
  local addr=getAddressList().getMemoryRecordByDescription("TP to Bloodstain Position")
  memoryrecord_unfreeze(addr)
end

local t=createTimer(nil)
t.OnTimer=disableSelf
t.Interval=400
t.Enabled=true
{$asm}


[[[[[[BaseX]+68]+18]+28]+50]+20]+120:
readmem([[BaseB]+40]+0,12)

[[[[BaseX]+68]+18]+28]+10:
readmem([[BaseB]+40]+0,12)

[DISABLE]


[/code]

_________________
uhh... hello?
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Wed Jan 09, 2019 7:27 am    Post subject: Reply with quote

Generically, put the code in an AA script in the table and use
Code:
AddressList.getMemoryRecordByDescription("Name of script").Active = sender.Checked
alternatively you can use the autoAssemble function and store the second return value when you enable it and pass that (along with the script) into autoAssemble when you want to disable it again (it's a table of registered symbols and allocated memory). The first is much easier though.

In this case you can probably just use readBytes and writeBytes in the event handler eg.
Code:
local bytes = readBytes('[[BaseB]+40]+0', 12, true)
writeBytes('[[[[[[BaseX]+68]+18]+28]+50]+20]+120', bytes)
writeBytes('[[[[BaseX]+68]+18]+28]+10', bytes)

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Wed Jan 09, 2019 9:27 am    Post subject: Reply with quote

Lua scripts also now have a variable "memrec" that either stores a reference to the memory record this script is a part of or is nil if it's not a part of the addresslist.

Code:
{$lua}
if syntaxcheck then return end
print(memrec and ('executed via memrec "%s"'):format(memrec.Description)
             or 'not executed via memrec')
[ENABLE]
[DISABLE]

_________________
I don't know where I'm going, but I'll figure it out when I get there.
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 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