Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


How to run lua script every once a while?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
simonzack
Newbie cheater
Reputation: 0

Joined: 19 Jun 2014
Posts: 15

PostPosted: Thu Jun 19, 2014 10:19 am    Post subject: How to run lua script every once a while? Reply with quote

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?
Back to top
View user's profile Send private message
alanze
Advanced Cheater
Reputation: 3

Joined: 03 Oct 2012
Posts: 50

PostPosted: Sun Jun 22, 2014 2:21 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites