BAM Can you get a the LightExt object from a Light object?

SpacePirateScott

Pinball Wizard
Joined
Jan 11, 2024
Messages
54
Reaction score
38
Points
24
Favorite Pinball Machine
Scared Stiff
I hsbr a sub routine where a light object is passed in and I would like to find the associated LightExt object. Is this possible?

For example:

Sub SetBrightness(byref light, newBrightness)

XBam.GetLightEx(light).Brightness = newBrightness '<--- I was hoping for something like this.

End Sub

Thanks
 
All you really need is the line below that you can add to a sub if desired.

LightExt.Brightness = 2

There are are 2 other adjustments for lights:

LightExt.GlowRadius = 50
LightExt.GlowBrightness= 0.65

You can also use this code to light up textures:

xBAM.GetTexture("[name of texture").Brightness = 0.4

Note that "Light" stands for the name of the light.

I use these BAM codes on all my tables that you can use for examples. I normally use a constant instead of the number.

If you want to go back to the default value, I think the default for Brightness and GlowBrightness is 1. The other guys might be able to verify this. The default GlowRadius is whatever the Glow Radius is set to in the editor.
 
Last edited:
All you really need is the line below that you can add to a sub if desired.

LightExt.Brightness = 2

There are are 2 other adjustments for lights:

LightExt.GlowRadius = 50
LightExt.GlowBrightness= 0.65

You can also use this code to light up textures:

xBAM.GetTexture("[name of texture").Brightness = 0.4

Note that "Light" stands for the name of the light.

I use these BAM codes on all my tables that you can use for examples. I normally use a constant instead of the number.

If you want to go back to the default value, I think the default for Brightness and GlowBrightness is 1. The other guys might be able to verify this. The default GlowRadius is whatever the Glow Radius is set to in the editor.
I don't actually have 'LightExt' unless it is explicitly passed into the sub.

I want to do something like:

gridLightsHelper.AddLight RoundLight1
gridLightsHelper.AddLight RoundLight2
gridLightsHelper.AddLight RoundLight3

instead of what I am doing now:

gridLightsHelper.AddLight RoundLight1, RoundLight1Ext
gridLightsHelper.AddLight RoundLight2, RoundLight2Ext
gridLightsHelper.AddLight RoundLight3, RoundLight3Ext

It would make for a nicer interface and I don't have to worry that they have passed the wrong 'Ext' object in.
 
I don't actually have 'LightExt' unless it is explicitly passed into the sub.

I want to do something like:

gridLightsHelper.AddLight RoundLight1
gridLightsHelper.AddLight RoundLight2
gridLightsHelper.AddLight RoundLight3

instead of what I am doing now:

gridLightsHelper.AddLight RoundLight1, RoundLight1Ext
gridLightsHelper.AddLight RoundLight2, RoundLight2Ext
gridLightsHelper.AddLight RoundLight3, RoundLight3Ext

It would make for a nicer interface and I don't have to worry that they have passed the wrong 'Ext' object in.

That sort of coding is a bit beyond my abilities. @Popotte is an excellent coder. He can probably help you.
 
No problem. It's been over 20 years since I touched VBScript, so my I think my coding abilities are pretty rusty. That's why I keep asking a lot of stupid questions. Hmmm, wasn't there a famous quote about stupid questions?

"There are no stupid questions, just stupid people"

Wait that doesn't sound right :)
 
I've seen this done with Execute statement:

C#:
' - Translite lights - '
For i = 1 to 2
    Execute"bgBulbGalaxy"&i&".State = BulbOn"
    Execute"bgBulbGalaxy"&i&"EXT.Brightness = 3"
    Execute"bgBulbGalaxy"&i&"EXT.GlowBrightness = 5"
...
Next
 
I've seen this done with Execute statement:

C#:
' - Translite lights - '
For i = 1 to 2
    Execute"bgBulbGalaxy"&i&".State = BulbOn"
    Execute"bgBulbGalaxy"&i&"EXT.Brightness = 3"
    Execute"bgBulbGalaxy"&i&"EXT.GlowBrightness = 5"
...
Next
You would need the name of the light in this case I realized.
 
I would stay away from execute or eval commands for anything that is used during realtime gameplay, as they get flagged / blocked / restricted by Windows Defender and possible other anti-virus.

Some older FP and VP tables become complete stutter-fests because of them on modern Windows.
 
I would stay away from execute or eval commands for anything that is used during realtime gameplay, as they get flagged / blocked / restricted by Windows Defender and possible other anti-virus.

Some older FP and VP tables become complete stutter-fests because of them on modern Windows.
Yup!

I don't actually have 'LightExt' unless it is explicitly passed into the sub.

I want to do something like:

gridLightsHelper.AddLight RoundLight1
gridLightsHelper.AddLight RoundLight2
gridLightsHelper.AddLight RoundLight3

instead of what I am doing now:

gridLightsHelper.AddLight RoundLight1, RoundLight1Ext
gridLightsHelper.AddLight RoundLight2, RoundLight2Ext
gridLightsHelper.AddLight RoundLight3, RoundLight3Ext

It would make for a nicer interface and I don't have to worry that they have passed the wrong 'Ext' object in.

Note get a reference to the Ext bulb part and then Set it to a variable reference. So, in the gridLightsHelper.AddLight method, get a ref to both the regular light and the Ext light

You can look at AnonTet and JLou's CosmicPrincess for example of this.

C#:
' Init number of players lights
For i = 1 to 4
     Execute "Set bgPLights("&i&",1) = bgPLight"&i&"big"
     Execute "Set bgPLights("&i&",2) = bgPLight"&i&"small"
     Execute "Set bgPLights("&i&",3) = bgPLight"&i&"bigExt"
     Execute "Set bgPLights("&i&",4) = bgPLight"&i&"smallExt"
Next
 
That works great! I added ~100 lights on startup with no noticeable slowdowns.

I will see if Windows Defender or my anti virus will flag it. If it does, I will revert back to the "pass in both objects" method
 
One more thing I want to change is how I'm storing the references. Right now I have a fixed length multi dimension array. My understanding VBScript doesn't let you Redim both dimensions, and I really don't like the idea of the fixed length array. I think I will have to make it a single dimension array and store a class object or an array in each row in the main array.

Is there a better way of doing this is FP VBScript ?
 
"Execute" and "eval" commands in the script are not a good idea unless there is no other way. You won't find anything on a scan. The problem is Defender's real time protection. Read my guide here to find out more:

 
One more thing I want to change is how I'm storing the references. Right now I have a fixed length multi dimension array. My understanding VBScript doesn't let you Redim both dimensions, and I really don't like the idea of the fixed length array. I think I will have to make it a single dimension array and store a class object or an array in each row in the main array.

Is there a better way of doing this is FP VBScript ?
Probably the easiest would be to have two arrays and redim both.

I think the other way would be to create a class or structure which contains the objects.

There used to be a scripter\table author called Propst who crafted some awesome scripting components:

I got a few ideas from his "collection" styled classes.

Also merging some of the ideas from LvR's list/collection work:
 
I would stay away from execute or eval commands for anything that is used during realtime gameplay, as they get flagged / blocked / restricted by Windows Defender and possible other anti-virus.
"Execute" and "eval" commands in the script are not a good idea
I've never had this problem, I've always used these commands in my tables, I don't remember anyone(in my table) complaining about this problem in Pinsim, but if it's an antvir problem, just create an exception
 
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: qinnuendo has left the room.
      Back
      Top