Part 1: Tutorial: 24 Hour Digital display | LBP Union
This tutorial covers how to create a digital timer that can be set by the player in play mode. You will need the basic count up and count down setups from part 1. You also might want to reread that tutorial, so you understand how the basic setups work. Saying that this tutorial is a bit more complex than part 1 is definitely an understatement so I'll make a video tutorial. This should work in LBP2, LBPVita, and LBP3.
I was originally going to make a full tutorial, but it was too long and possibly hard to understand. This is going to be more of a logic showcase.
Some games allow the player to use a timer. In Animal Crossing, you can use one to time how many fish and bugs you can catch in a certain amount of time. The game only allows you to choose between 3, 5, and 10 minutes, but in LBP you can remake it so the player can choose any time limit. This is one of the great things about LBP. You can recreate games and also improve on that game’s features.
You can also recreate electronics in real life that use timers. Most ovens and microwaves come with a built-in timer. You can set the timer on your oven so you know when your food should be ready and microwaves only cook food for however long you set the timer. I am going to be recreating the timer on my digital watch.
How I Created a Digital Timer
I started with the countdown digital display from part 1.
I was trying to make the circuit board bigger so I could have more room to work, but my game started lagging whenever I dragged a wire or gadget.
I found a trick to eliminate wire lag on LBPCentral that was posted by amiel445566. If you place an expandable gadget like a selector, timer, or counter on the edge of the circuit board and then resize the circuit board, it should get super big and break wire pathing. Place a gadget at the edges of the microchip so it doesn’t revert to normal. If you’re able to drag a wire around without lag, then you did it right. But if your game gets even laggier, then rewind and change the size of the expandable gadget and place it somewhere else. Then try resizing it again. Keep doing this until you don’t get any lag.
After I got that sorted out, I copy and pasted the selectors and put each of them into a microchip. I wired each of the new selector outputs to the corresponding inputs of the selectors from the initial setup. I used two sets of selectors so the current time and player set time are separate. I used AND gates to limit the max value to 23:59:59 like I did in part 1. I put each selector in a microchip so the player set time could be turned on and off. Later I wired an OR gate to the microchips. The player set time should be displayed when the player is in adjust mode or when the time is at 0 seconds and loop is on.
Then I started working on the functions of the digital timer. I based it off my real life digital watch which has the following functions:
If you press it once, the timer runs. If you press it again, the timer pauses.
If you press it once then you're able to change the set time. You press it again to confirm that time.
While in adjust mode, you can switch between changing the seconds, minutes, and hours.
While in adjust mode, you can set whether or not you want the timer to loop when it reaches 0 seconds.
When the timer is paused, you can reset it to whatever time was set.
I recreated all of this except for the reset button. In my logic setup, the adjust button does the same thing if pressed twice.
For the start/stop and adjust buttons I used controllinator outputs wired to 2 port selectors. I used a 3 port selector for the mode button.
I didn't wire the controllinator outputs directly to the cycle input of the selectors because I didn't want the player to press these buttons in the wrong mode. For example, you shouldn't be able to start and stop the timer while in adjust mode. So instead I wired the controllinator buttons to flow gates.
A flow gate, also called an if/then gate, is a circuit node inside of a microchip. In LBP3 you could probably use a circuit node by itself since it has 2 inputs, but I like the way microchips look on circuit boards better. If the microchip is on, then the signal will flow through.
In my setup, the x button should only be detected while the player is not in adjust mode. I did this by wiring the second output of the adjust mode selector to the activate input of the microchip. This means that the start/stop button can only be pressed if the set time has been confirmed.
The adjust button being pressed should only be detected if the timer is stopped. So I wired the 2nd output of the start/stop selector to the circle button's flow gate.
The mode should only be able to change between seconds, minutes, and hours when the player is in adjust mode. I wired the 1st input of the adjust mode selector to the square button flow gate.
The R1 and L1 buttons were used to change the time. I put these in 3 separate flow gates. The mode selector outputs were wired to each of these flow gates.
The start/stop function was definitely the easiest to make. I wired the 1st input to the microchips containing direction combiners and the start/stop input of the timer. Then I wired the 2nd input to the reset input of the timer.
The hardest part to make was the adjust mode. I made the selectors for the seconds first. I wired the R1 output from the flow gate into a flow gate containing the 1st input of the 1s digit selector. I wired that flow gate to the direction combiner's positive input. This means that when the time is being increased, the 0 in the 1s digit causes the tens digit to increase. I also used a flow gate to decrease the time.
When I tested it, the digits weren't changing correctly when increasing. It went from 0 to 11 and 20 to 31. I realized that I needed to use a Set/Reset switch.
A set/reset switch is a counter set to 1. It's like a one-shot switch, except both the increment and reset inputs are used. Its purpose is to detect if a condition has been met. You might've seen one in fall damage logic. When making fall damage, you have to detect Sackboy's speed and if he hits the ground. Sackboy can't be falling at a high speed and on the ground at the same time. So instead of wiring the speed sensor and impact sensor directly to the AND gate, you wire the speed sensor to a SR switch wired to the AND gate. Now you are detecting if Sackboy has reached a high speed and if he is touching the ground. The difference between wiring the sensor directly and using a SR switch is like saying "Sackboy IS falling at a high speed" vs. "Sackboy HAS reached a high speed". The SR switch is reset when Sackboy starts falling again so he can take damage multiple times.
In my digital timer's adjust mode, I was detecting if the 1s digit has reached 0 and if R1 is being pressed. If this condition is true, then the 0 in the 1s digit will cause the tens digit to increase. I wired the 1st input of the 1s digit selector to the set input of the set/reset switch. I wired the 1st input of the 10s digit selector to the reset input. Then I wired the Set/Reset switch and the R1 output from the flow gate to an AND gate. The AND gate was wired to the flow gate containing the 1st input of the 1s digit selector.
After that, everything was smooth sailing and I went on to create the switching modes function. First I copied and pasted the selectors over the other selectors so I didn't have to do much wiring. I only wired the R1 and L1 outputs and the first output of the adjust mode selector.
Then I made it so when the seconds, minutes, or hours were active they would flash on and off. I did this with an opacity tweaker but I also made a LBP2/Vita version with in/out movers. The opacity tweaker was set to 0%, 0.0 sec, and include rigid connections. The first in/out mover was set to move in once and the 2nd one was set to move out. In LBP2/Vita you would have to put the numbers behind a background. I wired a 0.3 sec timer to the cycle input of a selector. I used a NOT gate to reset the timer when the selected digits weren't active. I used invisible sticker panel to glue each group of digits together.
I created the loop function by using a 6 port AND gate. When all 6 digits were 0, then the timer would either stop or loop. The player was able to turn the function on and off by using the R2 button. The button output was in the same flow gate as the square button since both signals can only be detected in adjust mode. I also made the timer beep when it reached 0 seconds.
The timer is finished, check it out here:
I'll make a video tutorial for part 1 and 2 of the digital display tutorial. I plan to do more with this digital display in the future but for now I want to do tutorials on other things. If I do continue the digital display, I'll create:
A stopwatch that can save up to 10 previous times
A clock and 3 alarms that can be set by the player
A setup that can do all of this with one single display
I probably won't be able to make any video tutorials until the summer when I have more time. My next few tutorials won't be as in depth with logic. I have 2 tutorials on visuals and physics planned. My next logic tutorial will be simpler.
Wow, this is very in-depth, and the design is so clean. Impressive work once again, bravo!