PDA

View Full Version : Tutorial 2.1 - Using the Set-Reset Switch



Logic Pack
11-05-2009, 03:17 AM
Tutorial 2.1 - Using the Set-Reset Switch
By ConfusedCartman (http://www.lbpcentral.com/forums/member.php?u=118)

The Set-Reset switch has a very specific purpose, but it can be used to accomplish a number of tasks depending on what logic you use in conjunction with it. In this tutorial, we're going to cover the basics of the Set-Reset, then we'll complicate things by integrating other types of logic. The goal of the tutorial is to help you understand how basic logic and more complex logic can be networked to accomplish almost any goal.



http://www.lbpcentral.com/images/logic_pack/tutorials/2-1/2-1a.jpg

So, first off, you'll want to build something like what's pictured above. Don't worry about being exact; instead, make sure you concern yourself with learning how everything works before worrying about aesthetics. You'll find yourself lost fairly quickly otherwise.



http://www.lbpcentral.com/images/logic_pack/tutorials/2-1/2-1b.jpg

Now build yourself a one-layer-thick background of cardboard, covering the entire object from left to right and extending quite a bit ways up. You'll want to leave yourself wiggle-room for later - remember, you can always remove extra material, but it's not always as easy to add in more if you find yourself needing it. Once you've done that, build the two two-layer-thick platforms you see in the screenshot above. Once again, don't worry too much about making yours the same as ours, as we'll go into more detail about alignment soon. Also, make sure you're in pause mode. We're going to be attaching pistons in a second, and you don't want them moving out of place before you have everything configured.



http://www.lbpcentral.com/images/logic_pack/tutorials/2-1/2-1c.jpg

Here's a front-view of those same platforms, with Sackboy included for scaling purposes. Try to make them about the same distance apart and about the same height, then attach two stiff pistons and set their minimum length to about the length they are currently at. Use the white line that appears while you're tweaking the piston if you're not exactly sure.



http://www.lbpcentral.com/images/logic_pack/tutorials/2-1/2-1d.jpg

Now, set the maximum length to somewhere around here and set the timing to about 2 seconds.



http://www.lbpcentral.com/images/logic_pack/tutorials/2-1/2-1e.jpg

In this screenshot, you'll see the platforms at their most extended point, and a new, slightly higher static alcove to the left of them that resides above the floor. Go ahead and build that alcove. The goal here is to have the retracted platforms act as a stairway from the floor to the right raised floor, then once extended, the platforms should act as a new stairway from the right raised floor to the left, much higher alcove. Also, make sure that you can't get up to this newly crafted alcove any way other than the extended platforms.



http://www.lbpcentral.com/images/logic_pack/tutorials/2-1/2-1f.jpg

Now, build yourself a three-layers-thick guidebar for the door that we'll soon install. The grid mode is the best way to craft it as it ensures the guidebar will be just the right size for the door.



http://www.lbpcentral.com/images/logic_pack/tutorials/2-1/2-1g.jpg

Now add a "door". Make sure there is a gap between the top inside of the guidebar and the top of the door, so that the winch we're going to install has extra room to pull the door up to the required height.



http://www.lbpcentral.com/images/logic_pack/tutorials/2-1/2-1h.jpg

Install a winch. Make sure the minimum length is set to the current distance, and make sure the maximum length is set long enough that the door can lower flush with the floor. Also, take care to ensure that the guidebar is long enough vertically that the door doesn't ever fully leave it - otherwise, when the winch retracts, the door may not go back inside.



http://www.lbpcentral.com/images/logic_pack/tutorials/2-1/2-1i.jpg

Add a switch and two buttons in the positions shown and glue them down. At this point, you can probably leave pause mode without any issues, but if you're not sure, feel free to keep the physics paused until you're ready.




http://www.lbpcentral.com/images/logic_pack/tutorials/2-1/2-1j.jpg


Add one of our Set-Reset switches, which can be collected by following the key at the end of the Intermediate Pack. Feel free to place it wherever you like; most people choose to place it off-screen somewhere, so the player won't see the logic. You always have the option of moving it around later by box-selecting the whole switch and moving it as normal.



http://www.lbpcentral.com/images/logic_pack/tutorials/2-1/2-1k.jpg

Make sure each button is set to "directional", then connect each button to a winch in the Set-Reset switch. Make sure the right button is connected to the right winch and vice versa.



http://www.lbpcentral.com/images/logic_pack/tutorials/2-1/2-1l.jpg

Now, in this screenshot, it appears as if the buttons aren't connected to the winches like they were previously. We have disconnected these wires so as to avoid any confusion with extra wires. Note: unless we specifically tell you to disconnect something, you probably shouldn't. Moving on, we now connect the Set-Reset's magnetic key switch to the pistons. Make sure the magnetic key switch is set to directional, not on/off as is the default.



http://www.lbpcentral.com/images/logic_pack/tutorials/2-1/2-1m.jpg

Finally, set the 2-way switch to directional, and connect it to the winch. If you haven't unpaused yet, do it now. The door should be lowered and the platforms should be extended to their highest position. If this is not the case, toggle on the "backwards" setting for the appropriate pistons/winches.



http://www.lbpcentral.com/images/logic_pack/tutorials/2-1/2-1n.jpg

Now, you're pretty much done with the basic structure and functionality, so save and change to play mode to test it out. When you press the first button, the platforms should lower, allowing you access to the raised platform and upper button. When you press the upper button, the platforms should raise again, allowing you to access the upper alcove and the switch that opens the door. Pull the switch and if the door opens as expected, then everything is in working order. If you'd like, you can head back into edit mode and polish it up. In our case, we added a confirmation sound to the door (since the player cannot see it when it opens), some camera angles, and a scoreboard.

Now, we've come to the place where you have a choice: you can decide to consider it "done" and stop now, or you can continue on and try a few "tweaks" that (we hope) will help you understand how to manipulate this logic a bit better. If we decide a few "tweaks" would be beneficial, then we'll include each one as a separate reply to this thread. Now, there may be times when a tutorial doesn't include any tweaks, and that's OK - sometimes the goal can be accomplished in a fairly straightforward way, and we don't need to include any tweaks to teach what we're trying to teach. When we do include them, we think it's best for everyone to do all of them; however, you do have the option of skipping them if you're not interested.

Logic Pack
11-05-2009, 03:18 AM
Tweak #1 - Adding a "Try" Limit

In this tweak, we're going to be covering how you can detect the number of times a button is pressed and disable it once it is pressed a preset number of times. In this way, you can make the puzzle more difficult by limiting the number of times a player can make a mistake.



http://www.lbpcentral.com/images/logic_pack/tutorials/2-1/2-1o.jpg

So, first of all, make sure Create mode is paused. Since we will be dealing with dissolve, you should keep Create paused every step of the way to protect against any possible accidents. Anyway, begin by disconnecting the buttons from the Set-Reset switch. Place down two of our AND switches and two of our Dissolve-Based Counter switches. I've arranged them in a way that makes sense to me, but feel free to orient them however you prefer. On both of the Dissolve-Based Counters, invert the blue magnetic key switches (just the blue ones - not the small red ones!).



http://www.lbpcentral.com/images/logic_pack/tutorials/2-1/2-1p.jpg

Connect the left button to one of the pistons on the leftmost AND switch. Connect the leftmost Dissolve-Based Counter's blue magnetic key switch (make sure it is set to directional) to the other piston on the leftmost AND switch. Connect the leftmost AND switch's magnetic key switch (also set to directional) to the leftmost winch on the Set-Reset. Once you're done with all of that, do the same thing for the right button and the remaining logic on the right side.



http://www.lbpcentral.com/images/logic_pack/tutorials/2-1/2-1q.jpg

Now, if we went into play mode, you'd notice that it would not work as we hoped. This is because the Dissolve-Based Counter doesn't do anything useful yet. The problem here is, the Dissolve-Based Counter requires an input set to one-shot, and none of our magnetic key switches are currently configured to output on that setting. However, there is a solution: the mighty Switcher. As we mentioned in the Beginner Logic Pack, the Switcher is incredibly useful in logic networks. Introduce two Switchers, one for each button. Connect the leftmost AND magnetic key switch to the piston of the leftmost Switcher. The Switcher has two magnetic key switches, but we'll only be using one. On the leftmost Switcher, tweak the magnetic key switch that is currently off (a black sphere instead of a blue one) and set it to one-shot. Finally, connect that same magnetic key switch to the Dissolve-Based Counter's piston. Once you're finished, do all of that for the right side as well. The screenshot above will give you a good idea of what the connections should look like.



http://www.lbpcentral.com/images/logic_pack/tutorials/2-1/2-1r.jpg

Now, feel free to head into play mode and test it out - it should work as advertised. Take a look at the above to get a sense of what the entire logic network should look like. If it looks good and it works, you can consider it done and skip the following paragraph. For those who are curious why this works, the next paragraph is for you.

When you press a button, it extends one of the pistons on the AND switch. Since the Counter's magnetic key switch is inverted, it stays on only until it has been activated a certain number of times. When it is on, it keeps the AND switch's second piston extended, allowing a press of the button to have an effect. However, every time you press the button, you also activate the Counter's piston, erasing one of your "tries". When you run out of said "tries", a press of the button has no effect because the Counter's magnetic key switch is off. To customize the number of tries the player is allotted, just add/remove a few dissolve squares in the Dissolve-Based Counter to match the number of tries you'd like that button to have.

To wrap this up, there is one modification we can make to the design that gives you a bit more control as a Creator. As the design is currently, you have a certain number of tries per button, which means one button can deactivate while the other is still active. We're going to show you how to modify the design so that you can limit the number of tries overall instead of per button.



http://www.lbpcentral.com/images/logic_pack/tutorials/2-1/2-1s.jpg

Delete one Dissolve-Based Counter and both Switchers. Disconnect the cable that runs between the remaining Dissolve-Based Counter's blue magnetic key switch and the AND switch. Introduce one of our 2-way OR switches and place it anywhere you like. Be sure to leave a bit of space around the 2-way OR switch. Because of the radius of the OR switch's magnetic key switch, there may be interference from other nearby magnetic keys. You also have the option of changing the color of the OR's magnetic keys and magnetic key switch, if you prefer.



http://www.lbpcentral.com/images/logic_pack/tutorials/2-1/2-1t.jpg

Now, connect each AND switch's magnetic key switch to a piston on the OR switch. Change the OR switch's magnetic key switch to one-shot, then connect that up to the Dissolve-Based Counter's piston. Finally, connect the Dissolve-Based Counter's blue magnetic key switch to the one remaining piston on both of the AND switches. As you can see in the screenshot, you have the option of customizing the number of tries allotted to the player by adding/removing a few of the dissolve squares in the Dissolve-Based Counter. If you don't have enough room, simply extend the Dissolve-Based Counter's glass walls upward to accommodate.



http://www.lbpcentral.com/images/logic_pack/tutorials/2-1/2-1u.jpg

At this point, you're done! Now, both designs covered in this Tweak are nowhere near perfect - in fact, it only counts the number of times a button is pressed, not the number of times the button press actually does anything useful. One thing you'll quickly notice with our tutorials is we don't always like to hand you the answer; by doing so, we're hoping you'll be inventive enough to find it yourself. The most important thing about Creation is flexing your Creative muscles on your own, without relying on something like a tutorial to walk you through everything. Otherwise your work would just end up as a carbon-copy of ours, and where's the fun in that?