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

Logic help; picking up 'seeds' with a limit of 3

Archive: 12 posts


Hi, this question has probably been answered somewhere, but I can't find any help for this problem.

To explain in its simplest terms; I am trying to make a level where the player picks up keys (not physically being held by the sackboy, but in his inventory if you will) but I want the player to be limited to only being able to carry 3 at a time, only being able to pick up another once one or more keys has been dropped.

I figured I would use counters to track the keys the player is holding, so for example, picking up a key would add 1 to a counter. But i need to make it so that picking up a key triggers 1 of the 3 counters (for the inventories max limit). How can I make it that when I pick up a key, it fills a counter that is not full and once all 3 counters are full, that the player cannot pick up anymore? Atm I can only make a specific key trigger a specific counter but this might not work in the game, if another key has already triggered the counter. The level will feature a lot of keys (around 20-30) so I need to be able to track the player picking up and dropping them. I may be going the complete wrong way about this, I'm not sure.

I hope this makes sense and am grateful for any help offered or a link to a topic that answers this question already.
2011-12-17 16:23:00

Author:
Unknown User


You could use a selector with 4 outputs representing the amount of keys you have (0, 1, 2, 3). When you pick up a key, raise it one. When you drop it, lower it one. When you are at the last output (representing 3 keys) disable the 'pick up' logic.

This seemed like the easiest solution to me.

Alternatively, if you want to stick closer to your own plan:
You could use something that checks your 3 counters until it finds an inactive one, and then activate that one. For example, send the 'pick up' signal to 2 AND gates. Wire the first counter to the first AND gate, and a NOT gate which leads to the second AND gate. Wire the second AND gate to the first counter. Now, if the counter is inactive, it will activate half the second AND gate. When you pick up a key, it will activate the other half, activating the counter.
Wire the first AND gate to an exact copy of this piece of logic. Now, if the first counter is active, and you pick something up, the signal will be redirected to the second counter.
You could use a similar system for dropping the keys, but using the reset.
Note that the pick-up signal will have to be a pulse, otherwise it will redirect to the next counter with the same signal because it's still active when the counter half-activates the other AND gate.
2011-12-17 18:00:00

Author:
Elifia Kamigawa
Posts: 35


Wait, let me read that again... To make sure you can't have more than 3, with each key collected, you must add to a counter set to 3. If the output is on, prevent the logic from working. You can use a combiner hooked to a counter, pulsing in the negative will lower the amount on the counter...

Now you're saying that each key is different, so you have to make sure to remember which keys were found by a player ? Then this is totally different. I would use counters set to one, as you say, for each key (and I guess an impact sensor set to that key's tag would be way to collect those keys. Just make sure the key gets destroyed .1 second after the player hits them but not at the same time, that way the player has time to actually collect it.

We'll use powered batteries to add up the number of keys collected. Place a battery on a chip and set it to 25% and hook the output of the battery outside the chip. Now you have a switchable battery, just hook a 1-shot counter to the chip. The battery will be on when the counter is. Now you want the counter to go up when you collect a key. You can collect keys when you hit them AND your inventory isn't full. You need a AND gate. Connect it to the counter. Then place an impact sensor (set to allow touching) and connect it to the AND gate's first input. The second input will be for the inventory part.

Now you have to copy-paste the setup for every single key type you have in the whole level. If all 30 keys are different, it means 30 times this logic. If you have only 5 types of keys but have many of each type, well you can just have 5 times the logic. Then, you'll have to add up the signals from the batteries to test if it is under 75% (which means you don't have 3 keys yet. To add signals, you must use this setup :

Signal1-----NOT-----(+) Combiner-----(+) Combiner----------Splitter(+)-----NOT----------Result
Signal2--------------- (-) Combiner
Signal3-------------------------------------(-)Combiner

Invert the first signal, subtract the 2nd signal from it, then subtract the 3rd signal from it, and so on. Then pass the sigal through a splitter, and invert the positive output with a NOT gate. I know, this is very abstract, but look at the math which is done here. NOT gates do 100-signal. So this does :
(100 - A) - B - C and then if result is positive, 100-result
Without the discard logic, it does :
100 - (100 - A - B - C)
100 - 100 + A + B + C
A + B + C
This is addition in LBP.

Now why this splitter ?
With numbers, let's say you have 50, 30 and 40.
(100 - 50) - 30 - 40) = 50 - 30 - 40 = 20 - 40 = -20
Since the result is negative, the splitter discards it. It then does 100 - 0 = 100%
Now adding 50, 30 and 40 does 120% which is impossible in lBP. Without the discard logic, it would have done NOT(-20). But the NOT gate with negatives does -(100 -|signal|), where || means the positive form of the signal. -(100-20) = -80, which is far from the 120% we should have! Hence the discard logic.

Coming back to this inventory, you have to add the signals of every 25% battery. Then, test if the signal is 75% or not. To do this, you need a sequencer set to positional. Make it 4 stripes wide, and place a battery right on the 3rd line. Then hook the signal coming out of your adder logic to the sequencer. Then hook the battery from the sequencer to a NOT gate, and hook that signal to the AND gates placed before.

If hitting key and not allready 3 keys, set counter to 1 and add 25% to the inventory count. That's what it does.
Now you might want to set the logic so that you can actually destroy keys when they are collected. Then you need to place a tag on the player, place an OR gate, hook every single AND gate to it and connect it to the tag. When a key is found and collected, destroy the key wirelessly with an impact sensor. You might want to use hologram hitboxes for keys, just remember to set the destroyer on them to "include rigid connections".

I know, not that simple, but that's how I would do it.
2011-12-17 18:17:00

Author:
Unknown User


Both of these answers are great, thanks!

Haven't got time now, but I'll test them out and see what happens.

@ Pivottt: The keys themselves are all indentical, I will just have a lot of them. They all do the exact same thing.
2011-12-17 18:23:00

Author:
Unknown User


Ah, well at least it made me think ^^
Then it's way easier just using a single counter set to max 3, invert it and pass it through a AND gate, then connect the impact sensor to the AND gate's other input. Then hook the AND gate to a tag so you can wirelessly tell the key that you collected it so it can disappear.
2011-12-18 00:12:00

Author:
Unknown User


If you use a counter (max 3), don't you have the problem that when you reach full, it gives an on-signal, but if you then decrease it by one, it's still on, and you have to actually empty it all the way to turn it off? Because that's the reason I suggested a selector.2011-12-18 03:21:00

Author:
Elifia Kamigawa
Posts: 35


Wait, let me read that again... To make sure you can't have more than 3, with each key collected, you must add to a counter set to 3. If the output is on, prevent the logic from working. You can use a combiner hooked to a counter, pulsing in the negative will lower the amount on the counter...

Now you're saying that each key is different, so you have to make sure to remember which keys were found by a player ? Then this is totally different. I would use counters set to one, as you say, for each key (and I guess an impact sensor set to that key's tag would be way to collect those keys. Just make sure the key gets destroyed .1 second after the player hits them but not at the same time, that way the player has time to actually collect it.

We'll use powered batteries to add up the number of keys collected. Place a battery on a chip and set it to 25% and hook the output of the battery outside the chip. Now you have a switchable battery, just hook a 1-shot counter to the chip. The battery will be on when the counter is. Now you want the counter to go up when you collect a key. You can collect keys when you hit them AND your inventory isn't full. You need a AND gate. Connect it to the counter. Then place an impact sensor (set to allow touching) and connect it to the AND gate's first input. The second input will be for the inventory part.

Now you have to copy-paste the setup for every single key type you have in the whole level. If all 30 keys are different, it means 30 times this logic. If you have only 5 types of keys but have many of each type, well you can just have 5 times the logic. Then, you'll have to add up the signals from the batteries to test if it is under 75% (which means you don't have 3 keys yet. To add signals, you must use this setup :

Signal1-----NOT-----(+) Combiner-----(+) Combiner----------Splitter(+)-----NOT----------Result
Signal2--------------- (-) Combiner
Signal3-------------------------------------(-)Combiner

Invert the first signal, subtract the 2nd signal from it, then subtract the 3rd signal from it, and so on. Then pass the sigal through a splitter, and invert the positive output with a NOT gate. I know, this is very abstract, but look at the math which is done here. NOT gates do 100-signal. So this does :
(100 - A) - B - C and then if result is positive, 100-result
Without the discard logic, it does :
100 - (100 - A - B - C)
100 - 100 + A + B + C
A + B + C
This is addition in LBP.

Now why this splitter ?
With numbers, let's say you have 50, 30 and 40.
(100 - 50) - 30 - 40) = 50 - 30 - 40 = 20 - 40 = -20
Since the result is negative, the splitter discards it. It then does 100 - 0 = 100%
Now adding 50, 30 and 40 does 120% which is impossible in lBP. Without the discard logic, it would have done NOT(-20). But the NOT gate with negatives does -(100 -|signal|), where || means the positive form of the signal. -(100-20) = -80, which is far from the 120% we should have! Hence the discard logic.

Coming back to this inventory, you have to add the signals of every 25% battery. Then, test if the signal is 75% or not. To do this, you need a sequencer set to positional. Make it 4 stripes wide, and place a battery right on the 3rd line. Then hook the signal coming out of your adder logic to the sequencer. Then hook the battery from the sequencer to a NOT gate, and hook that signal to the AND gates placed before.

If hitting key and not allready 3 keys, set counter to 1 and add 25% to the inventory count. That's what it does.
Now you might want to set the logic so that you can actually destroy keys when they are collected. Then you need to place a tag on the player, place an OR gate, hook every single AND gate to it and connect it to the tag. When a key is found and collected, destroy the key wirelessly with an impact sensor. You might want to use hologram hitboxes for keys, just remember to set the destroyer on them to "include rigid connections".

I know, not that simple, but that's how I would do it.

You just earned a heart from me and I've never seen anything you've ever made.
I'll do it when I'm un-grounded...
2011-12-18 05:07:00

Author:
Speedynutty68
Posts: 1614


Although I've called them keys, that's not exactly what they are. In the concept of the level, they are like floating lights. By pressing L1, button prompts appear above the lights that you are in range of then you press the corresponding button, the light moves to the player (as if they were absorbing the light) then adds 1 to your inventory.

I dunno if I can still do it with a hit detection cos of this :S


Wait, let me read that again... To make sure you can't have more than 3, with each key collected, you must add to a counter set to 3. If the output is on, prevent the logic from working. You can use a combiner hooked to a counter, pulsing in the negative will lower the amount on the counter...

That seems like a nice simple way of doing what I want. How do I make it that collecting each 'key' adds 1 to the counter? I've been testing it with buttons, just to test the logic, but the combiner can only have 1 positive input and 1 negative and seeing as I am gonna have around 30 keys, how do I make it work? are OR gates the answer? You keep mentioning pulses, is there are way to send out a signal or something? :S

Sorry, I'm a bit of a LBP2 logic noob.
2011-12-18 09:44:00

Author:
Unknown User


Pulsing is when a signal only exists for a moment. For example, use a counter (max 1) with its output wired to its own Reset. When you activate the counter, it will immediately turn itself off again, 'pulsing' a signal to whatever else it's connected to.
As for the combiner, just send a signal into the + whenever you pick up a key, and send a signal to the - when you drop one. I don't think you'd need an OR gate if all the keys are identical anyways.
2011-12-18 16:22:00

Author:
Elifia Kamigawa
Posts: 35


Yeah, I think you are right about counters being ON until you fully reset them. Then you need to test using the analogue signal instead of the digital : use a sequencer set to positional, 3 stripes, then place a battery at the end. If the counter is full, the battery will be on.

You can also use a selector, prevent it from looping and so on, but I don't like to do this, as it's slow to modify if you change your mind about the max amount of keys and so on.
2011-12-18 18:16:00

Author:
Unknown User


Hmm, yeah, the counter+sequencer would work. And is indeed easier to adjust than the selector. So forget the selector, counter+sequencer is better 2011-12-19 02:33:00

Author:
Elifia Kamigawa
Posts: 35


Yeah, I think you are right about counters being ON until you fully reset them. Then you need to test using the analogue signal instead of the digital : use a sequencer set to positional, 3 stripes, then place a battery at the end. If the counter is full, the battery will be on.

You can also use a selector, prevent it from looping and so on, but I don't like to do this, as it's slow to modify if you change your mind about the max amount of keys and so on.

Can you explain more in depth how I would set up the counters and sequencer together?

EDIT: Scratch that, think I get it now, thanks.
2011-12-19 18:04: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.