Reducing and incresing a timer.
Alto123
10 Sept 2016, 12:20I have a situation where I want to make a main objective timer that can be stopped, but that isn't the issue. Idealy I'd like to make it so a player can do 'x' command and it will delay the timer by 20 seconds (giving them more time to figure out the puzzle), but if they try to do 'y' action it will decrease by 20 seconds. I tried that with 'Set timer to expression -20, but that didn't seem to work. Anyone got an idea how to do this?
hegemonkhan
10 Sept 2016, 19:35for the delaying, one way would be, (I think), having another Timer, which does this:
// this is based upon being able to restart your puzzle's timer without any issues/problems in doing so
// also, this will effectively give you: 20 + puzzle's timer's (full: 0 time elapsed) interval, and not 20 + (puzzle's timer's full interval - X time elapsed)
<command name="delay_command">
<pattern>delay</pattern>
<script>
DisableTimer (puzzle_timer)
EnableTimer (delay_timer)
</script>
</command>
// not sure on the syntax for a Timer's Attributes:
<timer name="delay_timer">
<interval>20</interval>
<script>
EnableTimer (puzzle_timer)
DisableTimer (delay_timer)
</script>
</timer>
alternatively... you should be able to change the puzzle timer's interval... just have it be 20 less than the (normal) interval, though I'm not sure how'd this effect it, if/when done while it's running... maybe it'd be better to disable the puzzle Timer and enable a 'puzzle timer 2' with the lesser/reduced interval, instead
as for shortening the interval... The only way I can think of doing this in a way that hopefully would work, is to just disable the puzzle timer and enable another puzzle timer with the shortened interval time (puzzle timer's full interval time - 20), similar to my design in the code box above.

onimike
10 Sept 2016, 20:29Also you could (if using offline editor) make an attribute in the player call it (IDK) then you could decrease or increase this attribute depending on certain situations, we can the use run script after a number of seconds.
So it would kinda look like this
If (IDK = X);
run script after (10)seconds;
(Do somthing);
else if (IDK = Z);
run script after (20) seconds;
(Do something);
This isn't actual code lol so this won't work but the principle is the same. Now you can go on and on with else if depending on how many situations you want to change you just change the attribute value.
Hope it helps!
Mike
The Pixie
10 Sept 2016, 20:33Be aware that timers can be a little flaky
I would set up a timer that fires every five seconds, and when it does it decrements a counter on the game object by 1. If you want to reduce the time by 20 seconds, subtract 4 from the counter. If you want to delay it, add 4 to it. When the counter gets to zero or less, the thng happens.