Jump to content

  • Curse Sites
Become a Premium Member! Help
Latest News Article

Reset Command Block / Comparator?

command block comparator testfor

  • Please log in to reply
6 replies to this topic

#1

Fatal Gear

Posted 09 April 2013 - 08:19 AM

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 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.
Posted Image

Register or log in to remove.

#2

4mallyIntroduced
  • Minecraft: 4mallyIntroduced

Posted 09 April 2013 - 06:04 PM

The answer is fairly simple.

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

Edited by 4mallyIntroduced, 09 April 2013 - 06:07 PM.


#3

Legym
    Legym

    Out of the Water

  • Members
  • 2 posts

Posted 13 April 2013 - 07:09 AM

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.

#4

Raghav11

Posted 13 April 2013 - 11:32 AM

Does the comparator update like a BUD switch? You could make a monostable circuit I think.

Posted Image


#5

Pyro
    Pyro

    Obsidian Miner

  • Members
  • 1358 posts
  • Location: Sweden

Posted 14 April 2013 - 03:55 AM

It's simple comparator logic really, you just give it power after the amount you want to the side and it resets.

View Postnoobkilla123, on 28 May 2012 - 07:44 PM, said:

c is good but java maked minecraft so java can make better games with blocks so i would pick java

INACTIVE - RARELY VISIT THE FORUMS, IF YOU FOR SOME ODD REASON NEED ME, SEND A PM!


#6

Legym
    Legym

    Out of the Water

  • Members
  • 2 posts

Posted 14 April 2013 - 05:50 AM

View PostPyro, on 14 April 2013 - 03:55 AM, said:

It's simple comparator logic really, you just give it power after the amount you want to the side and it resets.

is it possible to do reset the comparator if strictly using Radius?

#7

Pyro
    Pyro

    Obsidian Miner

  • Members
  • 1358 posts
  • Location: Sweden

Posted 14 April 2013 - 11:35 AM

View PostLegym, on 14 April 2013 - 05:50 AM, said:

is it possible to do reset the comparator if strictly using Radius?
It's always possible to reset a comparator by powering the side.

Minecraftwiki said:

The Redstone Comparator (pronounced kəmˈparətər) is a block for use with redstone circuitry. It has two inputs: one from the back ('signal A') and one from the side ('signal B'). If signal B is stronger than signal A, there will be no output

This means that as long as the signal going in on the side is greater than the signal strength from the command block it will reset until the command runs again.

View Postnoobkilla123, on 28 May 2012 - 07:44 PM, said:

c is good but java maked minecraft so java can make better games with blocks so i would pick java

INACTIVE - RARELY VISIT THE FORUMS, IF YOU FOR SOME ODD REASON NEED ME, SEND A PM!