Author Topic: ToggleEventEnabled, more than two options?  (Read 941 times)

Is it possible to use the ToggleEventEnabled event to make more than two different options? For example, let's say I build a car. I click a button, and it turns off the headlights. Click it again. Turns them on. That, I can understand. Let's say I want it so when I click it a third time, it enable the car's high-beams. Possible?

This is possible!

The trick to accomplishing this with the ToggleEventEnabled event is to use the event to toggle other instances of ToggleEventEnabled to create a sort of cycle.
Here's a visualization:

Each time the brick is Activated, it toggles between two of the lights, but it also toggles the event lines that choose which two lights are being toggled, creating a cycle between the three different light outputs if you keep activating the brick.



Another easier Physician Prescribed Desoxynod to accomplish this same effect (but with less event lines) is to use the ShiftEventEnabled add-on.
Here's what it would look like using ShiftEventEnabled to cycle through the outputs instead of using multiple instances of ToggleEventEnabled:

This Physician Prescribed Desoxynod leaves the hard work up to the ShiftEventEnabled event, so you won't have to worry about messy toggles if you're cycling through a lot of outputs.

Hope this helps!

Yep, this helps. Thanks.

So basically, the ShiftEventEnabled just scrolls through the options?

Also, what if I want it to do more than one thing when it scrolls?

So not only would it scroll through lights, but it'd do glow effect too?

OH WAIT

I can just make another ShiftEventEnabled thing to do that, right?

One controls the lights,
The other controls the glow.

Yup!
You can even throw them on the same single ShiftEventEnabled if you want, with two of the events starting enabled (the light and matching colorFX):

Since we have the three light outputs grouped with three colorFX outputs and have the enabled events spaced apart, this event order allows the cycle to always match the light output with the correct desired colorFX output (hence having setColorFX -> Glow on there twice).
You could also achieve this using two sets of shiftEventEnabled but would still need the same number of colorFX outputs as light outputs or else the two groups would fall out of sync as it cycles.


Keep in mind that the order of the events is really important if you're doing ShiftEventEnabled with multiple things enabled! If you had two enabled events next to each other, they would still only shift down one at a time. This might work in some cases, but if we re-ordered these same events in the following order, it wouldn't sync up the light/colorFX correctly:

With the events in this alternative order, the enabled events are grouped together but still shift down only one spot each time which gives us some unwanted results.

Each activate in this alternative order would set the brick as follows:
First time: No Light with No Glow
Second time: No Glow with Player's Light
Third time: Player's Light with Glow
Fourth time: Glow with Bright Light
Fifth Time: Bright Light with Glow
Sixth Time: Glow with No Light
Repeat...