I am making an adventure map that involves a shop. I am having trouble with the command how do I testfor a player with 2 or more emeralds rather than just 2?
You can use CommandStats to accomplish this, which also supports multiplayer tracking.
Prerequisites:
Objective for each player to hold their own score:
/scoreboard objectives add ITEMS dummy
In order for CommandStats to modify a score, the target must be tracked prior to triggering. You may need to run the following on a clock if new players are able to enter the game at any time. Adding 0 will force players to be tracked with a default score of 0, while not affecting previously-tracked scores:
/scoreboard players add @a ITEMS 0
And finally, the players will need a necessary CommandStat trigger, in this case "AffectedItems". This may also need to be on a clock, same reasoning as the command before. The trigger will set the player's own score equal to the number of "affected items" whenever the player runs a command that targets items (such as /clear).
/stats entity @a set AffectedItems @p ITEMS
Triggering:
Place the following into a command block that will be detecting items in the inventory. It forces players to clear from their own inventories. It will not remove any items from their inventory, but we will get the necessary data: the number of items that *could* have been cleared.
Every time the /execute command is activated, players run the /clear command, triggering their stored CommandStat. That CommandStat will check the number of items the command the player ran (/clear) affected, and set the nearest player (which will be the executing player, so themselves) to have their "ITEMS" score set equal to that value.
So if a player has 30 cobblestone, their "ITEMS" score is set to 30. You can then target players with that score:
/say @a[score_ITEMS_min=30]
This will consider items regardless of where they are in their inventory.
I am making an adventure map that involves a shop. I am having trouble with the command how do I testfor a player with 2 or more emeralds rather than just 2?
This will require the use of CommandStats. I have a post describing how to do this here: http://www.minecraftforum.net/forums/minecraft-discussion/redstone-discussion-and/command-blocks/2395386-how-can-i-detect-if-player-have-a-minimum-amount?comment=3
Minecraft-things: http://skylinerw.com
More Minecraft-things: https://sourceblock.net
Guides for command-related features (eventually moving to Source Block): https://github.com/skylinerw/guides
I primarily hang out in the /r/MinecraftCommands discord, where there's a lot of people that help with commands: https://discord.gg/QAFXFtZ
Their corresponding subreddit: https://www.reddit.com/r/MinecraftCommands/
Thank you.