How can I restart a non-looping timer? If you create a timer that does not loop, once it expires, it just expires and can never be reset (or so it would seem). I would love it if there were a way to restart the timer from the beginning by calling the Timer Start action (which I assumed would restart the specified timer from the beginning). I am trying to use it because I have an area in my game where a player can walk up to a fishing dock and press E to start fishing (which starts the initial fishing timer countdown of 10 seconds). Once the timer is complete, the player is given a random item (fish, garbage, metal, nothing, etc.). They can then press E again to start the whole process over. '
Could you let me know if I'm trying to use the Timer functionality incorrectly? Could this be done a different way?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Recreated, thanks for the details. I will look into a fix.
You're very welcome. I would also suggest the ability to add/modify the timer action to allow you to change the length of the timer -- or even any of the timer details. The use-case would be creating a sort of multi-purpose action timer. This would open the door to some creative implementations, such as making the timer length a random value between 2 integers (ex., fishing takes 10-15 seconds), as well as being able to recycle a general action timer for other things (fishing, mining, any other kind of action-based things). If this is totally out of the realm of useful for AC in general, please tell me, and I will make something myself and throw it in the wiki. I appreciate everything you do. Thank you.
To fix: open up Timer.cs and replace the two instances of
return;
on lines 199 and 206 with:and
respectively.
On random timers: I'd say it'd best to avoid making such changes at runtime - at least officially - as it'd be easy to break things if you weren't careful.
Things can still be modified through script, however: you can access a Timer with the Variables Manager's GetTimer function.
You can't modify the min/max values, but you can set the current value. If your min/max values were 0 and 15, and the increment per tic was +1, then you could set a Timer to run between 10 and 15 seconds with:
Thanks @ChrisIceBox - This is perfect.
Quick note: you'll need to make Value's setter public (around line 474 in Timer.cs), but I'll make the same amendment in the next release.