View previous topic :: View next topic |
Author |
Message |
bknight2602 Grandmaster Cheater Reputation: 0
Joined: 08 Oct 2012 Posts: 577
|
Posted: Thu Sep 12, 2013 8:47 pm Post subject: Timer enable question |
|
|
I had a bit of code at the end of all the code lines immediately preceding a form_show(CheatPanel) command:
Code: |
tSave = createTimer(nil, true)
timer_onTimer(tSave, SaveAnywhere)
timer_setInterval(tSave, 500)--checks every 500 milliseconds
timer_setEnabled(tSave, true)
print("The save timer is enabled")
function SaveAnywhere(sender)
addresslist = getAddressList()
saveanywhereaddress = addresslist_getMemoryRecordByDescription(addresslist, "Save 0 No 128 Yes (Note: Airship may disappear)")
print("The address of the save is = ", saveanywhereaddress)
saveanywhere = memoryrecord_getValue(saveanywhereaddress)
print("The value of the save is = ", saveanywhere)
if tonumber(saveanywhere) ~= 0 then
prevsaveanywhere = tonumber(saveanywhere)
else
memoryrecord_setValue(saveanywhereaddress, prevsaveanywhere)
end
end |
When I opened the CE table nothing happened, except the print statement "The save timer is enabled"??
So I experimented a bit and put
Code: |
tSave = createTimer(nil, true)
timer_onTimer(tSave, SaveAnywhere)
timer_setInterval(tSave, 500)--checks every 500 milliseconds
timer_setEnabled(tSave, true)
print("The save timer is enabled")
| in function FormShow(sender)
When the table was opened the print commands began running non-stop as I expected.
The question why didn't the timer execute in the first bit of code?
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25296 Location: The netherlands
|
Posted: Fri Sep 13, 2013 3:06 am Post subject: |
|
|
when this code is execute the first time:
Code: |
timer_onTimer(tSave, SaveAnywhere)
|
it is equivalent to
Code: |
timer_onTimer(tSave, nil)
|
SaveAnywhere is still nil because it has not yet been declared. That happens after the print
Declare the function above the timer, not below it. (Or use a string as function, ce handles those differently)
_________________
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 |
|
|
bknight2602 Grandmaster Cheater Reputation: 0
Joined: 08 Oct 2012 Posts: 577
|
Posted: Fri Sep 13, 2013 6:40 am Post subject: |
|
|
Dark Byte wrote: | ...Or use a string as function, ce handles those differently) |
Would you give me an example of a string as function, please?
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25296 Location: The netherlands
|
Posted: Fri Sep 13, 2013 7:22 am Post subject: |
|
|
timer_onTimer(tSave, "SaveAnywhere")
_________________
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 |
|
|
bknight2602 Grandmaster Cheater Reputation: 0
Joined: 08 Oct 2012 Posts: 577
|
Posted: Fri Sep 13, 2013 9:59 pm Post subject: |
|
|
Ok I misunderstood your first post as I thought there was another way to code that statement
|
|
Back to top |
|
|
|