#how to execute commands with one second delay with gametest?
33 messages · Page 1 of 1 (latest)
could you give me an example?
can u use TickEvent?
yes but I do not know how.
I guess you could just count to 20?
Did they ever add a better interface to delayed executions?
My overcomplicated solution.
We know that minecraft runs things at 20 ticks a second.
So if we run a command every tick that adds a score to the player and reset it at 20
We can detect when one second has passed.
Like this.
/title @p[scores={tick=20..}] title one second has passed
we have in th3 beta this
? script tick awaition
since 1.19.50, we recieved two new methods that can be used for delayed function execution
// like setTimeout
system.run( func, tickDelay )
// like setInterval
system.runSchedule( func, tickDelay )
// like clearTimeout
system.clearRun( timeout )
// like clearInterval
system.cleatRunSchedule( interval )
Example
const TICKS_IN_SEC = 20
const run = system.run( () => {
console.warn( "timeout" )
}, TICKS_IN_SEC )
const runSchedule = system.runSchedule( () => {
console.warn( "interval" )
}, TICKS_IN_SEC )
system.clearRun( run )
system.cleatRunSchedule( runSchedule )
subscribe tick event count to 20 execute ur code and unsubscribe thick event
wait si this work on stable?
oh so delay is available and runSchedule?
Just system.run atm
thx for answer
bruh
That might've been a 1.19.50 thing