Changing the time span of an alarm? [SOLVED]
#1
Posted 12 July 2012 - 04:32 AM
#2
Posted 12 July 2012 - 04:45 AM
So in the click event of the egg have set alarm
SETTINGS:
That's it
Edited by GMKn00b, 12 July 2012 - 04:47 AM.
#3
Posted 12 July 2012 - 04:45 AM
alarm[0] = 600, or something make the 600 (or whatever it is) a variable. Such as
alarm[0]=hatchtimeand you can just set the default hatchtime, and reduce the hatchtime when the player warms the egg
#4
Posted 12 July 2012 - 05:40 AM
So, let me get this right, is the alarm already started with the default time when the egg instance is created, and then start alarm again with a value of of -30 and making it relative under the click event?DO set alarm
![]()
So in the click event of the egg have set alarm
SETTINGS:Spoiler
That's it
Instead of having the
alarm[0] = 600, or something make the 600 (or whatever it is) a variable. Such asalarm[0]=hatchtimeand you can just set the default hatchtime, and reduce the hatchtime when the player warms the egg
wouldnt this just start the alarm back over at the difference between the original hatchtime and the amount of reduction, rather than the difference between the CURRENT time and the reduction amount. But I might be wrong, please tell me.
Thanks to both of you for speedy answers!
#5
Posted 12 July 2012 - 06:00 AM
alarm[0]=max(alarm[0]-30,1)
#6
Posted 12 July 2012 - 06:54 AM
You can treat alarms just like any other variable. If the player is warming the egg, subtract a number such as 30 from the alarm and it will decrease the time. The only thing you need to make sure of is that the alarm does not drop below 1, or it won't go off.
alarm[0]=max(alarm[0]-30,1)
Okay thank you for the explanation. I did a test run and put the default hatching time to 300 for the alarm (or about 10 seconds) upon creation. I then used the code that you gave me on the click event. When i run the game, it correctly hatches after about 10 seconds, but after running the game again and immediately clicking the egg only twice, it hatches prematurely and almost immediately after clicking rather than shaving the supposed 2 seconds off of the 10 second time. Could someone please explain why?
#7
Posted 12 July 2012 - 08:38 AM
#8
Posted 12 July 2012 - 09:50 AM
It doesn't start again with -30, because you ticked the relative boxSo, let me get this right, is the alarm already started with the default time when the egg instance is created, and then start alarm again with a value of of -30 and making it relative under the click event?
That's what it does, if you tick it it adds it instead of setting it to -30.
It's relative to the Alarm that you picked not the click event(sorry for the confusion)
So the method above should work
EDIT: Let's just say relative simply means adding it to the current value
Edited by GMKn00b, 12 July 2012 - 10:19 AM.
#9
Posted 12 July 2012 - 02:53 PM
you probably used the wrong mouse event. you need to use local left button PRESSED(or released, not just held as it will run multiple time if you use that one, and use global if you just want to click anywhere on the screen not just the object the code is in)
It doesn't start again with -30, because you ticked the relative box
So, let me get this right, is the alarm already started with the default time when the egg instance is created, and then start alarm again with a value of of -30 and making it relative under the click event?![]()
That's what it does, if you tick it it adds it instead of setting it to -30.Spoiler
It's relative to the Alarm that you picked not the click event(sorry for the confusion)
So the method above should work
EDIT: Let's just say relative simply means adding it to the current value
Thank you so much for the help. It works!
Edited by bowlda, 12 July 2012 - 02:53 PM.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











