I'm looking for a very simple way to switch a block with a block with air with a single button press. As of now, I have several hoppers checking my score that is raised by the button pressing and that is what sets the block that I want. However, because of the massive amounts of blocks I get lag - simply to much hoppers involved. I looked at piston exchanges but they are to large for my needs. So, I'm pondering a command block or two that would place the block, then know to place a new block when the button is pressed - and finally know to place air when the button is pressed a third time. It would then reset and when you pressed the button again you would get the first block.
First make a dummy scoreboard objective, for example's sake I'll call it "buttonsPressed".
Then put this in a command block hooked directly to the button:
/scoreboard players add @p buttonsPressed 1
Then put a repeater for a delay, and all of these commands hooked to that:
/execute @a[score_buttonsPressed=1,score_buttonsPressed_min=1] ~ ~ ~ /setblock (coordinates for first block) (block name)
/execute @a[score_buttonsPressed=2,score_buttonsPressed_min=2] ~ ~ ~ /setblock (coordinates for second block) (block name)
/execute @a[score_buttonsPressed=3,score_buttonsPressed_min=3] ~ ~ ~ /setblock (coordinates for first block) air
/execute @a[score_buttonsPressed=3,score_buttonsPressed_min=3] ~ ~ ~ /setblock (coordinates for second block) air
And then lastly, put one more repeater leading into this command:
/scoreboard players set @p[score_buttonsPressed_min=3] buttonsPressed 0
Your very own working button toggle thingy in just 6 command blocks! If you use it in multiplayer, make sure that the player pushing the button is always the closest player to the command blocks. Or if you want, you could switch the commands to be based on a named armor stand, which would make it work perfectly in multiplayer no matter what. Either way that should work, hope I helped!
Rollback Post to RevisionRollBack
May the ores be with you.
Yes, I'm one of these guys: If I say something that offends you or just seems wrong, please let me know. I was almost certainly just making a joke or a pun, or something really dumb like that, and didn't mean anything by it. Don't take anything I say too seriously!
Looks good, -- I'll have to have 64 names still, but this is without hoppers! <3
thanks I'll let you know if it works!
edit... IT WORKS AWESOSMEEEEE ! THank you x99999% no more hoppers -- at least, not for that.
You're welcome, glad I could help!
Rollback Post to RevisionRollBack
May the ores be with you.
Yes, I'm one of these guys: If I say something that offends you or just seems wrong, please let me know. I was almost certainly just making a joke or a pun, or something really dumb like that, and didn't mean anything by it. Don't take anything I say too seriously!
Any ideas?
Thanks.
First make a dummy scoreboard objective, for example's sake I'll call it "buttonsPressed".
Then put this in a command block hooked directly to the button:
/scoreboard players add @p buttonsPressed 1
Then put a repeater for a delay, and all of these commands hooked to that:
/execute @a[score_buttonsPressed=1,score_buttonsPressed_min=1] ~ ~ ~ /setblock (coordinates for first block) (block name)
/execute @a[score_buttonsPressed=2,score_buttonsPressed_min=2] ~ ~ ~ /setblock (coordinates for second block) (block name)
/execute @a[score_buttonsPressed=3,score_buttonsPressed_min=3] ~ ~ ~ /setblock (coordinates for first block) air
/execute @a[score_buttonsPressed=3,score_buttonsPressed_min=3] ~ ~ ~ /setblock (coordinates for second block) air
And then lastly, put one more repeater leading into this command:
/scoreboard players set @p[score_buttonsPressed_min=3] buttonsPressed 0
Your very own working button toggle thingy in just 6 command blocks! If you use it in multiplayer, make sure that the player pushing the button is always the closest player to the command blocks. Or if you want, you could switch the commands to be based on a named armor stand, which would make it work perfectly in multiplayer no matter what. Either way that should work, hope I helped!
May the ores be with you.
Yes, I'm one of these guys: If I say something that offends you or just seems wrong, please let me know. I was almost certainly just making a joke or a pun, or something really dumb like that, and didn't mean anything by it. Don't take anything I say too seriously!
thanks I'll let you know if it works!
edit... IT WORKS AWESOSMEEEEE ! THank you x99999% no more hoppers -- at least, not for that.
You're welcome, glad I could help!
May the ores be with you.
Yes, I'm one of these guys: If I say something that offends you or just seems wrong, please let me know. I was almost certainly just making a joke or a pun, or something really dumb like that, and didn't mean anything by it. Don't take anything I say too seriously!