I understand how to use the chain command block etc., but I was just wondering if there was anyway to use the if/then command in one command if that makes sense.
I know but they could work. If a testfor command is true (see the "if") the comparator will activate. With enough True/False conditions, I guess you can create an If/then chain (ex: "/testfor (playername)[score_scoreboardname_min=1,score_scoreboard=1]", couldn't it can basically mean "if (playername) has a scoreboard score of 1, then activate other command (via comparator)
Well what you are asking is exactly an if/then situation. The only problem is that even in real programming, this is a multi-lined, or compound, "then".
Meaning, you cannot accomplish the removal of the levels and giving of the item without two separate commands. However, to answer your original question, yes you can make an if/then in one command:
/execute @a[lm=5] ~ ~ ~ xp -5L
What this command can be translated to is:
If a player has at least 5 levels, then remove 5 levels.
Since this still does not accomplish your requirements, here is a solution:
/scoreboard players tag @a[lm=5] add act
/xp -5L @a[tag=act]
/give @a[tag=act] minecraft:dirt 1 0 {display:{Name:"5 xp",Lore:["Look at you...","You managed to get 5 levels","Have some useful dirt!"]}}
/scoreboard players tag @a[tag=act] remove act
Now this can be translated to this in pseudo code:
I understand how to use the chain command block etc., but I was just wondering if there was anyway to use the if/then command in one command if that makes sense.
Can you give me the command so I could help you?
If you mean change multi command lines into one line you can do it by using scoreboard
i guess you could just use a comparator
Comparators are for True/False not If/Then
I know but they could work. If a testfor command is true (see the "if") the comparator will activate. With enough True/False conditions, I guess you can create an If/then chain (ex: "/testfor (playername)[score_scoreboardname_min=1,score_scoreboard=1]", couldn't it can basically mean "if (playername) has a scoreboard score of 1, then activate other command (via comparator)
I don't have the exact command but what I'm trying to do is
I've created a help command block creation on my PMC account.
It works as such: {onRightClick:{event:AllowFlight},Particle:flame}
But if you do not want to install modifications, you can always use the detect feature if you want to detect a block and then run an action.
Example:
/execute @a ~ ~ ~ detect ~ ~-1 ~ grass 0 /say hi
Well what you are asking is exactly an if/then situation. The only problem is that even in real programming, this is a multi-lined, or compound, "then".
Meaning, you cannot accomplish the removal of the levels and giving of the item without two separate commands. However, to answer your original question, yes you can make an if/then in one command:
/execute @a[lm=5] ~ ~ ~ xp -5L
What this command can be translated to is:
If a player has at least 5 levels, then remove 5 levels.
Since this still does not accomplish your requirements, here is a solution:
/scoreboard players tag @a[lm=5] add act
/xp -5L @a[tag=act]
/give @a[tag=act] minecraft:dirt 1 0 {display:{Name:"5 xp",Lore:["Look at you...","You managed to get 5 levels","Have some useful dirt!"]}}
/scoreboard players tag @a[tag=act] remove act
Now this can be translated to this in pseudo code:
if (player.level >= 5) {
player.addLevel(-5)
player.giveItem(...)
}
Or in other, actual, words:
if player's level is at least 5, then
remove 5 levels from player
give them the special item
done
Using the first command this is what came up: [19:07:23] Failed to execute 'xp -5L' as Byslic. Again thanks for the help!
That first command was simply an example you would actually do this:
/xp -5L @a[lm=5]