#Delay between commands in a commandchain in a script
1 messages · Page 1 of 1 (latest)
import {
world,
system
} from '@minecraft/server';
system.runInterval((q)=> {
q.runCommandAsync(`say hi`)
q.runCommandAsync(`say hello`)
}, 12000)```
I need this, but with a one-second delay between say hi and say hello
Please help me with that ❤️
Delay between commands in a commandchain in a script
import {
world,
system
} from '@minecraft/server';
system.runInterval((q1)=> {
q1.runCommandAsync(`say hi`)
system.runTimeout((q2)=>{
q2.runCommandAsync(`say hello`)
},20) //20 tick delay
}, 12000)```
That's the simplest way btw
Thank you so much <3, I'll try it
function delayCommand(cmd,tick,dimension="overworld") {
system.runTimeout(()=>{
world.getDimension(dimension).runCommand(cmd)},
tick
)
}
system.runInterval(()=>{
const command = [
["/say delay 0 tick",0],
["/say delay 10 tick",10],
["/say delay 3 seconds",60]
]
command.forEach(e=>{
delayCommand(e[0],e[1])
})
},200)
My approach for compact command
But the other one works too, right?
idk
If I want to send a message that everyone could see, would js q1.sendMessage(`Hello`) work?
In the first script is no error
alright, good for you
.
for everyone it's world.sendMessage("string")
for specific player it's
player.sendMessage("string")
foreach triggers it at once
the second script became kinda useless since you no longer use a command. xd
If I want to run a command in the world, should I use q1.runCommandAsync(``)? Because world doesn't exist on runCommandAsync
Because you need to specify which dimension first before you can use runCommand()