Jump to content



Photo
- - - - -

Rosve's Fading Lights System

scripting Lights Fading

  • Please log in to reply
8 replies to this topic

#1 rosve

rosve

    :)

  • VIP
  • 1,179 posts
  • Location:Always travelling around the world

  • Flag: Sweden

  • Favorite Pinball: Funhouse, Faces, Starship Troopers



Posted 12 November 2012 - 06:12 PM

Posted Image

File Name: Rosve's Fading Lights System
File Submitter: rosve
File Submitted: 12 Nov 2012
File Category: VP Development Resources

Here is a demo table and a description on how to use my fading lights code.
This system is specially made to make it easy to create really good looking lights on EM and original tables. It gives you much more control over the lights than the standard VP lights.

I have been using this code in tables like Starship Troopers, SPACE:1999, Red Dwarf, SkyRocket and many more.


---------------------------------------------------------------------------------
MANUAL (also included in the download)

- Add the Fading Lights code to the end of the table script.

- Create a new timer and name it "FLTimer". Set the interval to 33 and Enable it.

- Create a light somewhere besides the table and name it "DummyLight"

- Create 2 new collections, "L1" and "L2". Put the DummyLight in both collections.

- Make 3 playfield images with the Lights Off, Lights Halfe On, Lights Full On.

- Add all the lights needed on the playfield (light1 - 14 on the demo table).
On all the lights, Set the Off Image to the 'Lights Off' image. Set the On Image to the 'Lights Halfe On' image.

- Enter the lights into the "L1" collection.

- Copy and paste all the lights so that you get two lights in the same position.
On all the new lights, Set the Off Image to the 'Lights Halfe On' image. Set the On Image to the 'Lights Full On' image.

- Enter the new lights into the "L2" collection.

- set the variable "FLMaxLight" (3rd line in the fading lights code) to the number of lights that you made. 14 in the demo table.


YOU ARE NOW READY TO USE THE FADING LIGHTS.
-------------------------------------------

- Insert this line in the table _Init sub to initialize the fading lights system,
FLFlash 1, FLMaxLight, 0, 1, 4, 0



Use the following instructions to set a light (or a group of lights) ON, OFF or FLASHING


FLSetOn light1, light2, delay
- Light number from Light1 to Light 2 is set to ON.
- If the Delay is larger than 0 the code will wait the specified number of timer intervals before setting the lights ON.


FLSetOff light1, light2, delay
- Light number from Light1 to Light 2 is set to OFF.
- If the Delay is larger than 0 the code will wait the specified number of timer intervals before setting the lights OFF.



FLFlash light1, light2, repeats, on_duration, off_duration, delay
- Light number from Light1 to Light 2 is set to FLASHING.
- repeats is how many times the lights shall flash, 999 is continous flashing.
- on_duration and off_duration specifies how many timer intervals the light shall stay on and off in the flashing cycle.
- If the Delay is larger than 0 the code will wait the specified number of timer intervals before setting the lights to FLASHING.




EXAMPLES
--------

Set light 4 on.
FLSetOn 4, 4, 0

Set light 3 to 6 on after a small delay,
FLSetOn 3, 6, 10

Set light 4 off.
FLSetOff 4, 4, 0

Flash light 6 three times,
FLFlash 6, 6, 2, 2, 4, 0

Flash all light one time
FLFlash 1, FLMaxLight, 0, 1, 4, 0

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

To use it with VPM you also need this code snippet to read the lamp states.

Dim NewState(200)
Dim OldState(200)

FLTimer.Interval = 21
LampTimer.Interval = 10
LampTimer.Enabled = 1

Sub SetFlasher(nr, value)
NewState(nr) = abs(value)
End Sub

Sub LampTimer_Timer()
	 Dim chgLamp, num, chg, ii
	 chgLamp = Controller.ChangedLamps
	 If Not IsEmpty(chgLamp) Then
		 For ii = 0 To UBound(chgLamp) ' **UPDATE LAMP STATES ***
			 If chgLamp(ii, 1)=0 then
			 FLSetOff chgLamp(ii, 0), chgLamp(ii, 0), 0
			 else
			 FLSetOn chgLamp(ii, 0), chgLamp(ii, 0), 0
			 end if
		 Next
	 End If
	 For ii=81 to 88 ' ******** FLASHER NUMBERS *************
	 If NewState(ii) <> OldState(ii) then
		 OldState(ii)=NewState(ii)
		 If NewState(ii)=0 then
			 FLSetOff ii, ii. 0
		 else
			 FLSetOn ii, ii, 0
		 end if
	 end if
	 Next
End Sub

Solenoid controlled flasher states are read like this,
SolCallBack(25)="SetFlasher 81, "		 'red x 4
SolCallBack(26)="SetFlasher 82, "	 'yellow x 4
SolCallBack(27)="SetFlasher 83, "		 'green x 4
SolCallBack(28)="SetFlasher 84, "		 'blue x 4
SolCallBack(29)="SolWarrior"				 'flash multiball x 4
SolCallBack(30)="SetFlasher 86, "		 'left ramp x 4
SolCallBack(31)="SetFlasher 87, "		 'right ramp x 4
SolCallBack(32)="SetFlasher 88, "				 'pops x 2

Click here to download this file

#2 oldskoolgamer

oldskoolgamer

    VP Graphic Artist

  • VIP
  • 643 posts
  • Location:USA

  • Flag: United States of America

  • Favorite Pinball: Safe Cracker

Posted 12 November 2012 - 06:22 PM

Wow now thats cool Thanks Rosve! Playing with it now :)
 Posted Image  Posted Image Posted ImagePosted Image Posted Image Posted ImagePosted ImagePosted Image

#3 Aaron James

Aaron James

    <<< Grand Champion >>>

  • VIP
  • 1,408 posts
  • Location:Shelby Township, Michigan

  • Flag: United States of America

  • Favorite Pinball: Docking Complete...Negative...You Must Redock...Redock Now!



Posted 12 November 2012 - 06:25 PM

Wow...gonna have to look into this one !

vpsig.jpg


#4 faralos

faralos

    VPF Veteran

  • Members
  • PipPipPipPipPipPip
  • 7,838 posts
  • Location:Eastern Pa,USA

  • Flag: United States of America

  • Favorite Pinball: Flash (Williams) 1979, Flash2 Updated




  • Trophies:

Posted 12 November 2012 - 06:25 PM

Kewl but why is some of your coding remmed out?
I will try to learn this for future pins if I can get it to work properly
"Don’t let the noise of others’ opinions drown out your own inner voice.
And most important, have the courage to follow your heart and intuition.”
----Steve Jobs


#5 rosve

rosve

    :)

  • VIP
  • 1,179 posts
  • Location:Always travelling around the world

  • Flag: Sweden

  • Favorite Pinball: Funhouse, Faces, Starship Troopers



Posted 12 November 2012 - 06:27 PM

Kewl but why is some of your coding remmed out?
I will try to learn this for future pins if I can get it to work properly


It's not, Don't know why it looks that way???

#6 oldskoolgamer

oldskoolgamer

    VP Graphic Artist

  • VIP
  • 643 posts
  • Location:USA

  • Flag: United States of America

  • Favorite Pinball: Safe Cracker

Posted 12 November 2012 - 06:30 PM

doesn't look that way for me. Only remarks are:

'*********************************************************************************************
'***************** FADING LIGHTS CODE ***************************
'***************** ROSVE ***************************
'*********************************************************************************************

and

' 1=command --> 0=set off 1=set on 2=flash 99=no change
' 2=state
' 3=repeats 999=continous
' 4=on duration
' 5=off duration
' 6=on dur mem
' 7=off dur mem
' 8=start delay

everything else is not remarked out...not sure what you are seeing faralos
 Posted Image  Posted Image Posted ImagePosted Image Posted Image Posted ImagePosted ImagePosted Image

#7 faralos

faralos

    VPF Veteran

  • Members
  • PipPipPipPipPipPip
  • 7,838 posts
  • Location:Eastern Pa,USA

  • Flag: United States of America

  • Favorite Pinball: Flash (Williams) 1979, Flash2 Updated




  • Trophies:

Posted 12 November 2012 - 06:32 PM

in the post here it is in green I just thought that it was remmed out in the coding
"Don’t let the noise of others’ opinions drown out your own inner voice.
And most important, have the courage to follow your heart and intuition.”
----Steve Jobs


#8 oldskoolgamer

oldskoolgamer

    VP Graphic Artist

  • VIP
  • 643 posts
  • Location:USA

  • Flag: United States of America

  • Favorite Pinball: Safe Cracker

Posted 12 November 2012 - 06:34 PM

ahh I follow you :) its not like that when you download the real table file.
 Posted Image  Posted Image Posted ImagePosted Image Posted Image Posted ImagePosted ImagePosted Image

#9 Aurich

Aurich

    Enthusiast

  • Members
  • PipPipPip
  • 306 posts
  • Location:Southern California

  • Flag: ---------

  • Favorite Pinball: Scared Stiff

Posted 12 November 2012 - 07:00 PM

in the post here it is in green I just thought that it was remmed out in the coding


It looks like the code parsing in the forum is making anything between each set of ' green, rather than a line by line basis.





Also tagged with one or more of these keywords: scripting, Lights, Fading