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 


Checkbox timer(?)

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

Joined: 20 Aug 2016
Posts: 44

PostPosted: Tue Jan 24, 2017 2:34 pm    Post subject: Checkbox timer(?) Reply with quote

It's possible to make a timer stop when a checkbox is active?
I've been trying for a couple of days and I can't make it work, the timer it's always active.

Code:
tmer.OnTimer = function(tmer)
local value=readFloat("[[[[HelloNeighborReborn-Win64-Shipping.exe+02650AC0]+358]+0]+E8]+140")
control_setCaption(CETrainer2_ZAxis, value)
local value=readFloat("[[[[[HelloNeighborReborn-Win64-Shipping.exe+02650AC0]+70]+160]+F0]+0]+144")
control_setCaption(CETrainer2_XAxis, value)
local value=readFloat("[[[[[HelloNeighborReborn-Win64-Shipping.exe+02650AC0]+7B8]+20]+70]+3E0]+148")
control_setCaption(CETrainer2_YAxis, value)
end

tmer = createTimer(nil, false)
tmer.OnTimer = function(tmer)
  if checkbox_getState(EditAxis)== 0 then
    tmer.Enabled = false
  else
    tmer.Interval = 100
    tmer.Enabled = true
  end
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: Tue Jan 24, 2017 3:41 pm    Post subject: Reply with quote

Code:

othertmer = createTimer(nil, false)
othertmer.OnTimer = function(t)
  if EditAxis.Checked then
    tmer.Enabled = false
  else
    tmer.Interval = 100
    tmer.Enabled = true
  end
end


or just
Code:

tmer.OnTimer = function(tmer)
  if not EditAxis.Checked then
    CETrainer2.ZAxis.Caption=readFloat("[[[[HelloNeighborReborn-Win64-Shipping.exe+02650AC0]+358]+0]+E8]+140")

    CETrainer2.XAxis.Caption=readFloat("[[[[[HelloNeighborReborn-Win64-Shipping.exe+02650AC0]+70]+160]+F0]+0]+144")

    CETrainer2.YAxis.Caption=readFloat("[[[[[HelloNeighborReborn-Win64-Shipping.exe+02650AC0]+7B8]+20]+70]+3E0]+148")
  end
end

tmer.Interval = 100
tmer.Enabled = true

_________________
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
Greenhouse
Cheater
Reputation: 0

Joined: 20 Aug 2016
Posts: 44

PostPosted: Tue Jan 24, 2017 3:49 pm    Post subject: Reply with quote

It just gives me an error, the same happened with my code:
Code:
Error:[string "function FormKeyPress(sender, key)
..."]:200: attempt to index a nil value (global 'EditAxis')

Line 200 is:
Code:
if not EditAxis.Checked then

By the way. The EditAxis checkbox is in another form. Not in the main one.
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: Tue Jan 24, 2017 3:51 pm    Post subject: Reply with quote

then do formname.EditAxis.Checked
_________________
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
Greenhouse
Cheater
Reputation: 0

Joined: 20 Aug 2016
Posts: 44

PostPosted: Tue Jan 24, 2017 3:56 pm    Post subject: Reply with quote

But the timer is still enabled. It makes no sense...
I can send you the .CT in a private message If you want to see the entire code,etc.
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Tue Jan 24, 2017 5:11 pm    Post subject: Reply with quote

Be aware that every time you click execute, it is creating a new timer while the old one continues running.
Try closing and opening your trainer again. Prevent it from creating multiple timers:
Code:
if tmer == nil then
  tmer = createTimer(nil, false)
end
Back to top
View user's profile Send private message
Greenhouse
Cheater
Reputation: 0

Joined: 20 Aug 2016
Posts: 44

PostPosted: Tue Jan 24, 2017 5:18 pm    Post subject: Reply with quote

Zanzer wrote:
Be aware that every time you click execute, it is creating a new timer while the old one continues running.
Try closing and opening your trainer again. Prevent it from creating multiple timers:
Code:
if tmer == nil then
  tmer = createTimer(nil, false)
end

Now it just doesn't change. My script is fucked up.
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Tue Jan 24, 2017 5:24 pm    Post subject: Reply with quote

You can attach your table to your post.
Back to top
View user's profile Send private message
Greenhouse
Cheater
Reputation: 0

Joined: 20 Aug 2016
Posts: 44

PostPosted: Tue Jan 24, 2017 5:38 pm    Post subject: Reply with quote

I'll PM you the table.
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Tue Jan 24, 2017 5:59 pm    Post subject: This post has 1 review(s) Reply with quote

Textboxes have the .Text property.
Code:
if tmer == nil then
  tmer = createTimer(nil, false)
end

tmer.OnTimer = function(tmer)
  CETrainer2.ZAxis.Text=readFloat("[[[[HelloNeighborReborn-Win64-Shipping.exe+02650AC0]+358]+0]+E8]+140")
  CETrainer2.XAxis.Text=readFloat("[[[[[HelloNeighborReborn-Win64-Shipping.exe+02650AC0]+70]+160]+F0]+0]+144")
  CETrainer2.YAxis.Text=readFloat("[[[[[HelloNeighborReborn-Win64-Shipping.exe+02650AC0]+7B8]+20]+70]+3E0]+148")
end

tmer.Interval = 100
tmer.Enabled = true

function EditAxisClick(sender)
  if sender.Checked then
    tmer.Enabled = false
  else
    tmer.Enabled = true
  end
end
Back to top
View user's profile Send private message
Greenhouse
Cheater
Reputation: 0

Joined: 20 Aug 2016
Posts: 44

PostPosted: Tue Jan 24, 2017 7:15 pm    Post subject: Reply with quote

Now it works. Thank you soo much!
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