#Schedule function | I don't know why it's not working (I also don't know what I'm doing)

1 messages · Page 1 of 1 (latest)

modern sundial
#

So I'm trying to make a datapck (my first real one), but for now I'm trying to have the logic in place and I don't understand why it's not working.

The intended functionnement is this :
the load function creates a scoreboard to know when tick function should work (working)
the borderlaunch function changes the scoreboard so the condition is fullfilled (working)
the tick function calls the borderdelayer function (if the condition is met) (working)
said function should call every five seconds the border function wich will do the things. (not working)

Actual functionnement is this:
the load function andborderlaunch function both work as intended
the tick function's condition works (tested)
the border function is called when /reload - ing
the borderdelayer function seems not to work

The zip file with the entire datapack is with this post.

merry dagger
#

I think your problem is, that you call the schedule for in 5 seconds every single tick

#

so you overwrite the scheduled function

#

and it might run when you reload because the game lags? just a wild guess

modern sundial
#

i don't know i just want a timer but i can't comprehend schedule

merry dagger
#

to fix it you could add the condition with the schedule command (if score #border launched matches 1 run schedule nomadmode:borderdelayer 5s) to borderdelayer, you'd also probably need to use a different condition to start the checks and reset the condition once you start the schedule

merry dagger
#

that just counts up every tick

#

and calls a function and resets once it hits a certain amount of ticks

modern sundial
merry dagger
#

sorry, i thorugh you were scheduling the borderdelayer function there

#

your problem rn is, you overwrite the schedule every tick and even if you wouldn't overwrite it every tick the function would run every tick (since you schedule it every tick)

modern sundial
#

and if i do schedule replace

merry dagger
#

what you want is, that the function that runs after 5 seconds, schedules itself to run after additional 5 seconds

merry dagger
modern sundial
#

i have schedule append rn because it needs either of them

merry dagger
#

the idea

### function nomad:start
execute if <condition> run function nomad:schedule
### function nomad:schedule
execute if <condition> run schedule function nomad:schedule 5s
...
# all the stuff
# that you want
# to do every 5
# seconds
...
#

that way you start the schedule loop with the starting function

#

and it keeps running as long as the condition is fulfilled

#

you don't need a tick function, it will become it's own tick function, it just ticks after 5 seconds

modern sundial
#

ok but then I need all my functions to have the condition

#

in nomad:schedule

merry dagger
#

no

#

you can also call the function only if said condition is fullfilled in the first place

modern sundial
#

yeah ok

merry dagger
#

I assumed that that function is the condition in the first place

#

fixed my message then

modern sundial
#

i mean the condition is just so that the player can start it whenever
so ig i don't even need a condition

merry dagger
#

you might want one to stop the schedule, but yea it's not required

modern sundial
#

all datapacks running data are saved when exiting the world right

merry dagger
#

do you mean the scheduled functions?

#

not sure actually but I'd assume so

modern sundial
#

ok i'll try

#

I think i was indeed replaceing the cooldown now that i tested it

#

bruh it works with 3 total lines of code

merry dagger
#

:D

daring walrus
#

resolved?

modern sundial
#

ye