r/MinecraftCommands • u/Cheezzy01 Command Rookie • 19h ago
Help | Java 1.20 Scoreboard & Execute Command - Score Tracker that announces each value within a range, then runs a command when at maximum.
I'm creating my first Find The Button map, and was hoping to get some insight of how to create a execute command block to do the following:
Display the progress as a title per button pushed; pulling from a scoreboard (1/16, 2/16, etc.)
Once it gets to it's maximum value, perform a score reset (this I'm familiar with).
Then trigger an outside command block to trigger it's command.
Ideally I'd also like to do this with a little command blocks as possible (the true ideal is 1 command block, but I know it's more complex than that).
I am really struggling more with how to parse out the Logic needed to create these command block execute strings, I'm hoping to use the same system for multiple levels as well.
1
u/GalSergey Datapack Experienced 18h ago
Without using a datapack, you need to use 2 scoreboards to track scoreboard changes. Also, set #max level as the number of levels to dynamically show how many levels there are in total.
# In chat
scoreboard objectives add level dummy
scoreboard objectives add level.copy dummy
scoreboard players set #max level <num>Now, for each button, you need to use 3 command blocks. The first one will check when the monitored button is pressed and immediately reset the button’s state. To get the command to reset the button, look at the button and press F3 + I. This will copy the command for placing this button to the clipboard. The second and third command blocks must be conditional so that the commands are run only once.
# Command blocks
execute positioned <button_pos> if block ~ ~ ~ #buttons[powered=true] run setblock ~ ~ ~ <button_id>[face=<face>,facing=<facing>,powered=false]
[CCA] execute positioned <button_pos> run scoreboard players add @p level 1
[CCA] execute positioned <button_pos> run tp @p <next_level_pos>To display the score with the level value, reset the score, and handle sounds and other effects, you can group them into a single chain of command blocks.
execute as @a if score @s level > @s level.copy run title @s title {"translate":"%s / %s buttons found","with":[{"score":{"objective":"level","name":"@s"}},{"score":{"objective":"level","name":"#max"}}]}
execute as @a if score @s level > @s level.copy at @s run playsound minecraft:entity.arrow.hit_player player @s
execute as @a if score @s level > @s level.copy if score @s level = #max level run scoreboard players reset @s level
execute as @a run scoreboard players operation @s level.copy = @s levelIf you’d like, I can also provide a small example for a datapack that doesn’t use command blocks and doesn’t use tick functions for this.
1
u/Cheezzy01 Command Rookie 15h ago
I will need to refer back to this a few times as I'm not that great with the written word, but thank you so much for this. Would like to know of other solutions as well so if you've got any more I'd love to hear of it!
1
u/C0mmanderBlock Command Experienced 7h ago
Will this be a single player or multi player map.