View previous topic :: View next topic |
Author |
Message |
xMichael Newbie cheater
Reputation: 0
Joined: 24 Jun 2012 Posts: 20
|
Posted: Thu Apr 18, 2019 9:27 am Post subject: Lua timer toggle script |
|
|
Hi, this may be a noob question but how would a lua script (or Auto Assemble script if easier) that toggles my auto assembler script (code injection) every second on and off look?
Is it possible to enable the script every second but disable it shortly after, like say 200 miliseconds.
This is for AI checking for enemy script, so I want to make them check for enemies every second and shortly after they do, disable the check and go on their way, basically a loop of this. Thanks for help! |
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4697
|
Posted: Thu Apr 18, 2019 4:53 pm Post subject: |
|
|
I think it's better to implement that logic in the code injection. If you don't want to call an api, have CE periodically update an address with the current time and read from that.
The Lua approach would be to use a timer to toggle the script. If it's a memory record, use memrec.Active = not memrec.Active; otherwise, call autoAssemble. Update the timer's interval in the timer itself.
The CE wiki has general information. Documentation is in celua.txt and examples are on these forums. _________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
xMichael Newbie cheater
Reputation: 0
Joined: 24 Jun 2012 Posts: 20
|
Posted: Fri Apr 19, 2019 3:29 pm Post subject: |
|
|
ParkourPenguin wrote: | I think it's better to implement that logic in the code injection. If you don't want to call an api, have CE periodically update an address with the current time and read from that. |
I have no idea what that means, I'm new to all of this
ParkourPenguin wrote: |
The Lua approach would be to use a timer to toggle the script. If it's a memory record, use memrec.Active = not memrec.Active; otherwise, call autoAssemble. Update the timer's interval in the timer itself.
The CE wiki has general information. Documentation is in celua.txt and examples are on these forums. |
I saw many topics on this forum and read the wiki and still am not sure how to do it. I think I have to use getMemoryRecordByDescription and toggle it in intervals but Im not sure how |
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4697
|
Posted: Fri Apr 19, 2019 10:40 pm Post subject: |
|
|
That means you should be using cmp and jcc instructions.
e.g.:
Code: | mov eax,[lastCheckTime]
mov ecx,[currentTime] // Lua timer writes to currentTime
add eax,#1000
cmp eax,ecx // if 1000ms has passed, check it again
jle skip
mov [lastCheckTime],ecx
// do checks here
skip:
// original code |
With the Lua way, the code might look like this:
Code: | local memrec = getAddressList().getMemoryRecordByDescription'My Check Script'
if checkT then checkT.destroy() end
checkT = createTimer()
checkT.Interval = 200
checkT.OnTimer = function(t)
memrec.Active = not memrec.Active
t.Interval = memrec.Active and 200 or 1000
end |
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
xMichael Newbie cheater
Reputation: 0
Joined: 24 Jun 2012 Posts: 20
|
Posted: Sat Apr 20, 2019 1:31 am Post subject: |
|
|
Thank you man, it works  |
|
Back to top |
|
 |
|