#Delay between commands in a commandchain in a script

1 messages · Page 1 of 1 (latest)

mighty talon
#

How to run a chain of commands every 10 minutes (Each command should have a delay of 1 second to the next command)?

mighty talon
#
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

trim wave
#
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

mighty talon
trim wave
#
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

mighty talon
trim wave
#

idk

mighty talon
#

If I want to send a message that everyone could see, would js q1.sendMessage(`Hello`) work?

trim wave
#

give me an error

#

for the first one

mighty talon
trim wave
#

alright, good for you

trim wave
frigid tree
#

foreach triggers it at once

trim wave
#

the second script became kinda useless since you no longer use a command. xd

mighty talon
#

c:

#

I'm using the first one now

mighty talon
trim wave
#

Because you need to specify which dimension first before you can use runCommand()