[BEHAVIOR] Timer (reworked)

Completed plugins, behaviors and effects.

Post » Tue Nov 20, 2012 10:31 pm

Hi folks,

Just for fun I fiddled with the Timer behavior sources
and as it was broken (couldn't create two different timer on the same behavior), I started to rework it a bit.

So now not only can you create as much timer as you want,
but you also have one new condition:
- timer "timername" is running: true if the timer is currently running
and two new expression:
- count("timerName"): returns the current value of the counter
- initialValue("timerName"): returns the initial value you put in the counter

I'll support this plugin so if you have any bug and/or feature request, feel free to ask (:

Timer.zip
You'll have to overwrite the original plugin to avoid conflict

Just in case there's bugs you can fall back on the original one
Timer_original.zip

Have fun (:Yann2012-11-20 22:32:02
Last edited by Yann on Sun Sep 14, 2014 9:28 pm, edited 2 times in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Tue Nov 20, 2012 11:53 pm

Awesome, thanks Yann =D
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Wed Nov 21, 2012 10:43 am

thanks a lot
B
2
Posts: 8
Reputation: 266

Post » Wed Jan 02, 2013 9:09 pm

A "bit" late but THANKS Yann!!

I was so mad with Timer until realize it was broken and looked for a solution and it's quite recent, I had problems with it long ago, but just now when I tried to use again (forgot that something was wrong) that I decided to search the forum.

Thanks again o/
~Alt+Tab resuming project~
B
3
Posts: 3
Reputation: 331

Post » Wed Jan 02, 2013 9:45 pm

Looks like I can't use the new expressions, the "New Action" window says that "Parameter 1 of (...) does not take 'string'". (nor 'integer')

But the most important for me works: simultaneous timers
B
3
Posts: 3
Reputation: 331

Post » Wed Jan 02, 2013 10:20 pm

@WesleyNR
Hmm weird, expressions works well with me. Maybe you did something wrong with the syntax and maybe I should have provided examples

Anyway, the proper syntax is:
If you created a timer like that[code]Sprite: Start timer "test" with length 10000, Repeat, Don't destroy when finished[/code]
you can get the current count and the initial value this way:[code]Sprite[Timer].count("test")
Sprite[Timer].initialValue("test")[/code]
This way you can even display some percentages like this[code]round((Sprite[Timer].count("test") / Sprite[Timer].initialValue("test")) * 100)[/code]

(Ah I saw a small little mistake, for the initialValue expression it the default is value, it should be name)Yann2013-01-02 22:23:27
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sun Jan 06, 2013 3:05 pm

After some tests, I see that the problem happens when "Sprite" (from the example) is a family instead of an object.

And another thing I noticed is when you "start" a timer with 0ms, the game crashes. Surely no one would need a timer with 0ms, but maybe the lenght is in function of something else and if it becomes zero the crash can happen. We could also test if it's zero and don't try to start, but...
B
3
Posts: 3
Reputation: 331

Post » Mon Jan 07, 2013 8:14 am

@WesleyNR
Thanks for the info, I'll see what I can do about it when I get home (:
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sun Oct 20, 2013 10:20 am

Hi,

I am new Construct2, so I cannot figure out how to add this external Timer plugin to Construct2. Please help me in this.

Thanks.!
B
6
S
3
Posts: 5
Reputation: 946

Post » Sun Oct 20, 2013 1:01 pm

@maxdilbe

See where it says Construct Classic at the top?
Image Image
B
161
S
48
G
90
Posts: 7,354
Reputation: 66,763

Next

Return to Completed addons

Who is online

Users browsing this forum: No registered users and 0 guests