Page 1 of 1

[HELP]Lua help

Posted: Fri Apr 23, 2021 1:57 am
by Wjb1001
Hello,

I have two separate Lua scripts. One of the scripts is supposed to run on a timer when a byte address value is set to 0, and the other script is supposed to run on a timer when the value is set to 1. I already have the timers and scripts set up correctly, but the issue is I don't know how to set it up so that the scripts will only run when the value is set to specifically 1 or 0.

This is the address that will have a value of either 1 or 0: [pCubic]+4C0

This is the script that should run when the value is 0

Code: Select all

function CETrainer_CETimer1Timer(sender)
sleep(1500)
writeInteger("Cubic.exe+311B0A", 128)
writeInteger("Cubic.exe+311D0D", 128)
sleep(1125)
writeInteger("Cubic.exe+311B0A", 0)
writeInteger("Cubic.exe+311D0D", 0)
end
This is the script that should run when the value is 1

Code: Select all

function CETrainer_CETimer3Timer(sender)
writeInteger("Cubic.exe+311B0A", 128)
writeInteger("Cubic.exe+311D0D", 128)
sleep(100)
writeInteger("Cubic.exe+311B0A", 0)
writeInteger("Cubic.exe+311D0D", 0)
end
Thank you!

Re: [HELP]Lua help

Posted: Fri Apr 23, 2021 3:47 am
by Eric
use a single timer.
In that use readInteger("[pCubic]+4C0") to check the current value, and then execute the specific script you like

Re: [HELP]Lua help

Posted: Fri Apr 23, 2021 12:13 pm
by Wjb1001
How would that script work? I tried something like this, but I'm not sure what I am doing wrong.

Code: Select all

function CETrainer_CETimer1Timer(sender)
  readInteger("[pCubic]+4C0")
if ("[pCubic]+4C0" == 0) then
sleep(1500)
writeInteger("Cubic.exe+311B0A", 128)
writeInteger("Cubic.exe+311D0D", 128)
sleep(1125)
writeInteger("Cubic.exe+311B0A", 0)
writeInteger("Cubic.exe+311D0D", 0)
end
end

Re: [HELP]Lua help

Posted: Fri Apr 23, 2021 12:22 pm
by TimFun13
readInteger returns a value, you need to check that. You're only checking if the string is equal to zero.