I’m working on a custom map and I’m trying to get some dialogue working by using a repeating function via /schedule that constantly adds 1 to a score, which is read by another function and sends out the dialogue in chat when the score hits certain numbers. This is the timer function:
execute if entity @a[tag=!timer,limit=1] run scoreboard objectives add timer dummy
execute if entity @a[tag=!timer,limit=1] run scoreboard players set @s timer 0
tag @a[tag=!timer] add timer
execute if entity @a[tag=timer,limit=1] run scoreboard players add @s timer 1
The other function schedules the timer function and itself over again using these commands:
execute if entity @a[tag=book,limit=1] run schedule function map:map_intro 1t
execute if entity @a[tag=book,limit=1] run schedule function map:timer 1t
(The “book” tag is given when the player presses another button to receive a hint book they can use throughout the map, and serves as a way to keep the player from starting the map without the book.)
I know that having a function repeatedly execute itself using the /schedule command works because if I set my score to any of the numbers used when a dialogue message is to be sent out, it fills my chat with that message. The issue is that no matter where I put the command that is supposed to increment the score by 1, it is never being executed. I even put that command into the map_intro function (function that has the dialogue) (with some tweaking to make it work) and the result still happens.
My questions is: Why is this not working? Does it have something to do with my command layout, or does Minecraft simply block all attempts to run such a function? If there’s no way to make this work, I can always have it set a redstone block by a repeating command block and remove it when it’s done.
P.S. I have tried things like using 2t instead of 1t and it still has the same result. Also, any command having to do with setting or adding a score in that function doesn’t execute for some reason.
Edit: My command setup is fine, I believe, because if I run the increment command in chat it works.
I’m working on a custom map and I’m trying to get some dialogue working by using a repeating function via /schedule that constantly adds 1 to a score, which is read by another function and sends out the dialogue in chat when the score hits certain numbers. This is the timer function:
execute if entity @a[tag=!timer,limit=1] run scoreboard objectives add timer dummy
execute if entity @a[tag=!timer,limit=1] run scoreboard players set @s timer 0
tag @a[tag=!timer] add timer
execute if entity @a[tag=timer,limit=1] run scoreboard players add @s timer 1
The other function schedules the timer function and itself over again using these commands:
execute if entity @a[tag=book,limit=1] run schedule function map:map_intro 1t
execute if entity @a[tag=book,limit=1] run schedule function map:timer 1t
(The “book” tag is given when the player presses another button to receive a hint book they can use throughout the map, and serves as a way to keep the player from starting the map without the book.)
I know that having a function repeatedly execute itself using the /schedule command works because if I set my score to any of the numbers used when a dialogue message is to be sent out, it fills my chat with that message. The issue is that no matter where I put the command that is supposed to increment the score by 1, it is never being executed. I even put that command into the map_intro function (function that has the dialogue) (with some tweaking to make it work) and the result still happens.
My questions is: Why is this not working? Does it have something to do with my command layout, or does Minecraft simply block all attempts to run such a function? If there’s no way to make this work, I can always have it set a redstone block by a repeating command block and remove it when it’s done.
P.S. I have tried things like using 2t instead of 1t and it still has the same result. Also, any command having to do with setting or adding a score in that function doesn’t execute for some reason.
Edit: My command setup is fine, I believe, because if I run the increment command in chat it works.
I don't know why it isn't working as I don't use /schedule but I will point you to a much much better solution. If you are using a data pack, there is a built-in feature which tells the game to run your function in a loop.
you can create the following directory: data pack folder > data > minecraft > tags > functions and then create a "tick.json" file inside that folder. Open it and paste this in:
{
"values":[
"namespace:function"
]
}
replace "namespace" with your namespace and "function" with the function you want to run. There is also "load.json" which only runs once (when the game loads your world) which is useful for initializing scoreboard objective and running one time commands. I have a tutorial here if you want more info: https://datapackcenter.com/projects/data-pack-basics.71/
I know about running functions using the tick method, but that wouldn’t really work with this. What I was trying to achieve was a timer than I can activate, stop, and reset whenever I needed to. I could have it run constantly using the tick method and just reset it when I need it, but I want to keep it lag-friendly.
I know about running functions using the tick method, but that wouldn’t really work with this. What I was trying to achieve was a timer than I can activate, stop, and reset whenever I needed to. I could have it run constantly using the tick method and just reset it when I need it, but I want to keep it lag-friendly.
/schedule is not a timer which you can control, It waits for n amount of ticks, seconds or in-game days and executes the specified function. If you want a controllable timer, use a scoreboard timer.
/schedule is not a timer which you can control, It waits for n amount of ticks, seconds or in-game days and executes the specified function. If you want a controllable timer, use a scoreboard timer.
You sort of can, actually. Turn it on by executing it (and have a /schedule command within that triggers itself every tick (1t)), and when you want to stop/pause it, you use the same /schedule command but with a very high tick delay. From there, you have it increment a scoreboard score by 1 every time it’s triggered.
In my function file that has the introduction dialogue, there are two commands that both trigger and stop the timer function. One of them is the second command in the second code box above, and the other one is virtually identical except that instead of 1t it’s something like 10000000000t to make it stop running when I need it. Right after is a command to reset the scoreboard score it uses back to 0. I don’t need anything precise, just something that increments every tick. The precision is coded into the function commands themselves.
Also, a scoreboard clock is what I’m *trying* to do with the function files and /schedule. In my post, I said that I’m trying to create the clock using a function on repeat with /schedule, but for some reason, it doesn’t execute.
Also, I've noticed you are using "@s" in your functions (which doesn't make sense if the functions are running themselves). Are you running the function from a player with /execute?
Also, I've noticed you are using "@s" in your functions (which doesn't make sense if the functions are running themselves). Are you running the function from a player with /execute?
The execute commands are set to execute only when a player has the required tags (or before getting a tag to set something up). I use @s to use that same player for the scoreboard scores needed. I only need to use one player (map is for 1-2 players), hence the “limit=1” part. Some of those commands would run on repeat with a schedule command set to 1t. Essentially, the functions on repeat execute all the commands on one of the players before setting itself to repeat again.
The execute commands are set to execute only when a player has the required tags (or before getting a tag to set something up). I use @s to use that same player for the scoreboard scores needed. I only need to use one player (map is for 1-2 players), hence the “limit=1” part. Some of those commands would run on repeat with a schedule command set to 1t. Essentially, the functions on repeat execute all the commands on one of the players before setting itself to repeat again.
I don't know what the problem is then. Like I said before, I suggest using tick.json over /schedule, maybe that's the problem.
I don't know what the problem is then. Like I said before, I suggest using tick.json over /schedule, maybe that's the problem.
tick.json would have it run continuously when I would prefer something I can shut off when not in use. No worries, though. I’ll just have the dialogue function set a redstone block next to a repeating command block to increment the timer.
Edit: It appears that it’s not the command that’s the issue, but a bug in executing commands. I’ve run across this type of bug a bunch of times before. With this bug, functions and command blocks refuse to run it, but when it’s sent through chat it works.
Edit 2: Actually, it was my own fault. Apparently the way the command was set up, it wasn’t able to target any entity when used in a function or command block so I had to use the ‘as’ parameter to fix that. (Mojang really makes this confusing.)
tick.json would have it run continuously when I would prefer something I can shut off when not in use. No worries, though. I’ll just have the dialogue function set a redstone block next to a repeating command block to increment the timer.
Edit: It appears that it’s not the command that’s the issue, but a bug in executing commands. I’ve run across this type of bug a bunch of times before. With this bug, functions and command blocks refuse to run it, but when it’s sent through chat it works.
Edit 2: Actually, it was my own fault. Apparently the way the command was set up, it wasn’t able to target any entity when used in a function or command block so I had to use the ‘as’ parameter to fix that. (Mojang really makes this confusing.)
That's why I asked you if you were using /execute to execute the function 'as' something, otherwise @s points to nothing. One exception is when you run the function from chat with /function, then @s will point to the player who ran it.
That's why I asked you if you were using /execute to execute the function 'as' something, otherwise @s points to nothing. One exception is when you run the function from chat with /function, then @s will point to the player who ran it.
Anyways, glad you were able to fix your issue
Mojang just makes it confusing the way they have the commands run, cause the way I had it, you’d read it as something along the line of “execute only if an entity of all players with these parameters then run the scoreboard command with the players section for the same entity targeted before (@s) with the objective called timer and add 1 to it” and you’d figure that would work but apparently not.
Also, @s (in my opinion) *should* point to the entity targeted before it, regardless if it is using ‘as’ since it’s still using an entity for it’s execution.
I’m working on a custom map and I’m trying to get some dialogue working by using a repeating function via /schedule that constantly adds 1 to a score, which is read by another function and sends out the dialogue in chat when the score hits certain numbers. This is the timer function:
The other function schedules the timer function and itself over again using these commands:
(The “book” tag is given when the player presses another button to receive a hint book they can use throughout the map, and serves as a way to keep the player from starting the map without the book.)
I know that having a function repeatedly execute itself using the /schedule command works because if I set my score to any of the numbers used when a dialogue message is to be sent out, it fills my chat with that message. The issue is that no matter where I put the command that is supposed to increment the score by 1, it is never being executed. I even put that command into the map_intro function (function that has the dialogue) (with some tweaking to make it work) and the result still happens.
My questions is: Why is this not working? Does it have something to do with my command layout, or does Minecraft simply block all attempts to run such a function? If there’s no way to make this work, I can always have it set a redstone block by a repeating command block and remove it when it’s done.
P.S. I have tried things like using 2t instead of 1t and it still has the same result. Also, any command having to do with setting or adding a score in that function doesn’t execute for some reason.
Edit: My command setup is fine, I believe, because if I run the increment command in chat it works.
I don't know why it isn't working as I don't use /schedule but I will point you to a much much better solution. If you are using a data pack, there is a built-in feature which tells the game to run your function in a loop.
you can create the following directory: data pack folder > data > minecraft > tags > functions and then create a "tick.json" file inside that folder. Open it and paste this in:
replace "namespace" with your namespace and "function" with the function you want to run. There is also "load.json" which only runs once (when the game loads your world) which is useful for initializing scoreboard objective and running one time commands. I have a tutorial here if you want more info: https://datapackcenter.com/projects/data-pack-basics.71/
Command block engineer // Developer // #TeamTrees
I know about running functions using the tick method, but that wouldn’t really work with this. What I was trying to achieve was a timer than I can activate, stop, and reset whenever I needed to. I could have it run constantly using the tick method and just reset it when I need it, but I want to keep it lag-friendly.
/schedule is not a timer which you can control, It waits for n amount of ticks, seconds or in-game days and executes the specified function. If you want a controllable timer, use a scoreboard timer.
Command block engineer // Developer // #TeamTrees
You sort of can, actually. Turn it on by executing it (and have a /schedule command within that triggers itself every tick (1t)), and when you want to stop/pause it, you use the same /schedule command but with a very high tick delay. From there, you have it increment a scoreboard score by 1 every time it’s triggered.
In my function file that has the introduction dialogue, there are two commands that both trigger and stop the timer function. One of them is the second command in the second code box above, and the other one is virtually identical except that instead of 1t it’s something like 10000000000t to make it stop running when I need it. Right after is a command to reset the scoreboard score it uses back to 0. I don’t need anything precise, just something that increments every tick. The precision is coded into the function commands themselves.
Also, a scoreboard clock is what I’m *trying* to do with the function files and /schedule. In my post, I said that I’m trying to create the clock using a function on repeat with /schedule, but for some reason, it doesn’t execute.
Also, I've noticed you are using "@s" in your functions (which doesn't make sense if the functions are running themselves). Are you running the function from a player with /execute?
Command block engineer // Developer // #TeamTrees
The execute commands are set to execute only when a player has the required tags (or before getting a tag to set something up). I use @s to use that same player for the scoreboard scores needed. I only need to use one player (map is for 1-2 players), hence the “limit=1” part. Some of those commands would run on repeat with a schedule command set to 1t. Essentially, the functions on repeat execute all the commands on one of the players before setting itself to repeat again.
I don't know what the problem is then. Like I said before, I suggest using tick.json over /schedule, maybe that's the problem.
Command block engineer // Developer // #TeamTrees
tick.json would have it run continuously when I would prefer something I can shut off when not in use. No worries, though. I’ll just have the dialogue function set a redstone block next to a repeating command block to increment the timer.
Edit: It appears that it’s not the command that’s the issue, but a bug in executing commands. I’ve run across this type of bug a bunch of times before. With this bug, functions and command blocks refuse to run it, but when it’s sent through chat it works.
Edit 2: Actually, it was my own fault. Apparently the way the command was set up, it wasn’t able to target any entity when used in a function or command block so I had to use the ‘as’ parameter to fix that. (Mojang really makes this confusing.)
That's why I asked you if you were using /execute to execute the function 'as' something, otherwise @s points to nothing. One exception is when you run the function from chat with /function, then @s will point to the player who ran it.
Anyways, glad you were able to fix your issue
Command block engineer // Developer // #TeamTrees
Mojang just makes it confusing the way they have the commands run, cause the way I had it, you’d read it as something along the line of “execute only if an entity of all players with these parameters then run the scoreboard command with the players section for the same entity targeted before (@s) with the objective called timer and add 1 to it” and you’d figure that would work but apparently not.
Also, @s (in my opinion) *should* point to the entity targeted before it, regardless if it is using ‘as’ since it’s still using an entity for it’s execution.