Support File FP SLSeq: Enhancing and customizing the default Light Sequencer with code

Future Pinball

Wecoc

Pinball Wizard
Joined
Dec 7, 2021
Messages
65
Reaction score
102
Points
40
Favorite Pinball Machine
Cirqus Voltaire
Script Light Sequencer (SLSeq) is a Future Pinball Script that recreates the default Light Sequencer, but on an open source and customizable VBScript code. The script is not meant to overwrite the default Sequencer, but to use it side by side when the default one falls short. They're therefore compatible, and for the most part they work in a very similar way.

SLSeq is also compatible with BAM and FizX. No credits are required.
Current version: 2.00

----------------------------------------

[7th November 2023]: New version 2.00 available! The topic still includes both, but I highly recommend using the last version.
The new version removes the limit of 500 lights per sequencer and the upper bound of 50 pending effects in queue. It also includes new functionalities for BAM, that allow more complex effects with multicolour lights, or lights that can be turned on/off smoothly. Check the new demo for more details!

----------------------------------------

Properties and Enhancements​

- The code is open and can be further modified according to your table.
- The default limitation of only one light per each 15x15 millimeter cell is no longer applied.
- You can define the rect where the sequencer applies, instead of always using the full table / translite. With this, you can have more control on the effect applied on "light grids" or a mini-playfield. (See for example the 5x5 light grid in Jack Bot).
- The "Virtual Center" coordinates can be changed dynamically.
- Custom Random-like and List Order effects are easier to implement using a For Loop.
- Multiple Sequencers can be reduced to only one Editor Object (Timer).
- It's possible to control the state cache (preservation of the original light states) when the queue ends.
- It's possible to control if the effect is ignored on lights that are already lit.
- You can create custom light effects using a grayscale image as a mask.
- [Advanced] You can create custom light effects with "variable tail lengths" using an additional mask.

Instructions​

I included a Manual on the demo, but here's a summary on how this works.
First, import the two VBS scripts to your table's code.

Code:
ExecuteGlobal LoadExternalScript("LightScriptEffects.vbs")
ExecuteGlobal LoadExternalScript("LightScriptSequencer.vbs")

LightScriptEffects.vbs is used to define the effects. You can make custom ones at the end of this code, or in your table's code after importing it.
LightScriptSequencer.vbs controls how the sequencer works under the hood.

These two files are all you need on your table from the demo, everything else was made as a helper.

Then, define a variable for your sequencer, add each Light on the Sequencer, and define which Timer it uses. Usually, the Timer will always be enabled.

Code:
Dim LightSeq : Set LightSeq = New LightScriptSequencer
LightSeq.Name = "LightSeq"

LightSeq.SetLight(Bumper1)
LightSeq.SetLight(Bumper2)
LightSeq.SetLight(RampFlasher)
'(...)

LightSeq.SetTimer(LightSeqTimer)
Sub LightSeqTimer_Expired() : LightSeq.Timer_Expired() : End Sub

Finally, you can use it as always, with Play, StopPlay, etc.

Because of VBScript limitations, you will have to define the number of arguments of Play with an extra digit on its name, in those cases where not all parameters are defined.

Code:
Sub SetLightsForAttractMode
  LightSeq.Play3 ScriptSeqUpOn, 50, 2
  LightSeq.Play3 ScriptSeqDownOn, 50, 2
  LightSeq.Play2 ScriptSeqStripe1VertOn, 50
End Sub

You will find more details in the Manual.
 

Attachments

  • Script Light Sequencer.zip
    1.3 MB · Views: 16
  • Script Light Sequencer 2.0.zip
    1.3 MB · Views: 1
Last edited:
and to obtain rotating color quarters, with change of hues (like LEDs) ? like attract mode mpf

rr.jpg


1:17
 
Last edited:
Excellent tutorial, and quite helpful. Sure a lot of new and exciting stuff coming out recently. Most people here may not know this, but Black also wrote the Lightseg system for vp first, before he developed FP. I have used this since 2004 (starting with VP) and it's very powerful and honestly quite surprised how little it is used.
I can add to this that you should be able to run 2 seperate lightseqs at the same time, with different patterns assigned, to get some pretty amazing lighting routines. I haven't seen this done in fp, but should be very easy to do, and the same person did write both the vp and fp versions. Even if it doesn't work, the code above used as a double lightseq should work. My old, old, old vp game Trigon, used double lightseqs, so you can grab the code and port it over easy enough, because it's pretty much the same code with FP.

Trigon is here: https://shiva.pinballnirvana.com/files/index.php?twg_album=Visual+Pinball/trigon
the lightseg code is in trigon_lights_sound.vps, there's quite a few of them

here's a code example from Trigon so you can see. 2 lightsegs working at the same time. I believe when the lights intersected, lightseg1 had the priority over lightseg2
Code:
           AllLightSeqOff():LightSeq1.Play SeqAllOff:LightSeq2.Play SeqAllOff          
            For lc=1 to 3
                LightSeq1.UpdateInterval =10:LightSeq2.UpdateInterval=10:LightSeq1.Play SeqFanLeftUpOn,10,1:LightSeq2.Play SeqFanRightUpOn,10,1:LightSeq1.Play SeqFanLeftDownOn,10,1:LightSeq2.Play SeqFanRightDownOn,10,1
            Next
LightSeq1 and 2 would use the exact same lights listed if you were using fp in the light list manager (all pf lights in the table) but the lightseq routines are set to opposite each other, one uses the left fan, the other uses the right fan.
 
@fastdraw
Those effects are next level! oO As I said in a recent post, it's possible to change a light's color dynamically, but it has to change its state lit/unlit to update, it's not completely "automatic", so I don't know if this is doable.

[Note] I should make clear this last sentence is only true on vanilla FP, but BAM's light functions allow breaking that limitation. SLSeq 2.0 now uses those functions for more advanced color effects.

You can make all the lights of a SLSeq change to a specific color, even set it by coordinates, but update them through the effect is a bit too much.

Code:
' Change the Lit Colour of all the lights in LightSeq, single color (purple)
Dim i : For i = 0 To LightSeq.Length
    LightSeq.Data(i).LitColour = RGB(255, 32, 192)
Next

' Change the Lit Colour of all the lights in LightSeq, vertical green-yellow-red gradient
Dim CurrentRed, CurrentGreen
Dim i : For i = 0 To LightSeq.Length
    ' Use the Y parameter of the light to set the Red value
    CurrentRed = Int((LightSeq.Data(i).Y / 516) * 255)
    If (CurrentRed < 0)   Then CurrentRed = 0
    If (CurrentRed > 255) Then CurrentRed = 255
    ' Use the "inverse" of the Y parameter of the light to set the Green value
    CurrentGreen = Int(((1032 - (LightSeq.Data(i).Y / 516)) * 255))
    If (CurrentGreen < 0)   Then CurrentGreen = 0
    If (CurrentGreen > 255) Then CurrentGreen = 255
   LightSeq.Data(i).LitColour = RGB(CurrentRed, CurrentGreen, 0)
Next

About the rotating color "wheel", it has little to do with the classic way Sequencers work, also in my script, since the lights are always turned on. If you use overlapping lights (for each color) however, which I would only recommend with a few lights/colors, you could use a default Sequencer for each light color, a Timer, and a counter, like this.

Code:
Sub WheelTimer_Expired()
    Select Case(WheelCounter)
        Case 0: LightSeqMagenta.Play  SeqClockRightOn, 180
        Case 1: LightSeqBlue.Play     SeqClockRightOn, 180
        Case 2: LightSeqYellow.Play   SeqClockRightOn, 180
        Case 3: LightSeqGreen.Play    SeqClockRightOn, 180
        Case 4: LightSeqOrange.Play   SeqClockRightOn, 180
        Case 5: LightSeqBrown.Play    SeqClockRightOn, 180
    End Select
    WheelCounter = (WheelCounter + 1) Mod 6
End Sub

Even without hue changing, there are of course some advanced effects both the default Sequencer and my script are not capable of, at least without setting a custom pattern "cell by cell" in the grid; that would be those cases where lights lit/unlit multiple times in the same effect (like that bouncing effect in the start of the video). It's still better than doing it light by light, though. For that specific effect, we would be talking about only around 10 cells.

I once saw another example some time ago where basically there was an invisible "point" that moved around the table and lights nearby turned on, making an effect that looked like if the ball was being searched by a focus light you had to avoid. These kinds of things have nothing to do with Light Sequencers and would require a different script.

@shiva
Yep, two (or more) SLSeq can be applied to the same lights simultaneously for overlapping effects. I want to encourage other scripters to expand on my code; use it as a base if you want, get crazy with it :mrhappy: Who knows what great results may be achieved with this! :-)
 
Last edited:
If you can get Trigon to work (It's quite broken now by all the VP changes, but VP7 works sort of, though the timing got broken) you can see for yourself. There were 4 lighsegs in there, and about 100 routines or so. There was a simple searchlight effect used for multiball, a great corkscrew effect etc. If people search the code, should be very doable using a combination of 2 lightsegs and you can add the custom code posted here to make it even better.
Again, great work Wecoc. Have to add this support to fpxEngine, stuff you can do with lightseg for effects is amazing.
 
If you ever use a BAM mini playfield to move and relocate lights / inserts that are part of a miniplayfield...

...keep in mind that the Light Sequencer uses the x and y position "within" the playfield area. The Light Sequencer won't work with positions outside of that.

So in my case for Silent Hill, I use BAM mini playfields to relocate and position portions of different sections of the playfield and its lights for different "Scenes" of gameplay. Most of these things are located outside the playfield, and then positioned within the playfield (using a mini playfield) when they are used. Since the Light Seqencer only works within the main playfield's x and y position area... those lights positioned outside of the main playfield can't be used with them.

I found that out the hard way.
 
Interesting… Makes sense. This isn't true anymore for SLSeq, so I guess it's another possible use case for this script.

Let's say you defined some lights outside the playfield. Your playfield's "corner" points would be (0, 0), (516, 0), (0, 1068) and (516, 1068) respectively, for example. By default, everything outside these bounds won't work on the sequencer, including the SLSeq. You may have your "alternative" lights set -1000px to the left, being the new coordinates (-1000, 0), (-484, 0), (-1000, 1068), (-484, 1068).

To fix this, you would simply use:
Code:
LightSeq.SetRect -1000, 0, -484, 1068
LightSeq.SetVirtualCenter -742, 534

That being said, it still sounds like a bug in BAM's mini playfield integration, and it may be possible to fix it for default Sequencers on a future BAM version.
 
It's possible.... it could only be the gui item of the Light Sequencer position that won't translate in a mini-playfield.

So if that can be defined in script... maybe it will work... or if that can be changed in script dynamically it can work.
 
That being said, it still sounds like a bug in BAM's mini playfield integration, and it may be possible to fix it for default Sequencers on a future BAM version.

I wouldn't say it's a bug, as much as I think there are limitations of what can be repositioned in a miniplayfield. Most things work great, and its my favorite tool to use by far... but I know for certain that Gas Segment displays can't be relocated.
 
Very interesting!!
Keep up the great work!!
 
@fastdraw
Wecoc said:
(...) it's possible to change a light's color dynamically, but it has to change its state lit/unlit to update, it's not completely "automatic", so I don't know if this is doable
This should surprise nobody, but I just checked it to be sure, and that statement is not true with BAM.
BAM has an alternative "external" call to change light colors, which updates instantly.

Code:
xBAM.CreateAllExt()
Sub Timer_Expired()
    ' Change the light's color to a completely random value
    ShootAgainLightExt.SetLitColor Int(rnd()*255), Int(rnd()*255), Int(rnd()*255)
End Sub

This and other BAM specific properties may allow breaking even more the limits of the default Light Sequencers.
I don't know exactly how to implement any of that, in my code I didn't consider color changes at all, but in the future I may make a third external code, completely optional, that includes some BAM-related stuff ;)
 
I've once read somewhere that you could use image list to give that pulsing effect instead of on/off. But that would be even trickier to get I suppose albeit looking really cool.

Something VPX get perfectly if you ask me.
 
@Wecoc

You can take a look at F-14 (PinEvent ) for some examples of using BAM for changing light colours dynamically during gameplay, and also look at RetroFlair BAM Edition (PinEvent) for examples of using BAM for color cycling of GI lights as well.






Man, whenever I look at my older videos, it makes me want to updsate those table "right now" as there is so much I can do now compared to back then :)
 
So much to do, so little time, right? :D
 
I updated the original post with a new version 2.00!

Most limitations (number of lights, number of effects in queue) were removed and some new BAM properties are available, although the script can still be used without BAM. These script sequencers now support BAM multicolour effects of different kinds, and you can do things like turn the lights off smoothly (changing their brightness slowly until they are turned off) or things like that.

Many light effects from this table are now available with this script. To recreate those without a SLSeq you would need to apply the changes in every light independently. Even if this may still be the case for the most complex cases (like the one mentioned by fastdraw with many colors updating in the same effect), other many multicolour effects can now be applied with just a few lines of code.


See for example the white arc effect over red lights in minute 4:32 or the green/yellow roulette-like effect in minute 7:05. Check also the smooth fade out in 7:11, as commented before. The new demo includes examples that may help recreate these kinds of effects.
 
General chit-chat
Help Users
You can interact with the ChatGPT Bot in any Chat Room and there is a dedicated room. The command is /ai followed by a space and then your ? or inquiry.
ie: /ai What is a EM Pinball Machine?
  • No one is chatting at the moment.
      Chat Bot Mibs Chat Bot Mibs: Flipper Hermann has left the room.
      Back
      Top