0

I want to connect a button to a command block, and execute a toggle command when the button goes "off"

In Javascript terms, I want to execute a command "onMouseUp"

Command blocks only seem to execute when they are turned on. How do you make a command block execute a callback operation when the block is turned off?

1 Answer 1

1

Place a redstone torch between the button and the command block.

4
  • To what extent does this violate the "don't mix redstone and commands" rule?
    – One 2 Many
    Jan 16, 2021 at 23:37
  • If you have another answer that doesn't use redstone, feel free to post it, however any pure-command answer I can think of for this is more complicated.
    – pppery
    Jan 16, 2021 at 23:42
  • i don't understand how this would do what i want. doesn't a restone torch just keep a command block on all the time? how does this execute a different command when the button pops up?
    – JDS
    Jan 17, 2021 at 16:45
  • 1
    A command block that is not set to repeating only activates once, when it receives redstone power, and then doesn't activate again until it becomes unpowered and then powered again. If you connect a command block to a redstone torch, it will activate once as you wire the mechanism, and then again after the torch turns on (when the button is pressed) and then off again (when the button is released)
    – pppery
    Jan 17, 2021 at 16:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .