Hi there! I'm looking to make a shop in my minecraft server that cycles through different signs if you press another sign.
I'm not quite sure how to do this.
I want the 'shop' sign to give the player an item, if they have a certain number of precious stones, be it emerald or diamond.
Then a sign to the left or right would cycle the 'shop' to have a different item to sell.
My mind thinks that there would be signs placed elsewhere that I could move around.
I also think it might be possible to just encode those 'selector' signs to cycle through the items on the 'shop' sign without moving anything. Instead replacing the 'shop' sign, when the player uses the 'selector' sign. But I don't know if the 'selector' would be able to loop, or whether it would end. My hopes would be for it to loop.
> If Player clicks 'selector 1'
>> And 'shopvalue' is value '0'
>>> place 'shopitem1' at 'shoplocation'.
>>> Set 'shopvalue' to '1'
This is what my brain is thinking. I just don't know how to put it into JSON.
That line assumes we're using scoreboards to track values. As I don't think minecraft could tell the difference between signs just by what's on them. It's probably going to see the same thing no matter what extra NBT data is on the sign. *shrug* but I don't really know. And that's why I'm here.
Sign generators won't help if you don't know how to solve the problem first.
So to break this down: you want to check for a players inventory and if a condition is met then you want to give them an item. The problem is that you need 2 things to happen: check for the inventory and if that matches it should then give permission to use the signs.
Although it's perfectly possible to make a sign 'do' something you're also severely limiting your options if you do that. Because the command structure doesn't really allow for conditional checks. Functions come close, but even those can only check for selectors and selectors cannot check much more other than distance and such.
Therefor I suggest you use a button and commandblocks instead. Let the sign tell players what they're buying, then they can click a button and the command blocks will do the rest.
First command block could check if the player has the required items, and if so remove them (see /clear or /testfor), then the other (chain) command block can give them the items.
Keep in mind that this could be tricky. /testfor has a Count property but that doesn't account for "at least x". So: if you test for 3 ingots and the system finds 4 then it will count as a fail.
Replace every "()" with what's needed inside. What this command should do is give you a sign which you can place wherever. When you right click the sign, it should test if you have a certain item in your inventory, then should change the sign's data to a different sign (If filled out correctly).