1

Function Command Help.

ExtremeGaming654 6/8/17 10:45 pm
647
6/9/2017 4:47 pm
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.


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.
Posted by
ExtremeGaming654
Level 1 : New Explorer
1

  Have something to say?

JoinSign in

6

Heklo
06/09/2017 4:47 pm
Level 25 : Expert System
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.
1
Cadermate
06/09/2017 4:08 pm
Level 16 : Journeyman System
After using the if function, try creating multiple functions and running them inside of each other.
1
Pepijn
06/09/2017 11:52 am
Level 58 : Grandmaster Cyborg
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]).
1
ExtremeGaming654
06/09/2017 11:38 am
Level 1 : New Explorer
Thanks for the help. I will give it a try.
1
Greystalk
06/09/2017 10:20 am
Level 46 : Master Ranger
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.
1
Jakarian Studios
06/09/2017 10:11 am
Level 36 : Artisan Pixel Painter
I don't think functions can be conditional.
1

Welcome