Most of the time, the normal game clock you can change in the map options is good enough. However, it does not let change interact with it during a game. This guide will teach you how to make your own clock that you can add to the UI.
- First you are going to want to make a timer out of counter devices.
Start by making a counter with a starting value of 59, and a repeater decreasing its value every second. This will track seconds.
Then make it have a target value of -1 and have it transmit a signal when it reaches it. This signal will be used to decrement a second timer that will track minutes.
Add another counter and decrement it when it receives the signal. You can set this counters starting value to however long you want it to be.
Give this a target value of -1 as well and you can make it send a signal when it reaches it if you want it to do something like end the game.
- Now you need to set up the properties.
Add two property devices. Make one of them named second. Set the property type to number and make the value 59
Make the other property called minute and make the value whatever you made the counter.
- Put it on the UI.
Go back to the repeater and make it send a signal when a task occurs.
Place down a game overlay device, go to the blocks, and make a new one that runs when it receives the signal from the repeater.
In the blocks menu, get an “if” block and click the setting to add an “else” to the bottom of it.
Then, get the “___ = ___” block in the logic section and set it to greater than or equal to. On one side, put the property for seconds and on the other side put the number 10. Put the whole thing at the top of the “if” block.
Now get a “set text” block and add a “create text with” block to it. On one side, put the property for minutes.
On the other side, put another “create text with” block and add text block with “:” in it and the property for seconds.
Then, copy the entire thing and and add a 0 to the text block. It should say “:0”
Add the first one to the top and and second one to the “else” spot. This is the final product.
You should now have a working custom timer on the on Ui! Enjoy!