The Meaning of Life, the Universe, and Everything.
Join Date:
5/25/2011
Posts:
57
Minecraft:
Fatal_Gear
Xbox:
Fauxreguard
Member Details
Not exactly a redstone logic question, but this seemed like the best place for this. I'm wondering if there's any way to reset a Command Block that is outputting to a comparator without running the command again. What I want to do is:
Press a button.
Activate a Command Block with a testfor command.
Output a short pulse from the Command Block if testfor is successful.
Press the button again.
Have testfor succeed again, tripping the circuit a second time.
The trouble I'm having is that once the Command Block successfully executes a command, the comparator turns on. It then remains on forever until the command is run again and fails. So, for instance, if my Command Block had the command: testfor @p[r=3]
And one were to push the button while standing 2 blocks away, and the output activates a Dispenser, it spits out an item. My whole circuit looks like this:
[Button]->[Command Block]->[Comparator]->[Dispenser]
If I press the button a second time, nothing happens because the comparator never turned off. I want it to dispense every time the button is pressed and the testfor command is successful (i.e., I want the comparator to send out a pulse instead of just staying on, because it jams up the circuit). Just curious if that's possible.
The way it's set up, it seems like I would have to step back to 4 blocks away from the Command Block, press the button so the command fails, and then step closer and press the button again. That's really asinine, and could cause a lot of unwanted results in other circuits where running the command a second timewould actually do something to effect the world (teleport a player, change a scoreboard score, etc). I realize I could just hook up an AND gate with the button and my comparator as the inputs, but that makes it occupy more space than I'd like it to and doesn't really excuse it for being asinine. Just wanted to know if there's some other way. Maybe Mojang should add a tickbox on the Command Block interface that would let you configure whether the output stayed on or sent a pulse. I would like that.
Sadly this does not refresh the command block. The only way to execute a command twice while the statement is true is to make the statement false. Another way of putting it is once the statement is true the comparator will stay active until the command is false. This causes the comparator to stay active, not allowing us to make the same two commands.
In order to get this to work as the OP wanted, we want a solution where the comparator will check to see if the command block is true and will emit ONE pulse so it can check for the same command. I'm so close to a World Guard system using Scoreboard/command blocks but because the comparators are staying active, it only works with two people. If anyone knows how to emit one pulse from the comparator that would be Freaking awesome.
@OP
If i run into anything, i'll post and update. Also this post was for more clarification.
Ah. The blockdata <x> <y> <z> {SuccessCount:0} is pretty nice.
I had solved it by making it last as long as I wanted to and then having a command replace the comprarator with air and then shortly replaced by another command. These are my commands:
testfor @e[x=1711,y=64,z=334,r=0]
comparator
tp @e[1711,64,334,0] ~-47 ~ ~
24 ticks
setblock <x> <y> <z> air
2 ticks
setblock <x> <y> <z> unpowered_comparator
I rigged this to create a break in another loop I have running as the only way a player can pass through a certain point. So long as the comparator is on "success," the other loop is stopped by its signal.
testfor @p[r=3]
And one were to push the button while standing 2 blocks away, and the output activates a Dispenser, it spits out an item. My whole circuit looks like this:
[Button]->[Command Block]->[Comparator]->[Dispenser]
If I press the button a second time, nothing happens because the comparator never turned off. I want it to dispense every time the button is pressed and the testfor command is successful (i.e., I want the comparator to send out a pulse instead of just staying on, because it jams up the circuit). Just curious if that's possible.
The way it's set up, it seems like I would have to step back to 4 blocks away from the Command Block, press the button so the command fails, and then step closer and press the button again. That's really asinine, and could cause a lot of unwanted results in other circuits where running the command a second time would actually do something to effect the world (teleport a player, change a scoreboard score, etc). I realize I could just hook up an AND gate with the button and my comparator as the inputs, but that makes it occupy more space than I'd like it to and doesn't really excuse it for being asinine. Just wanted to know if there's some other way. Maybe Mojang should add a tickbox on the Command Block interface that would let you configure whether the output stayed on or sent a pulse. I would like that.
Make something that emits a pulse continuously to the command block. Any clock circuit should do fine.
This should refresh your command block.
I realize that size is an issue but that's probably the simplest way. It would remove the button as well.
Hope this helps!
Edit: Grammar
In order to get this to work as the OP wanted, we want a solution where the comparator will check to see if the command block is true and will emit ONE pulse so it can check for the same command. I'm so close to a World Guard system using Scoreboard/command blocks but because the comparators are staying active, it only works with two people. If anyone knows how to emit one pulse from the comparator that would be Freaking awesome.
@OP
If i run into anything, i'll post and update. Also this post was for more clarification.
is it possible to do reset the comparator if strictly using Radius?
E.g.:
blockdata <x> <y> <z> {SuccessCount:0}
where x,y,z are the coords of the testfor block in question.
When the success count gets reset to 0, the signal the command block is putting into the comparator goes away. :-)
--
Furry cows moo and decompress.
/setblock ~ ~ ~ command_block 1 3 {Command:"/testfor @p[r=3]}
Is there supposed to be another " in that command? I'm having trouble getting it to work.
Yes, and it's at the end in front of the }.
/setblock ~ ~ ~ command_block 1 3 {Command:"/testfor @p[r=3]"}
Ah. The blockdata <x> <y> <z> {SuccessCount:0} is pretty nice.
I had solved it by making it last as long as I wanted to and then having a command replace the comprarator with air and then shortly replaced by another command. These are my commands:
testfor @e[x=1711,y=64,z=334,r=0]
comparator
tp @e[1711,64,334,0] ~-47 ~ ~
24 ticks
setblock <x> <y> <z> air
2 ticks
setblock <x> <y> <z> unpowered_comparator
I rigged this to create a break in another loop I have running as the only way a player can pass through a certain point. So long as the comparator is on "success," the other loop is stopped by its signal.
You can try this. It's kind of a hack but it worked for me
My Youtube Channel https://www.youtube.com/user/bongotezz
How i can use comparator in testforblock command what is name of comparator