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 


Need some help with Lua Timer.

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

Joined: 20 Jul 2017
Posts: 17

PostPosted: Sat Dec 09, 2017 3:17 am    Post subject: Need some help with Lua Timer. Reply with quote

I am trying to write a script with multiple timers. The 1st timer works perfectly but the 2nd timer isn't operating as I'd like.

timer10 = createTimer(nil, true)
timer_setInterval(timer10, 1)

function Loop()


NoObstaclesValue = 11536506

HighBeesZ1 = 1224.871094
HighBeesX1 = 313.856842
HighBeesZ2 = 1161.190063
HighBeesX2 = 345.2701721



local NoObstacle = readBytes("0x63BE94")
local ZClick = readFloat("[game.exe + 01F5DDA4] + 1FC")
local XClick = readFloat("[game.exe + 01F5DDA4] + 1F4")
local ZTele = readFloat("[game.exe + 01F5DDA4] + 58")
local XTele = readFloat("[game.exe + 01F5DDA4] + 50")




if isKeyPressed(0x4A) then
FarmingStage1 = 1
end

if (FarmingStage1 == 1) then
writeFloat("[game.exe + 01F5DDA4] + 1FC",HighBeesZ1)
writeFloat("[game.exe + 01F5DDA4] + 1F4",HighBeesX1)
writeInteger("0x221CF14",6)
doKeyPress(0x75)
end

if (FarmingStage1 == 1) and (ZTele > 1223) and (ZTele < 1225) and (XTele > 312) and (XTele < 314) then
FarmingStage1 = 2
end

if (FarmingStage1 == 2) then
doKeyPress(0x72)
end


if (FarmingStage1 == 2) then
local timer1 = createTimer(getMainForm())
timer1.Interval = 60000
timer1.OnTimer = function(timer)
FarmingStage1 = 3
FarmingStage2 = 1
DoneState1 = true
if DoneState1 == true then
timer1.destroy()
end
end
end






if (FarmingStage2 == 1) then
writeFloat("[game.exe + 01F5DDA4] + 1FC",HighBeesZ2)
writeFloat("[game.exe + 01F5DDA4] + 1F4",HighBeesX2)
writeInteger("0x221CF14",6)
doKeyPress(0x71)
end

if (FarmingStage2 == 1) and (ZTele > 1159) and (ZTele < 1162) and (XTele > 343) and (XTele < 346) then
FarmingStage2 = 2
end

if (FarmingStage2 == 2) and (FarmingStage1 == 3) then
doKeyPress(0x72)
end


if (FarmingStage2 == 1) then
local timer2 = createTimer(getMainForm())
timer2.Interval = 60000
timer2.OnTimer = function(timer)
FarmingStage2 = 3
FarmingStage1 = 1
DoneState2 = true
if DoneState2 == true then
timer2.destroy()
end
end
end




end
timer_onTimer(timer10, Loop)


(0x71) is supposed to spam while FarmingStage2 == 1 but it continues to spam even after FarmingStage2 changes to 2. If anyone can tell me what I'm doing wrong I'd very much appreciate it. Thank you so much in advance.
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