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 repeat a timer?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
etioplmld
Advanced Cheater
Reputation: 0

Joined: 09 Feb 2021
Posts: 72

PostPosted: Thu Sep 29, 2022 4:13 am    Post subject: how to repeat a timer? Reply with quote

make this function execute repeatedly,to get 5,4,3,2,1,0.end, 5,4,3,2,1,0.end......
This code can run.

Code:

function countdownuse()
local jsct = 5
function countdown()
  if jsct >= 0 then
   print(jsct)
  jsct = jsct - 1
  else
      print("end")
  cdjs.destroy()
  end
end

cdjs = createTimer()
cdjs.interval = 1000
cdjs.OnTimer = countdown
end
countdownuse()

but This is bug code
Code:

function countdownuse()
local jsct = 5
function countdown()
  if jsct >= 0 then
   print(jsct)
  jsct = jsct - 1
  else
      print("end")
  cdjs.destroy()
  end
end

cdjs = createTimer()
cdjs.interval = 1000
cdjs.OnTimer = countdown
end

for n = 0, 5 do
countdownuse()
end
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Thu Sep 29, 2022 6:46 am    Post subject: Reply with quote

instead of
Code:

print("end")
cdjs.destroy()

do
Code:

jsct=0


and perhaps add another counter to make it stop after 6 times

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
etioplmld
Advanced Cheater
Reputation: 0

Joined: 09 Feb 2021
Posts: 72

PostPosted: Thu Sep 29, 2022 8:48 am    Post subject: Reply with quote

oh,good idea ,it is this.

Code:

cdjs = createTimer()
local maincount = 3
local jsct = 5
function countdown()
  if(jsct > 0 and maincount>0 )then
   print(jsct)
  jsct = jsct - 1
  elseif (jsct == 0 and maincount>0) then
    jsct = 5
    maincount = maincount - 1
     print("end")-- do some thing
  else
   print("realend") -- do some thing
   cdjs.destroy()
  end
end
cdjs.interval = 1000
cdjs.OnTimer = countdown
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