I'm looking to have a chain-always active command block use setblock to set a repeating command block with this command: execute as @p[nbt={Inventory:{tag:{display:{Name:"{\"text\":\"Backdoor Key\"}"}}}}] run playsound minecraft:ui.toast.challenge_complete master @p -31 63 318 1 1 1
I tried this but it's not working: setblock -31 60 322 minecraft:repeating_command_block[facing=east]{Command:"execute as @p[nbt={Inventory:{tag:{display:{Name:"{\"text\":\"Backdoor Key\"}"}}}}] run playsound minecraft:ui.toast.challenge_complete master @p -31 63 318 1 1 1",auto:1} replace
It's Json string formatting. The "\" character is a special escape character which is used to "escape" strings (my theory) If you've done any programming you will know what strings are but in case you don't, strings are basically words. By adding two more backsplashes you're allowing a single backslash to exist inside of text without escaping that text. I know this is all very confusing and I barely get it myself, your best option is googling it if you're really interested.
Ok, yes that does explain that. I'm not terribly familiar with json but I know enough to figure it out. Just going to have to get used to it. Thank you!
I'm looking to have a chain-always active command block use setblock to set a repeating command block with this command: execute as @p[nbt={Inventory:{tag:{display:{Name:"{\"text\":\"Backdoor Key\"}"}}}}] run playsound minecraft:ui.toast.challenge_complete master @p -31 63 318 1 1 1
I tried this but it's not working: setblock -31 60 322 minecraft:repeating_command_block[facing=east]{Command:"execute as @p[nbt={Inventory:{tag:{display:{Name:"{\"text\":\"Backdoor Key\"}"}}}}] run playsound minecraft:ui.toast.challenge_complete master @p -31 63 318 1 1 1",auto:1} replace
Anyone know how this can be done?
Use this:
Command block engineer // Developer // #TeamTrees
Can you explain why that is. What is it that you doing by adding the extra "\"?
It's Json string formatting. The "\" character is a special escape character which is used to "escape" strings (my theory) If you've done any programming you will know what strings are but in case you don't, strings are basically words. By adding two more backsplashes you're allowing a single backslash to exist inside of text without escaping that text. I know this is all very confusing and I barely get it myself, your best option is googling it if you're really interested.
Command block engineer // Developer // #TeamTrees
Ok, yes that does explain that. I'm not terribly familiar with json but I know enough to figure it out. Just going to have to get used to it. Thank you!