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 


timer question, please help

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

Joined: 08 Oct 2020
Posts: 71

PostPosted: Sun Nov 08, 2020 12:48 pm    Post subject: timer question, please help Reply with quote

hi, this is my case code :
Code:

--for exit program press "/" on numpad
createHotkey(
    function()
        closeCE()
    end,
    VK_DIVIDE
)

--for requested code, press "-" on numpad
createHotkey(
    function()
        --the code
    end,
    VK_SUBTRACT
)

Count = 0
t = createTimer(UDF1)
--interval = 10 second
t.Interval = 10000
t.OnTimer = function(t)
  Count = Count + 1 
  Print(Count)
end
t.Enabled = true

the code that I like is, when the "-" Numpad button pressed, the count will print instantly and reset the timer, so the timer will wait another 10 seconds to print another Count, and yes if you press the "-" Numpad button 5 times, the count will print 5 times too

thanks for reading, have a nice day
Back to top
View user's profile Send private message
ByTransient
Expert Cheater
Reputation: 5

Joined: 05 Sep 2020
Posts: 240

PostPosted: Sun Nov 08, 2020 3:13 pm    Post subject: Reply with quote

The explanation is complicated "printing 5 times" etc.
I just tweaked your code.
You can give a little more detail.

Code:
if t then t.destroy() end
t = createTimer() --(UDF1)
--interval = 10 second
t.Interval = 1000 --10000
t.Enabled = false

local textIndex=0
local Count = 0

function codeActivate()
print("The code is activated!")
end

function Closed()
       -- closeCE()
print("Trainer Closed!")
end

t.OnTimer = function(t)
  Count = Count - 1
  if textIndex==1 then
  Print("To activate the code: "..Count)
  if Count==1 then sleep(500) codeActivate()
t.Enabled = false end
  end
  if textIndex==2 then
  Print("To turn off the trainer: "..Count)
  if Count==1 then sleep(500) Closed()
t.Enabled = false end
  end
end

--for exit program press "/" on numpad
createHotkey(
    function()
    sleep(200)
    Count=6
    textIndex=2
    t.Enabled = true
    end,
    VK_DIVIDE
)

--for requested code, press "-" on numpad
createHotkey(
    function()
    sleep(200)
    Count=6
    textIndex=1
    t.Enabled = true
    end,
    VK_SUBTRACT
)
Back to top
View user's profile Send private message
kucingkembar
Advanced Cheater
Reputation: 0

Joined: 08 Oct 2020
Posts: 71

PostPosted: Sun Nov 08, 2020 3:31 pm    Post subject: Reply with quote

ah silly of me, I forgot I can do this

Code:


Count = 0

function dosomething()
  Count = Count + 1
  Print(Count)
end

--for requested code, press "-" on numpad
createHotkey(
    function()
        dosomething()
    end,
    VK_SUBTRACT
)

t = createTimer(UDF1)
--interval = 10 second
t.Interval = 10000
t.OnTimer = function(t)
    dosomething()
end
t.Enabled = true


anyway, note your code seems is I not looking for, it does not even contain any "Print(Count)", but thank you for the hard work, I really appreciate it
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