increment every second
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 2
- Joined: Mon Nov 17, 2014 12:58 pm
increment every second
I am designing a game and need to increment a variable every second without preventing the user doing other things. is there any way to do this while avoiding an infinite loop, which prevents the user doing anything else?
Re: increment every second
Hi batsby,
Check out the following stackOverFlow post which should help you with this-
http://stackoverflow.com/questions/2222 ... a-livecode
Kind Regards,
Neil Roger
--
LiveCode Support Team ~ http://www.livecode.com
--
Check out the following stackOverFlow post which should help you with this-
http://stackoverflow.com/questions/2222 ... a-livecode
Kind Regards,
Neil Roger
--
LiveCode Support Team ~ http://www.livecode.com
--
-
- Posts: 2
- Joined: Mon Nov 17, 2014 12:58 pm
Re: increment every second
Thanks, that seems to have stoped the crashing. 

Re: increment every second
Neil, I take this back.
I was wrong, thought too much of a timer with a parameter. Sorry for that. This was now more a "youth sin" of me ...
The only thing that remains is, that this is actually counts down to one, because the timer stops at the beginning of zero( .., two, one, "go"). But most people wish to have it like that.
Hermann
I was wrong, thought too much of a timer with a parameter. Sorry for that. This was now more a "youth sin" of me ...
The only thing that remains is, that this is actually counts down to one, because the timer stops at the beginning of zero( .., two, one, "go"). But most people wish to have it like that.
Hermann
Last edited by [-hh] on Wed Nov 19, 2014 6:56 pm, edited 2 times in total.
shiftLock happens
Re: increment every second
Hi hh,
The link provides the information the original poster requested so it should be ok to keep
In regards to the counter, would changing the following resolve the issue you are describing-
The link provides the information the original poster requested so it should be ok to keep

In regards to the counter, would changing the following resolve the issue you are describing-
Code: Select all
on mouseUp
if the label of me is "start" then
set the label of me to "reset"
put true into sTimerRunning
put 59 into field "counter"
put 59 into sGameSeconds
send "timerRun" to me in 1 second
else
set the label of me to "start"
put false into sTimerRunning
put 60 into field "counter"
end if
end mouseUp
on timerFinished
answer "Time Up!"
put "60" into field "counter"
end timerFinished
Re: increment every second
There were several threads on this last year, though in this case it sounds like the one-second timer is not, er, time critical.
That thread spoke about using the system clock instead of "sending in time" for greater accuracy. It was called "Accurate timer". Just something to think about.
Craig Newman
That thread spoke about using the system clock instead of "sending in time" for greater accuracy. It was called "Accurate timer". Just something to think about.
Craig Newman