simonzack Newbie cheater Reputation: 0
Joined: 19 Jun 2014 Posts: 15
|
Posted: Thu Jun 19, 2014 10:19 am Post subject: How to run lua script every once a while? |
|
|
I'm doing a cheat table on wolfenstein the new order, and the player struct's index changes once a while, and I would like to update the calculated index using my lua script.
How would I be able to run it every once a while, preferably just before cheat engine's "freeze" updates?
|
|
alanze Advanced Cheater Reputation: 3
Joined: 03 Oct 2012 Posts: 50
|
Posted: Sun Jun 22, 2014 2:21 pm Post subject: |
|
|
Try this timer loop to update the indexes:
Code: |
t1=createTimer(nil, false)
function startTimer(timer, func, mlsec)
timer.onTimer=func
timer.Interval=mlsec
timer.Enabled=true
end
function updateIndex()
--
-- this section will be executed every 4 minutes,
-- insert the script here to update the indexes.
--
end
startTimer(t1, updateIndex, 240000) --set the time here in milliseconds
|
Your indexes will be updated every 4 minutes, change 240000 to any milisecond, for example 60000 to get 1 minute interval.
You can stop the timer this way:
t1.Enabled=false
Or start it again:
startTimer(t1, updateIndex, 240000)
Do NOT start it multiple times!
Be careful with "t1", do not use it for other purposes,
instead create another timer object, like "t2", "t3"... and use this way:
Code: |
t2=createTimer(nil, false)
startTimer(t2, yourFunction, 5000)
|
Destroy the timer object if you don't need it anymore:
Code: |
t2.Destroy()
t2=nil
|
Good luck.
|
|