1
Function Command Help.
Is it possible to make a function command conditional so it will not move on to the next command if the previous command was not executable?
I am trying to make this function work but every time you execute it the commands it will give you money even if you do not have any iron.
Any Ideas? Thanks for that help.
I am trying to make this function work but every time you execute it the commands it will give you money even if you do not have any iron.
testfor @s[r=5] {Inventory:[{id:"minecraft:iron ingot",Count:1b}]}
clear @s[r=5] iron_ingot 0 1
scoreboard players add @s Money 10
tellraw @s ["",{"text":"$10","bold":true,"color":"dark_green"},{"text":" ","bold":true,"color":"dark_red"},{"text":"Has Been Added To Your Account.","color":"green"}]
Any Ideas? Thanks for that help.
6
A function can also be linked up to a chain of command blocks that are conditional. Setting a redstone block at the beginning of a command line could do that, but it would have to be in a constantly loaded area such as spawn chunks.
After using the if function, try creating multiple functions and running them inside of each other.
Commands inside a function can indeed not be made conditional, but the function command can (sort of) using the "if" or "unless" parameters followed by a selector.
Just give the player a tag in your main function whenever you want the other function to run (using /function example:example if @a[tag=TAGHERE]).
Just give the player a tag in your main function whenever you want the other function to run (using /function example:example if @a[tag=TAGHERE]).
Thanks for the help. I will give it a try.
you can use selectors to simulate conditional command blocks such as @p[tag=example] or @p[score_example_min=1] or something like that. In your case you might be able to do something like this.
scoreboard players tag @p[r=5] add example {Inventory:[{id:"minecraft:iron_ingot",Count:1b}]}
clear @s[tag=example,r=5] iron_ingot 0 1
scoreboard players add @s[tag=example] Money 10
tellraw @s[tag=example] etc.
scoreboard players tag @p[tag=example] remove example
I'm not positive this will work, but hopefully you can get the idea.
scoreboard players tag @p[r=5] add example {Inventory:[{id:"minecraft:iron_ingot",Count:1b}]}
clear @s[tag=example,r=5] iron_ingot 0 1
scoreboard players add @s[tag=example] Money 10
tellraw @s[tag=example] etc.
scoreboard players tag @p[tag=example] remove example
I'm not positive this will work, but hopefully you can get the idea.
I don't think functions can be conditional.
