Take the 2-minute tour ×
Arqade is a question and answer site for passionate videogamers on all platforms. It's 100% free, no registration required.

I am creating an adventure map and needed to know how to make a command block only say something once in the chat menu.

PS: I would like this to be under my floor because it is supposed to be an NPC talking. I also need to know how to set the radius so the text only appears when close enough to the command block.

share|improve this question

5 Answers 5

Here's a compacted device that will do what you want. Two command blocks are necessary; one for the player detector, and one for the message. I've labeled the blocks with example commands to use.

Explanation:

The six blocks in the top-left form a basic clock, which repeatedly triggers the testfor command. (The faster the clock, the quicker the detection, but higher CPU cost ("server lag") to run it.)

The torch of the clock activates the testfor command block at left, and (towards the right) its output is detected by the comparator, amplified by the repeater, and goes in to the command block at the right to trigger the message.

The signal then also goes to the left-pointing repeater and into the block holding the torch. This stops the clock, so that the player test will not run again. This means that left command block's output remains on, so the right command block won't say anything again since it's waiting to see the signal turn on.

Then, to reset the mechanism (after testing, say), push the button at the bottom, which reruns the player test and thus reenables the clock, while you are out of range. (It'll need to be longer than shown to be actually out of range.)

The redstone dust on top of the command block is not actually necessary (it just looks better), and if you omit it the entire mechanism is only one block high so it'll fit easier under a floor.


If you want to do the same kind of thing for something other than a message, you can just omit the command block on the right and use the redstone output for whatever you want (as long as it also loops back to stop the clock).


By the way: as a matter of game design, I would recommend that you not do exactly this, unless the message is purely flavor and not an important hint. Don't make an NPC say something only once, because the player could easily miss it the first time around, or assume they could get the information again later since most games do that.

If you simply omit the part which stops the clock (the left-pointing repeater and the wire going to it), then there will be a message each time the player enters the detection range (but not any repetitions while they are in it).

Adding a bit more redstone logic could do things like giving a long message the first time the player is detected and a short one later times.

share|improve this answer
    
Thank you very much! This works perfectly, And I can even change the /say command to anything needed (rain command perhaps). Also, The first NPC that will use this will be just like to say something just to make the game more realistic. –  MCCG May 4 at 5:59

one thing I might suggest is having the command block be paired with another command block that does something along the lines of /fill 2 2 2 stone (or whatever block you want to fill with), the second block would completely delete the first one, or you could use the copy command as the 2nd one, then, off site, you could have a number of command block sets that you could have copied and relocated to take the current command block set's place, but you'd need it to detect a slightly different locations, like to the left, right, or straight ahead, which would make this method good for conversation paths if you were to copy signs to their respective locations too

share|improve this answer

You want to use an R-S NOR latch combined with an edge detector. There are a few simplified versions that you can use if you don't need to reset the thing, such as a single fire pulse limiter, which uses a regular piston instead of a sticky piston.

share|improve this answer
    
Do you by any chance have a link to an image of that? As I do not know where to place the edge detector (and an image would be more helpful than being explained where the Edge Detector) –  MCCG May 3 at 23:50
    
No, unfortunately my internet connection went down this morning. I'm answering from my cell phone –  MBraedley May 3 at 23:52
    
I went to make an image for you, but while designing it I realized there is no need for a separate edge detector (because command blocks trigger on rising edges) or latch (because command block outputs are latched internally after the command runs), so I wrote a whole answer. –  Kevin Reid May 4 at 4:13

You could very easily just attach a redstone block to a piston, and have that triggered by a redstone signal. Boom. Done.

share|improve this answer

well, you can make it so that the redstone wire connects to a command block that says something that connects to a sticky piston that cuts off the signal of redstone and connects to an dropper on top of the pressure plate. I used this in my CTM map. 3 redstone is hidden around the map, each used in this contraption (I removed most of the walls and ceilings so you can see the whole thing) hidden in my map, used to get 3 emeralds from 3 redstone. contraption:

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.