2

I am trying to set up a branching dialogue system using command blocks, a scoreboard, a trigger objective, and a command block chain.

The first five command blocks work correctly. I can see the fourth and fifth command blocks updating my score. However, the sixth, seventh, and eighth command blocks don't work. I'm not sure why. I'm using the same commands that I used for the fifth command block. For some reason, they are not activating.

First Command Block (set as impulse, unconditional, needs redstone, and triggered by a pressure plate).

/scoreboard objectives add dialoguetrigger trigger

Second Command Block (set as chain, unconditional, always active).

/scoreboard players enable @p dialoguetrigger

Third Command Block (set as chain, unconditional, always active).

scoreboard objectives setdisplay sidebar dialoguetrigger

Fourth Command Block (set as chain, unconditional, always active).

scoreboard players set @p dialoguetrigger -1

Fifth Command Block (set as chain, unconditional, always active).

execute if score @p dialoguetrigger matches -1 run tellraw @p ["",{"text":"Bartholomew: Do you wish for me to speak with you? Enter the chat and click "},{"text":"SPEAK. ","color":"gold","clickEvent":{"action":"run_command","value":"/trigger dialoguetrigger set 3"}},{"text":"You may also ask for "},{"text":"SILENCE.","color":"gold","clickEvent":{"action":"run_command","value":" /trigger dialoguetrigger set 2"}}]

Sixth Command Block (set as chain, unconditional, always active).

execute if score @p dialoguetrigger matches 2 run tellraw @p ["",{"text":"Bartholomew: I’ll leave you to your thoughts."}]

Seventh Command Block (set as chain, unconditional, always active).

execute if score @p dialoguetrigger matches 1 run tellraw @p ["",{"text":"Bartholomew: The rooms have become unruly in your absence. Doors behind doors. "},{"text":"[...]","color":"gold","clickEvent":{"action":"run_command","value":"/trigger dialoguetrigger set 3"}}]

Eighth Command Block (set as chain, unconditional, always active).

execute if score @p dialoguetrigger matches 3 run tellraw @p ["",{"text":"HOW DARE YOU LET THIS HAPPEN!!! ","color":"gold","clickEvent":{"action":"run_command","value":"/trigger dialoguetrigger set 4"}},{"text":" OR "},{"text":"WHERE ARE THE GARDENS?","color":"gold","clickEvent":{"action":"run_command","value":"/trigger dialoguetrigger set 5"}}]

1 Answer 1

3

You set dialoguetrigger to -1 and then immediately check for various values. It will only ever be -1 and only the command that checks for -1 will execute.

Scoreboard initialisation (creation, setdisplay, initial values) should usually only be done once in the process of making a map and not be put into a command block. Or you can have one place that initialises everything, but that should only run when the map is started, not many times while playing it.

1
  • Thank you! I didn't realize all the command blocks would execute immediately. I ended up running the initial scoreboard value of -1 off a pressure plate and the remaining command blocks off a redstone clock. Very helpful!
    – Megan
    May 23, 2020 at 14:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .