1
Timersalarm_add
I am making a custom data pack for me and my friends. I know how to make a timer, but I don't know how to display the timer or make it so that the timer can be delayed (by one second) by running a command. If anyone could help, that would be great! Thanks!
5
Lets say we have a scoreboard timer called "timer".
Chat command:
Clock Commands:
Now that we have the above scoreboard timer, we can easily display it by typing a single command into chat:
And that's it! There are many other ways to do it, but this one is by far the simplest. It is also possible to display it above the hotbar, in the bossbar, or if you're willing to invest time into making a resource pack, have it display pretty much anywhere you want on your screen. If you want to use one of the other methods I have mentioned, let me know and I'll try to provide a solution for that(Note that the last one is more complicated and I have less experience with it, but I will still try).
EDIT: In regards to delaying the timer by one second, that can be done by doing the following:
Note that 20 minecraft ticks is equivalent to 1 second, which is why we are removing that amount.
Hope this helps! :)
Chat command:
/scoreboard objectives add Timer dummyClock Commands:
execute if score Ticks Timer matches 100.. run scoreboard players reset Ticks Timerscoreboard players add Ticks Timer 1Now that we have the above scoreboard timer, we can easily display it by typing a single command into chat:
/scoreboard objectives setdisplay sidebar TimerAnd that's it! There are many other ways to do it, but this one is by far the simplest. It is also possible to display it above the hotbar, in the bossbar, or if you're willing to invest time into making a resource pack, have it display pretty much anywhere you want on your screen. If you want to use one of the other methods I have mentioned, let me know and I'll try to provide a solution for that(Note that the last one is more complicated and I have less experience with it, but I will still try).
EDIT: In regards to delaying the timer by one second, that can be done by doing the following:
/scoreboard players remove Ticks Timer 20Note that 20 minecraft ticks is equivalent to 1 second, which is why we are removing that amount.
Hope this helps! :)
Sorry to bother again, but how do i pause it when the person logs off
Assuming the cmd block is in spawn chunks (around 0,y,0) if you are using it, and you're waiting for the last player to log off, use
execute if entity @a run scoreboard players add Ticks Timer 1Also do I have to use function for a custom command or are there any alternatives that make completely new commands, like /time instead of /function time
Unfortunately, custom commands are not a thing for datapacks. With that said, /function is not your only option as there is also /trigger, which is a much more user friendly way of doing things. /trigger is a command ANY player can run(not just OP'd players!). As such, /trigger is useful for the players who are not OP'd, and /function is useful for those who are.
A quick demonstration on how /trigger works. We will start with making a trigger objective called "Interact":
Next, we will put the following command in a clock to enable it every tick for every player. If we don't do this, then non-OP'd players won't be able to use the trigger command like we want!
Finally, non-OP'd players can run the following to set the score to whatever they want! :)
Note that # can be replaced with any number.
Hope this helps! :)
A quick demonstration on how /trigger works. We will start with making a trigger objective called "Interact":
/scoreboard objectives add Interact triggerNext, we will put the following command in a clock to enable it every tick for every player. If we don't do this, then non-OP'd players won't be able to use the trigger command like we want!
/scoreboard players enable @a InteractFinally, non-OP'd players can run the following to set the score to whatever they want! :)
/trigger Interact set #Note that # can be replaced with any number.
Hope this helps! :)
