4

For an adventure map, I'm building a library room with a hidden piston door that opens when you enter the correct 4-digit passcode. The passcode will be implemented by inserting books into the right slots in each of 4 separate chiseled bookshelves. To test out the concept, I built a simplified version of the circuit first in a superflat world - it only checks for a single digit being equal to 5, and turns on a redstone lamp if and only if it is.

The circuit works, but takes up a lot of space. Here is an aerial view with annotations - under the picture I'll describe what each part does in more detail. enter image description here

To differentiate them from comparators, I have labeled all repeaters in the picture with "R."

The signal coming out of the back of the bookshelf when the correct book is inserted should have a value exactly equal to 5. This means testing for both the conditions (s >= 5) and (s <= 5). The first comparator only outputs a signal if the bookshelf value is >= 5. The second comparator is two blocks further away, so it checks for s <= (5 - 2).

The next step is to take both results and send them to an AND gate (circled in orange). The (s <= 5) condition, if true, turns off the inhibiting comparator while the (s >= 5) condition, if true, turns on the activating comparator. So, both conditions must be true for a signal to be sent to the lamp to turn it on.

The picture shows the result after a book has been inserted in the correct slot (#5), so the lamp is on.


An area I'm having difficulty with in particular is keeping the paths for the two conditions from intersecting too soon. To solve this, one of them goes over the other on an "overpass", but that adds a vertical space requirement for the build. The fixed-value comparisons (to signal values of 5 and 3, respectively, taking up 11 and 13 blocks) also seem inefficient.

Do you have any suggestions for how to improve this?

2
  • 1
    Why are you using redstone instead of commands for this? This becomes almost trivial to do in a function file and makes your maps much more robust. Learning commands should be a prerequisite to making an adventure map. I'm not saying you have to do everything with commands and avoid redstone entirely, but for some things redstone just doesn't make sense. It's also a lot easier to cheese/bypass redstone puzzles, even in adventure mode.
    – MBraedley
    Commented Aug 18, 2023 at 18:13
  • @MBraedley I'm already using commands for my teleporters :D But, I'll admit it never occurred to me to use them for something like this. I've only used the blocks so far, not function files, but will have to look into how to do that since it seems like it will really simplify things. Thanks for the idea! Commented Aug 18, 2023 at 18:43

2 Answers 2

5

Here's two things I see already.

Compat constants/variables

One improvement you can try is to get the "5" from a block state. See Restone Comparator#Measure_Block_States.

(Note: Link may become out of date if wiki community decides to fork off Fandom)

Just have a comparator pointing out from a chest/hopper with the amount of items as listed below:

Signal Strength Hopper Item Count Chest # stacks
0 0 0
1 1 1
2 23 1s 60 (124)
3 46 3s 55 (247)
4 1s 5 (69) 5s 51 (371)
5 1s 28 (92) 7s 46 (494)
6 1s 51 (115) 9s 42 (618)
7 2s 10 (138) 11s 37 (741)
8 2s 32 (160) 13s 32 (864)
9 2s 55 (183) 15s 28 (988)
10 3s 14 (206) 17s 23 (1111)
11 3s 37 (229) 19s 14 (1235)
12 3s 60 (252) 21s 14 (1358)
13 4s 19 (275) 23s 10 (1482)
14 4s 42 (298) 25s 5 (1605)
15 5s (full/320) 27s (full/1728)

You can also get this number (though it only goes up to 8; 0-7) from an item frame.

Redstone = Spaghetti

Another thing you can do is try to avoid using wires as these take up space. Have your comparisons happen next to each other; such as this compact design by /u/Eggfur:

enter image description here

(Replace the two glass blocks with solid blocks)
The top-left hopper is your desired count, and the bottom hopper is your input.

This is roughly the compact equivilant of:

enter image description here

Subtract one less the desired from the input.
If the signal strength is 1, it is equal, and the light turns on.
If the signal strength is 0, it is less, and the light stays off because the middle section has no power.
If the signal strength is more than 1, it is greater and the light stays off, because the second repeater to the left negates the signal on the right into that comparator.

3
  • 4
    My favourite way to get a specific redstone signal is a book with 16 pages on a lectern. You will get a different signal depending on the current page.
    – Mike Caron
    Commented Aug 18, 2023 at 15:18
  • @MikeCaron Wow, that's also something I'll have to try! I had always thought of lecterns as just being the librarian villager's workstation :D Commented Aug 18, 2023 at 15:39
  • @aytimothy Thanks for writing such a detailed (and illustrated) answer! This will really help in fitting everything around the library - just imagine how big an area I would have had to excavate with the original version Commented Aug 18, 2023 at 15:41
2

Here is another idea:

enter image description here

Because you are trying to detect signal strength 5, this means that in a line of redstone dust (like in the image), the 5th dust will be on but the 6th dust will be off.

You can then just output: 5th dust AND NOT 6th dust.

10
  • That's clever! It's really nice how that method only uses one comparator total :) (Edited) Commented Aug 18, 2023 at 15:55
  • 1
    @QuackE.Duck you mean one comparator in total right? You only need to get the power from the bookshelf. The AND gate doesn't need any comparators
    – minseong
    Commented Aug 18, 2023 at 15:56
  • 1
    @QuackE.Duck you can make XOR gates without any comparators at all, A xor B = (A and not B) or (B and not A). You can make that most easily with torches and wires, like this "compact" xor gate (although this one is so compact it might be hard to see the logic)
    – minseong
    Commented Aug 18, 2023 at 16:10
  • 1
    @QuackE.Duck you don't need to accept my answer. My favourite solution to your question is aytimothy's last image, because you can easily change the password at any time - the second bookshelf stores the password. That's really elegant.
    – minseong
    Commented Aug 18, 2023 at 16:14
  • 1
    @QuackE.Duck Oh I see. I'm sure you can make a good 2-way piston door even without asking a question first. Have a go and see what you can do by connecting different online tutorials (or your own ideas!) for the different parts. If you do come up against a small and specific problem while building it, then that would be the best time to turn to this site.
    – minseong
    Commented Aug 18, 2023 at 16:47

You must log in to answer this question.

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