1

Timersalarm_add

FluffyPancakes1 10/19/21 10:17 am
178
10/23/2021 5:01 pm
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!
Posted by
FluffyPancakes1
Level 1 : New Miner
0

  Have something to say?

JoinSign in

5

SUPERIONtheKnight
10/19/2021 1:36 pm
Level 30 : Artisan System
history
Lets say we have a scoreboard timer called "timer".
Chat command:
/scoreboard objectives add Timer dummy
Clock Commands:
execute if score Ticks Timer matches 100.. run scoreboard players reset Ticks Timer
scoreboard players add Ticks Timer 1
Now that we have the above scoreboard timer, we can easily display it by typing a single command into chat:
/scoreboard objectives setdisplay sidebar Timer
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:
/scoreboard players remove Ticks Timer 20
Note that 20 minecraft ticks is equivalent to 1 second, which is why we are removing that amount.

Hope this helps! :)
2
FluffyPancakes1
10/23/2021 9:22 am
Level 1 : New Miner
Sorry to bother again, but how do i pause it when the person logs off
1
HoboMaggot
10/23/2021 5:01 pm
Level 55 : Grandmaster Blob
history
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 1
2
FluffyPancakes1
10/19/2021 10:20 am
Level 1 : New Miner
Also 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
1
SUPERIONtheKnight
10/19/2021 1:55 pm
Level 30 : Artisan System
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":
/scoreboard objectives add Interact trigger
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!
/scoreboard players enable @a Interact
Finally, 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! :)
1

Welcome