Home    LittleBigPlanet 2 - 3 - Vita - Karting    LittleBigPlanet 2    [LBP2] Tutorials
#1

Code Sequence

Archive: 11 posts


I didn't find this anywhere else when I myself couldn't figure it out, but now that I know how and still don't see a tutorial I figure I might as well make one.

This a simplistic yet very accurate way to create a code sequence such as the famous Konami Code, but it can also apply to other inputs besides buttons:

1. Make an XOR gate with an input for each output that will reset the sequence if triggered at the wrong time. Keep in mind that these do not need to be part of the sequence in order to reset it, which is why I linked every button and joystick on the controllinator to the XOR gate in the figure below. Now make a counter with a target count of 1 and connect its output to its own reset input. Connect the XOR gate to the counter's main input. If your XOR gate has any inputs that can be negative (such as down or left on the joysticks/d-pad), you'll want to run it through two NOT gates first in order to get the absolute value as seen in the figure below. Without those NOT gates a negative input would not be able to trigger the counter. You should end up with an output that activates momentarily when any of the buttons are pressed:
http://www.orangemarble.net/lbp/1.jpg

2. Place a selector with the port number equal to the amount of inputs in your sequence plus one, and link the counter from step 1 to its first input. Place an AND gate for each input in the sequence and link each output on the selector to each AND gate in order from #1 to whichever output comes second-to-last. Now connect each AND gate's output back to the selector so that the AND gate taking selector output #1 loops back to selector input #2, #2 to #3, etc. I recommend color coding the AND gates to make the sequence a bit more readable. This is what it looks like with 4 inputs:
http://www.orangemarble.net/lbp/2.jpg

3. Now simply connect each button to the AND gates going in sequence. In my example I use Up, Down, Triangle, and Cross in that order, which requires the use of a direction splitter. Hook the last output on the selector to whatever you want to activate when the code is completed. You now have a fully functional code sequence:
http://www.orangemarble.net/lbp/3.jpg

4. You may notice that you can still cheat the code sequence by holding one button down that isn't in the sequence and randomly mashing on the rest. This is because of a stupid oversight I noticed only after I took my screenshots, but you can fix it simply by moving the AND gates into a microchip and linking the XOR gate's output to it:
http://www.orangemarble.net/lbp/6.jpg

5. (optional) If you want to make it easier to tell which AND gate has which button assigned to it, you can use microchips instead of AND gates altogether. Have the selector turn on the microchip which has a circuit node for the next button passing through it. This functions very much the same as an AND gate but the wires should be easier to read while their respective microchip is open. You can also reverse this and have the microchip activate when the button is pressed, then pass the selector's output through it instead. This can save you some microchips whenever the same button is used multiple times in the sequence, but it can be a little more confusing since there won't be a colored microchip for those parts of the sequence anymore. Note that this example can still be cheated without being inside the microchip from step 4:
http://www.orangemarble.net/lbp/4.jpg

6. Any buttons that appear twice in a row should first be run through a counter like the one in step 1. Here is what it'd look like if Down in the sequence was replaced with another instance of Up:
http://www.orangemarble.net/lbp/5.jpg

That should leave you with a mostly perfect code sequence using one button at a time. Let me know if there's any amendments I should make, or if I'm overlooking a far better way to do it.
2011-02-20 17:16:00

Author:
Unknown User


Cool, been wanting to try a tutorial for this. Will try it out tonight and let you know how I go.
Thanks for including pics btw.

What do you need to do if you want to use the analog stick instead of the d-pad?
(as I don't like disabling popit)
2011-02-20 17:32:00

Author:
midnight_heist
Posts: 2513


What do you need to do if you want to use the analog stick instead of the d-pad?
(as I don't like disabling popit)

Same thing you'd do for the d-pad, except you may need to take some extra measures to help prevent one direction from accidentally nudging one of its two perpendicular ones. The first thing that comes to mind is a battery on a sequencer that makes the counter in step 1 only activate when the analog signal from the second NOT gate is more than 10-20% or so.
2011-02-20 17:46:00

Author:
Unknown User


We could use this to make a level for people to use to send project levels between each other without anyone getting it that isn't supposed to! I might try that.... thanks for the tutorial. I am going to use this.2011-02-21 03:33:00

Author:
flamesterart
Posts: 585


Ok, had a go.
All good until I tried step 4 (prevent cheating).
The selector is stuck on the first output, and won't move no matter which button I press (including the code).
I'm guessing I did it wrong somehow.
2011-02-21 05:05:00

Author:
midnight_heist
Posts: 2513


In step one, I think you can simply use an inverted not gate (yes, you can invert them) instead of two normal not gates2011-02-21 05:47:00

Author:
Unknown User


I see Booxely already found this tutorial! He and me were messing around a bit the other night trying to get something up.

I gave up very early.

By the way, what I am curious about, is the basics behind this the fact that both an output from the XOR gate and a correct user input are received by the Selector and the Selector gives priority to the highest input channel number (meaning the correct button overrides the XOR gate that resets the Selector on ALL user input)?

If so, why using a XOR gate? What does a XOR gate with more than two inputs do exactly? Would an OR gate not be enough here?
2011-02-21 14:20:00

Author:
Antikris
Posts: 1340


In step one, I think you can simply use an inverted not gate (yes, you can invert them) instead of two normal not gates
A simple repeater like that will still pass negative values through. I'm not sure if that's a bug or what, but that's the way it is.


By the way, what I am curious about, is the basics behind this the fact that both an output from the XOR gate and a correct user input are received by the Selector and the Selector gives priority to the highest input channel number (meaning the correct button overrides the XOR gate that resets the Selector on ALL user input)?

If so, why using a XOR gate? What does a XOR gate with more than two inputs do exactly? Would an OR gate not be enough here?Yes, this works because selectors give priority to higher ports. The circuit waits for any of the inputs to turn on and attempts to reset the selector, but gets overridden by a higher port if that input was the correct one.

The XOR gate turns on only when exactly one button is being pressed, so it won't allow you to cheat by holding down every button at once like an OR gate would.

Edit:

Ok, had a go.
All good until I tried step 4 (prevent cheating).
The selector is stuck on the first output, and won't move no matter which button I press (including the code).
I'm guessing I did it wrong somehow.Can you get me a screenshot of your setup?
2011-02-21 18:55:00

Author:
Unknown User


http://i1.lbp.me/img/ft/2c11661467539cb02ba2a7a8264ad6ab546b9817.jpg
Here ya go.
I double checked the steps.
It's the konami code.
2011-02-22 04:03:00

Author:
midnight_heist
Posts: 2513


what about letter codes?2011-02-24 02:31:00

Author:
wait wtf
Posts: 853


Very delayed reply but...

http://i1.lbp.me/img/ft/2c11661467539cb02ba2a7a8264ad6ab546b9817.jpg
Here ya go.
I double checked the steps.
It's the konami code.
It's probably because you have the wires from the splitter running through the microchip with the AND gates instead of directly to the two counters, creating either a delay or cutoff of some sort. I'm not sure if that's the problem because I see no reason for it to happen, but it looks like the only thing you did differently. I also have no clue how you're using both up/down and left/right in the sequence without more than one splitter.

It's unnecessary to have the splitter's two outputs connected to the XOR gate separately when you can just link the single up/down output to them. I doubt that's causing any problems though.
2011-02-27 09:50:00

Author:
Unknown User


LBPCentral Archive Statistics
Posts: 1077139    Threads: 69970    Members: 9661    Archive-Date: 2019-01-19

Datenschutz
Aus dem Archiv wurden alle persönlichen Daten wie Name, Anschrift, Email etc. - aber auch sämtliche Inhalte wie z.B. persönliche Nachrichten - entfernt.
Die Nutzung dieser Webseite erfolgt ohne Speicherung personenbezogener Daten. Es werden keinerlei Cookies, Logs, 3rd-Party-Plugins etc. verwendet.