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