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 only fires once

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

Joined: 29 Jul 2015
Posts: 11

PostPosted: Wed Jul 29, 2015 6:53 pm    Post subject: Timer only fires once Reply with quote

Hello! I'm completely new to CheatEngine (been an ArtMoney user for many, many years), and I absolutely LOVE the idea of the scripting engine and it's the first thing I started playing around with once I transferred over some ArtMoney values.

Anyway, introductions out of the way, I have a form which I want to use to display the character velocity in a textbox. I want it to be updated every few milliseconds, so I added a Timer from the form creator to the form. Enabled is set to true, and I have an OnTimer event assigned. The only problem is, it fires exactly once, and never again.

Is there some specific way I need to run the form, or is my timer somehow being garbage collected?
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 Jul 30, 2015 3:19 am    Post subject: Reply with quote

when designing/testing the form make sure you first execute the lua script else the old function will be called instead

also, what does your onTimer do? Destroy sender/timer? Change the interval?

_________________
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
Jesuszilla
Newbie cheater
Reputation: 0

Joined: 29 Jul 2015
Posts: 11

PostPosted: Thu Jul 30, 2015 12:37 pm    Post subject: Reply with quote

How do I make sure the LUA script executes before the form?

Also the timer calls a method that updates the text in two Edit boxes. ReadOnly is set to false, so it should update (and indeed does, the first time).
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 Jul 30, 2015 1:29 pm    Post subject: Reply with quote

you can just click on execute in the lua script window before you start testing things

Instead of editing a editbox try the print command to verify that the timer only runs once. (it could just as well be that the code to set the editbox doesn't work a second time for some weird reason, like focused, or you have an if that checks if it's empty, etc...)

_________________
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
Jesuszilla
Newbie cheater
Reputation: 0

Joined: 29 Jul 2015
Posts: 11

PostPosted: Thu Jul 30, 2015 8:32 pm    Post subject: Reply with quote

Thanks for the help! I found the problem― my function wasn't set up correctly. I should have had "sender" as a parameter to my update_velocities function that the timer was calling.

Though now I can't get the timer to stop when I click the button again. My function for start_timer() is as follows:

Code:
function start_timer(sender)
   if timer_getEnabled(velocityTimer) == false then
       timer_setEnabled(velocityTimer,true)
   else
       timer_setEnabled(velocityTimer,false)
   end
end


This starts the timer, yet it does not stop it.

Also, I may be getting ahead of myself here, but speaking of "sender," is it possible to get a set of objects from the sender parameter?
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: Fri Jul 31, 2015 3:50 am    Post subject: Reply with quote

try
Code:
 
velocityTimer.Enabled=not velocityTimer.Enabled



and you don't have another timer running? (e.g. if you create a timer with code instead of forms, you'll have to destroy it yourself)

not sure what you mean with "a set of objects" but closest thing i can come up with is use a table with a set of objects, use createRef to get in integer reference to that table, assign it to the Tag property, and then in the functioncall use getRef with Sender.Tag to get the table containg the objects

_________________
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
Jesuszilla
Newbie cheater
Reputation: 0

Joined: 29 Jul 2015
Posts: 11

PostPosted: Sun Aug 02, 2015 4:27 pm    Post subject: Reply with quote

Works now! I guess the form was out of sync with the LUA script.

I'm getting the hang of this pretty quickly! Once again, this is an AWESOME tool, thanks!
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