[HELP]Lua help

Want Cheat Engine to do something specific and no idea how to do that, ask here. (From simple scripts to full trainers and extensions)
Post Reply
Wjb1001
Noobzor
Noobzor
Posts: 6
Joined: Tue Jun 02, 2020 5:56 am
Reputation: 0

[HELP]Lua help

Post 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!

Eric
Hall of Famer
Hall of Famer
Posts: 174
Joined: Thu Mar 02, 2017 11:01 pm
Reputation: 90

Re: [HELP]Lua help

Post 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

Wjb1001
Noobzor
Noobzor
Posts: 6
Joined: Tue Jun 02, 2020 5:56 am
Reputation: 0

Re: [HELP]Lua help

Post 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

TimFun13
Expert Cheater
Expert Cheater
Posts: 1353
Joined: Fri Mar 03, 2017 12:31 am
Reputation: 7

Re: [HELP]Lua help

Post by TimFun13 »

readInteger returns a value, you need to check that. You're only checking if the string is equal to zero.

Post Reply

Who is online

Users browsing this forum: No registered users