PDA

View Full Version : Tutorial 1.1 - Your First Logic Network



Logic Pack
11-05-2009, 01:56 AM
Tutorial 1.1 - Your First Logic Network
By rtm223 (http://www.lbpcentral.com/forums/member.php?u=4150)

In the Beginner Pack, we demonstrated how including a few basic logic switches in your level can greatly improve its quality. This was especially true in the final room, where we showed how our logic switches could be combined in a "network" to create complex puzzles and contraptions. Often, single logic switches aren't enough to achieve a specific goal, and it becomes necessary to wire logic switches into other logic to achieve your goals. The goal of this tutorial is to create one of these basic logic "networks" in order to (hopefully) help you understand the principles of combining logic with other logic.

First off, create a new level on your moon and pause the physics. Doing so is important to make sure nothing runs off on you or otherwise behaves in a way that we would want to avoid. You should only unpause your level when you need to observe something in action - otherwise, to be safe, keep it paused at all times.



http://www.lbpcentral.com/images/logic_pack/tutorials/1-1/1-1%20%281%29.jpg

Build a base for your puzzle room as pictured above. Make the floor three layers thick and quite wide (you want to give your player room to move around). Make the back wall 1 layer thick and glue it to the base.



http://www.lbpcentral.com/images/logic_pack/tutorials/1-1/1-1%20%282%29.jpg

Next, plop down two sponge blocks, which will be used as the key elements of the puzzle. Make them 4x4 small grid squares in size and place a magnetic key in the centre, as shown. Move these out of the way a little bit and then create some platforms to play in.



http://www.lbpcentral.com/images/logic_pack/tutorials/1-1/1-1%20%283%29.jpg

As you can see, the platforms have small alcoves cut into them. This is where the aforementioned blocks will need to be placed to complete the puzzle. Be sure that these alcoves are at least 4x4 small grid squares, in order to accommodate the blocks.



http://www.lbpcentral.com/images/logic_pack/tutorials/1-1/1-1%20%284%29.jpg

Glue these platforms to the base and place the cushions on the platforms, one on each side. In each of the alcoves, place a magnetic switch near the centre. If you're a perfectionist, the grid tool is perfect for getting these switches in the exact centre of the alcove, so be sure to use it.



http://www.lbpcentral.com/images/logic_pack/tutorials/1-1/1-1%20%285%29.jpg

In the tweak menu, set the radius to be quite small (as indicated by the white circle in the image) and set the magnetic switches to directional. This is very important, as we will be wiring these magnetic switches into some logic in a minute.



http://www.lbpcentral.com/images/logic_pack/tutorials/1-1/1-1%20%286%29.jpg

One thing that you can do here is to shrink down the size of the sponge blocks a tiny bit, so they can fit into the holes a little easier. It also stops them getting stuck and breaking your puzzle. As you can see from the image above, it's only a small change but it makes the puzzle a lot less fiddly for the player. You will need to turn the grid off to complete this bit, so be sure to turn it back on once you're done.



http://www.lbpcentral.com/images/logic_pack/tutorials/1-1/1-1%20%287%29.jpg

Now comes the fun part - we're going to finally place some logic! We need a logic switch that will activate when both of the magnetic switches are activated, which means an AND switch. The AND switch from the Beginner Pack is pictured above. If you haven't already picked up an AND switch from the Beginner Logic Vault, then you will need to go grab it before you can complete this tutorial. While you are there, it's probably a good idea to capture all of the logic so you have it available at all times while creating.



http://www.lbpcentral.com/images/logic_pack/tutorials/1-1/1-1%20%288%29.jpg

Place the AND switch on the back wall so it's visible, but don't glue it - the dark matter will keep it up. Normally, creators place their logic out of view, but while you're testing your creations it's very useful to see what the logic is doing, both for visual confirmation and to help nail down bugs (if any exist). Connect wires from each of the magnetic switches to one of the pistons in the AND switch.



http://www.lbpcentral.com/images/logic_pack/tutorials/1-1/1-1%20%289%29.jpg

At this point we can test that the logic is wired up correctly and behaves in the right way. Change to play mode and drag the sponges into the holes. The magnetic switches in the holes should make the pistons extend and the AND switch should activate its magnetic key when both pistons extend, like the picture above.

Hopefully this test has been executed successfully, but if not, try checking that:


The pistons in the AND switch are set to stiff and are not backwards.
The magnetic switches in the holes are set to directional and are not inverted.
The green magnetic key switches have large enough radii to detect their matching magnetic key.
The AND switch is not glued to the back wall.

Once it works as it's supposed to, you can move on to the next portion of the tutorial.



http://www.lbpcentral.com/images/logic_pack/tutorials/1-1/1-1%20%2810%29.jpg

Now the basic puzzle is done, we need a reward for solving the puzzle. In this case we will keep things simple and simply have the puzzle open a door. Create an upside down U-shape as shown above. To keep things neat and "machined", keep the small grid on while you design this bit. Glue this piece to the back wall.



http://www.lbpcentral.com/images/logic_pack/tutorials/1-1/1-1%20%2811%29.jpg

Add the door, and connect it to the U-shape with a piston. Make sure the piston is stiff and set so that the maximum length is long enough that it extends to the floor. Be careful here! If you make the maximum length too long, you risk breaking pieces of your level, so only make it as long as absolutely necessary!



http://www.lbpcentral.com/images/logic_pack/tutorials/1-1/1-1%20%2812%29.jpg

Now change the minimum length to something very small, so the door can be opened, and set the timing to around 1.5s. Now go back to the AND gate and set that magnetic key switch to directional. Connect this magnetic key switch up to the piston controlling the door. Finally, set the door piston to backwards, so the door stays closed until the puzzle is solved.



http://www.lbpcentral.com/images/logic_pack/tutorials/1-1/1-1%20%2813%29.jpg

This should be a completed, working puzzle for your level. Go into play mode and test that it works. Again, if anything isn't working properly, check that the switches and connectors are tweaked correctly, and nothing is glued where it shouldn't be.

Technically speaking, this isn't a logic network yet, as we have only used a single logic switch. Rather than stopping here, we're going to incorporate a "give up" button into the mix, which will allow the player to skip the puzzle if they desire. For the purposes of this puzzle, the idea of a "give up" button is rather silly, but it's a nice way to explore how a logic network can be used. Once you have a firmer grasp on logic networks, you could include some sort of payout for correctly solving the puzzle (score bubbles, perhaps!?). Here, our "give up" button will just serve as an alternative way of opening the door. Anything beyond this is up to you.



http://www.lbpcentral.com/images/logic_pack/tutorials/1-1/1-1%20%2814%29.jpg

Make a copy of the existing scene and place it over to the right of the version that is already there. Once you have done this, place a button on a wall, out of the main puzzle area (so your players can't trigger it by accident). Tweak the button to directional.



http://www.lbpcentral.com/images/logic_pack/tutorials/1-1/1-1%20%2815%29.jpg

Now get an OR switch from the Beginner Pack and place it next to the AND switch you already have on the wall. The picture above shows what the 2-input OR switch looks like, if you have any doubts.



http://www.lbpcentral.com/images/logic_pack/tutorials/1-1/1-1%20%2816%29.jpg

We need to wire up the OR switch as shown above. Disconnect the AND switch output wire from the door and reconnect it to one of the pistons in the OR switch. Then wire the give up button that you have just placed into the other piston of the OR switch. Note that the wires connected to the AND switch pistons are not shown. This is just for clarity - do not disconnect those wires in your version!



http://www.lbpcentral.com/images/logic_pack/tutorials/1-1/1-1%20%2817%29.jpg

Now take the output of the OR switch and wire that up to the door. Remember to set the output of the OR switch to directional. Go into play mode and test the new give up button. It wonít actually work, but donít worry, itís all part of the lesson. What you should see is that when you press the button, it triggers the OR switch. This in turn will make the door open. However, as soon as the button is released, the OR switch deactivates and the door closes again.



http://www.lbpcentral.com/images/logic_pack/tutorials/1-1/1-1%20%2818%29.jpg

What we need is a way to ensure that the door stays open permanently once the give up button is pressed. The permanent switch from the Beginner Pack (shown above) can be used to achieve this.



http://www.lbpcentral.com/images/logic_pack/tutorials/1-1/1-1%20%2819%29.jpg

Note that some of the wires are not shown again in this image, but remember, that is for clarity - in our tutorials, you should never detach wires unless expressly told to do so. Place the permanent switch next to the existing logic. You will need to wire the permanent switch in between the give up button and the OR Switch. First, disconnect the wire from the give up button to the OR switch. Tweak the permanent switch to be directional and wire it to the OR switch as shown above.



http://www.lbpcentral.com/images/logic_pack/tutorials/1-1/1-1%20%2820%29.jpg

Now tweak the give up button to either on/off or one-shot (both have the same effect on dissolve material) and connect the wire to the dissolve of the permanent switch. The puzzle should be complete with a working "give up" button now. Change to play mode and ensure that it works both ways - both with the newfound give-up button and the actual solution.

Everything should work as advertised now! If you're still having issues, check that:


You haven't inadvertently glued your logic to the back wall.
None of your logic's magnetic keys are interfering with other magnetic key switches. By default, our key switches have their trigger radii tweaked for minimal interference, but regardless, try to give the logic a little breathing room.
None of your logic physically interferes with any other logic. In this network, the pistons on the OR gate need space to extend. More space than necessary is much safer than not enough space.
None of your magnetic key switches are set to on/off when they should be directional.

The easiest way to troubleshoot a logic problem is to watch it in action. If you can pinpoint the source of failure, fixing it will be much easier. This will get easier as you understand how each logic gate is meant to work, assuming you haven't got it figured out already!