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 


help me to add if statment to the code

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Twistedfate
Expert Cheater
Reputation: 1

Joined: 11 Mar 2016
Posts: 231

PostPosted: Thu Aug 11, 2016 9:01 pm    Post subject: help me to add if statment to the code Reply with quote

I have 0 experience in LUA help me to add the 2nd code to its without errors please

Code:
{$lua}
[ENABLE]
myrecord = getAddressList().getMemoryRecordByDescription("whatever")
if mytimer == nil then
  mytimer = createTimer(nil, false)
end
mytimer.Interval = 10
mytimer.OnTimer = function(timer)
  myrecord.Active = not myrecord.Active
end
mytimer.Enabled = true
[DISABLE]
mytimer.Enabled = false


_____________________________




Code:
 if myrecord.Active then
    myrecord.Active = false
    mytimer.Interval = 1000
  else
    myrecord.Active = true
    mytimer.Interval = 10
  end



Quote:
Zanzer say

No, you definitely wouldn't call sleep at all.
You'd use the timer itself to handle both enable/disable of the secondary script.
If you want different intervals, you can change them within the function too.


I want to merge both codes → to add different intervals,
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Thu Aug 11, 2016 9:26 pm    Post subject: This post has 1 review(s) Reply with quote

Code:
{$lua}
[ENABLE]
myrecord = getAddressList().getMemoryRecordByDescription("whatever")
if mytimer == nil then
  mytimer = createTimer(nil, false)
end
mytimer.Interval = 10
mytimer.OnTimer = function(timer)
 if myrecord.Active then
    myrecord.Active = false
    mytimer.Interval = 1000
  else
    myrecord.Active = true
    mytimer.Interval = 10
  end
end
mytimer.Enabled = true
[DISABLE]
mytimer.Enabled = false
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