Posted: Mon Jan 07, 2019 11:37 am Post subject: Click on button event to enable Lua script (help)
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}
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)
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.
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