0

Is there a way to give a command, such as /say or /tellraw a time delay?

For example I want my command to say something after ten seconds, but I don't really want a bunch of repeaters everywhere. Is there a way to do this with command blocks or alternative methods?

  • I edited your question to make it slightly broader to make it more helpful for other people by "demoting" /say and /tellraw to examples. These commands don't have any special delay functionality, so the answers will apply to all commands anyway. – MrLemon Feb 12 '16 at 9:51
  • That said: Good first question, and welcome to the site. Be sure to check out the tour if you haven't already. – MrLemon Feb 12 '16 at 9:52
1

You can use scoreboard values and dummy variables.

Example

Setup:

/scoreboard objectives add Timer dummy

Run every tick for each individual command:

/scoreboard players remove cmd1 Timer 1
/scoreboard players test cmd1 Timer 0 0
v comparator(before 1.9) or conditional (after 1.9) v
/your_command_here

Run to start delay:

/scoreboard players set cmd1 delay_in_20ths_of_a_second

As you can see, this is scalable for as many commands as you need.

  • I haven't downloaded the newest snapshot, but at least i will know how to do it when 1.9 comes around. – Jason_ Feb 14 '16 at 3:23
  • If you aren't using 1.9, you can use a comparator to regular command block in place of the condintional. That's why it says comparator or condititonal(1.9). Sorry if i was overly vague. – rustphoenix Feb 15 '16 at 16:36
  • You should avoid using the * wildcard where possible. It's an expensive operation that should not be used on a clock, as it has to cycle through every single playerscore stored on the scoreboard (and not only those specified in the objective). As well, using it to modify a score rather than reset will bloat the scoreboard because now every single player tracked has a new score in "Timer". It should only be used for one-time situations, such as at the end of a minigame. – Skylinerw Feb 15 '16 at 19:52
  • @Skylinerw Oh, didn't think about that. Edited the answer so it's less resource intensive. Thanks for the help! – rustphoenix Feb 15 '16 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.