#the schedule command does not work

1 messages · Page 1 of 1 (latest)

lapis cedar
#

As the arrow is shot from a bow, I am trying to schedule a function to run 1s after the arrow is detected. This does not work though

feral pathBOT
#

<@&1201956957406109788>

Someone will come and help soon!

💬 While you wait, take this time to provide more context and details.

🙇 If nobody has answered you by <t:1750542355:t>, feel free to use the Summon Helpers button to ping our helper team.

✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve

winter tapir
#

it does workl but not how you think it does

#

scheduled functions alway run as the server and at world spawn.

#

to make your code work, you have to mark your arrow and run the function as the marked entity with target selectors

#

an easy way is to store the result of a scheuled function in the score of the arrow and once the function runs, check the current time, store it in a score and compare it to existing entities, The entity that you stored the schedule scorte in will have the exact same value than the current time that it is when the schedule runs.

lapis cedar
#

k, i understand but i have no clue howw to do any of that im a beginner.

#

is there anything like schedule?

#

i just needed a way to have a 'wait' command

winter tapir
#

what I just said

lapis cedar
#

k

winter tapir
#

it's really simple

lapis cedar
#

im dumb lmao, ill try my best but ty

winter tapir
#

first, you store the result of the schedule in the entity execute store result score <your entity> schedule_time run schedule <your function> append

bright sequoiaBOT
#

To check the time you can use a simple time check prediocate

execute as @e[type=arrow,<additional checks if necessary>] if predicate {condition:"minecraft:time_check",value:{min:{type:"minecraft:score",target:"this",score:"schedule_time"},max:{type:"minecraft:score",target:"this",score:"schedule_time"}}} run <your delayed function>
winter tapir
#

make sure to use your own score instead of schedule_time

winter tapir
#

in this case it comparse the current time against a range (the range being the stored score of the entity both for max and min)

#

if they match it runs the command

#

If you already know it's an arrow, add that as a type check like I did. It saves perfromance as the command doesn't have to search every entity if they are the correct one but only arrows.

lapis cedar
#

and all of this goes in tick.mcfunction?

winter tapir
#

hell no

lapis cedar
#

load?

#

or in the function i created alr

winter tapir
#

Whatever triggers the function to be scheduled needs to do the scheduling with the store command and the rest happens in the scheduled function

lapis cedar
#

sorry if itys a dumb question im just new to creating data packs

winter tapir
#

and everything else in that called function

winter tapir
lapis cedar
winter tapir
#

from what I see, you schedule the function every tick rn. This is not good.

#

What should trigger this?

lapis cedar
#

what i want to trigger the schedule is whenever the bow gets shot. That command is in the tick function

winter tapir
#

don't do that.

#

We can use advancements and other methods to detect that.

lapis cedar
#

oh

winter tapir
#

or at least we use conditions in the tick function

lapis cedar
#

what other methods are there that will work the same way

winter tapir
#

ok, I had th ewrong advancement in mind. It only works for crossbows. But we can use a statistic that keeps track of shot crossbows in a scoreboadr and check that.

lapis cedar
#

im using a bow

#

but it will also work with a bow

winter tapir
#

For the bow we need the statistic

#

I need to ckeck what it was called

#

scoreboard objectives add a minecraft.used:minecraft.bow

#

this needs to go in the load function

#

a is just a placeholder, you can name it whatever you want

#

every time you use a bow it will go up by 1.

#

in the tick function we can detect that and run commands based on that.

lapis cedar
#

i figured there would be a scoreboard obj for it

bright sequoiaBOT
#
execute @a[scoes={a=1..}] as @e[type=arrow,<additional checks>] unless score @s schedule_time 1.. store result score @s schedule_time run schedule <delayed function> <time> append
winter tapir
#

it looks a bit wild

lapis cedar
#

cant i just reset the score to 0 after the function and then just check if the scoreboard 'a' = 1

winter tapir
#

It looks so wild I even forgoit parts and made mistakes, give me a second

bright sequoiaBOT
#
execute @a[scores={a=1..}] as @e[type=arrow,<additional checks>] unless score @s schedule_time 1.. run function namespace:scheduler_function

scheduler_function

scoreboard players reset @a a
execute store result score @s schedule_time run schedule <delayed function> <time> append
lapis cedar
#

wow this is alot so far, i gtg for now and ill try to when i get back tyy!

winter tapir
#

Yeah, it's not that simple to delay a function like saying "run in n seconds" but that's often with commands, seemingly simple stuff can be quite the undertaking but seemingly complex stuff can be done in 1 command.

lapis cedar
#

ive tried to see what might be the problem but at this point its getting confusing for me

#

is the 'schedule_time' defined or is it a built in thing or smth

winter tapir
#

you have to define that in te load fuction (as dummy)

lapis cedar
#

im not to sure

winter tapir
#

yes

lapis cedar
#

i reset my scoreboard for 'a' ingame

#

and when its 1, the function doesnt run

feral pathBOT
#
Closed for inactivity

This question has been inactive for some time, so it's going to be closed for inactivity. If you still need it, please disregard this message.

feral pathBOT
#
Closed for inactivity

This question has been inactive for some time, so it's going to be closed for inactivity. If you still need it, please disregard this message.

feral pathBOT
#
Closed for inactivity

This question has been inactive for some time, so it's going to be closed for inactivity. If you still need it, please disregard this message.