Code/Example BAM Simulate Spinners and Gates with BAM

Coding and examples for future Pinball and BAM
Sorry for a rookie question. I'm trying to cure a gate that slows/stops the ball intermittently.

I opened the example table and the target table in one editor. In the example window I select and copy the gate/wall. I switch windows to the target table and click Paste At. I only get this symbol:
1693259582024.png
What am I supposed to do to get the toy in the target table?

Thanks for your patience.
Brent
 
yes when you copy an object from one table to another, don't forget (1)code (2)texture and (3)models.
 
look in example to collect what you need
 
Sorry to return to this. I've imported Gate-Heavy-T1-Toy into the table. I've copied the GateToy from the example table to the table I'm working on and moved the transparency slider all the way to the left. I can't see the toy when I try to play the table and it doesn't seem to be there as I get a RotatateToyYZ script error when the ball passes over the GateTrigger. The ball can freely reenter the shooter lane so I must not have it located at the correct height. I've also placed the GateWall in the same location.

This table has a separate playfield surface offset 50mm above the standard surface. I've assigned the GateWall and the GateToy to the playfield surface. The GateToy is offset 29mm and the GateWall has a height of 29mm.

Thanks in advance for any suggestions.
 
Are there any models for spinner toys larger than the one on the demo table? I have a table using the FP standard spinner-T2 that looks larger than the demo toy. I would like to add a spinner toy but would prefer a larger one that matches the T2.

...Or is it possible to convert a standard spinner model to a toy using the FPM Editor? The FPM Editor does seem to allow it.
 
Last edited:
if you need the model (toy, drop, trigger and more) to be modeled and adapted to the place where you need to insert it, you know you can ask me
 
if you need the model (toy, drop, trigger and more) to be modeled and adapted to the place where you need to insert it, you know you can ask me
Thanks Paolo! I converted the T2 spinner to a toy using the FPM Editor and tried it on Wecoc's demo table. It appears to work although I haven't tried it on my table yet so I will let you know if I need your help.
 
I got it to work. I tried Rav's code and the spinner would usually only spin one time before it stopped. It spins several times now with the toy. Has Shiva's question ever been answered? I tried adding a sound to Sub SpinnerTimer_Expired(). Like Shiva said, the sound never stops playing after the spinner is hit. Is this an issue?

I tried adding the spinner sound below this comment where it only played the sound one time when the spinner is hit:

' Add here the effect when hitting the spinner, for example a Sound depending on the current force

I needed it to play the sound with each revolution so I added it below the following comment along with the rest of the code that had been added to the old spinner hit subroutine. It worked perfectly.

' Add here the effect for each loop (Add Score, etc)

I found if you lower the values in this section, the spinner will spin more revolutions. If you set loose to 1.0, it will spend endlessly. It might be different with different sized spinners.

Case 0 : SpeedDecrease = 1.5 ' Loose
Case 1 : SpeedDecrease = 1.7 ' Norm
Case 2 : SpeedDecrease = 1.9 ' Tight

I deleted these 2 functions because they don't appear to be used anywhere:
Function RotateToyXZByFrames(ByVal Toy, ByVal Frames, ByVal sAngle, ByVal eAngle)
Function RotateToyXYByFrames(ByVal Toy, ByVal Frames, ByVal sAngle, ByVal eAngle)

This one is used:
Function RotateToyYZByFrames(ByVal Toy, ByVal Frames, ByVal sAngle, ByVal eAngle)

This is pretty cool! I like it. I am interested in knowing the resolution to Shiva's question I mentioned above.
 
I ended up using the section of the code that says "Add here the effect when hitting the spinner, for example a Sound depending on the current force". The table I am editing has an award for the spinner where the player can get 1000 points per revolution. I tried setting it up so the display says 1000 points but that got a little excessive to display it for each spin. So I moved the code for the display to the other location where I made it say 1000 per spin and it is only displayed one time for each hit of the spinner.
 
On this topic of custom gate/spinners, @Wecoc you have the below code for the gate Hit trigger event. It looks like you are only looking for velocity going up and down. I'm putting two gates at the top facing left and right. Do I need to change this to look at velocity going left/right?

C#:
Sub GateTrigger_Hit()
    If (BAM_VERSION = 0) Then Exit Sub
    ' Check if the ball is going up or down
    Dim d : If (xBAM.Ball.Velocity.Y < 0) Then : d = 1 : Else : d = -1 : End If
 
You don't need the BAM_VERSION line I'd say. You test once at table launch to see if BAM meets the minimum requirements and call it a day.
 
That BAM_VERSION avoids a possible error if loading the table without BAM, by ignoring the gate spinning function entirely. In some tables that may be a saver, in others it's unnecessary, but it should never cause any trouble by itself.

About @madmrmax's question, the answer is yes. The gate has two possible "directions" and checks which one you triggered by looking at the ball's Velocity. Usually Velocity.Y is enough to distinguish it, even if the gate is slightly rotated, but if the gate is facing strictly to the left or right you would use Velocity.X instead. Sorry for not making this more clear on the code. The "spinning effect" itself is based on the toy's rotation, so there's no problem there.

These are the 3 things you must consider in this case:
1- Toy's rotation is important and works the same as gate rotation.
That means for one-directional gates, the toy on the left should have a rotation of ~90 and the one on the right should have a rotation of ~270.
2- On both lines of code inside GateTrigger_Hit that use Velocity.Y, you would use Velocity.X instead.
3- The one on the left must have another change: The mentioned line has (xBAM.Ball.Velocity.X < 0) should be changed to (xBAM.Ball.Velocity.X > 0) instead. In the very rare but possible case where a one-way gate should block the ball when it's going up (a rotation of ~180), the same change would be applied but with Velocity.Y

There are other things that can be tweaked, like the force, the damping effects, the minimum required speed, etc. My codes are pretty much examples meant to have a certain amount of configuration based on your specific case ;)
 
Well, for one, EVERYONE should keep BAM updated. How people still miss this is beyond me and it's why the 1st answer when troubles arise is "make sure you have latest BAM".

Also the spinners won't work as intended if you bypass them. On principle alone, the table SHOULD fail the load even if you have to write the above answer, yet again.

What's the point in setting the spinners or whatever to make things work/look better and then bypass all that?

If we keep doing things so 20years old computers still run things we're just adding overhead and keep old notions alive making moving forward more difficult.
 
I think my answer was misunderstood. I also think by now everyone should use BAM and keep it updated. But I also prefer a notification that says "You don't have BAM! / This table requires at least [X] version of BAM!" at the start, better than an error display that says "xBAM.Ball undefined" when the ball touches the gate. That line is like a last resort to avoid that error message in the case BAM was not implemented properly. This is why I also tend to separate completely the "BAM" functions and properties from the "non-BAM" ones on more complex codes. Even though in most tables that should not be necessary at all, I still think it's good practice.
 
The problem with that message as far as I can remember is that it is only seen if you run in debug mode :(
 
The problem with that message as far as I can remember is that it is only seen if you run in debug mode :(
True, but in odd (very much the exception case) cases, I guess a spinner that uses a toy as the spinning part could "in theory" not make the rest of the table break. But yeah maybe perhaps an actual exception could be raised. (not fully custom, but you could do Err.Raise ///some number.

I don't recall if VB script compiles each method or each line. I would think that when the _hit method is just-in-time compiled it would actually throw on the xBam call even before it reaches the line. I could be wrong on that though.
 
Last edited:
Yeah, you could use something like this at the start of your table to make sure the player is using at least the version you used when making the table, or more specifically, the last version where all the functions you used were already implemented (since this is about compatibility, after all).
Code:
If (BAM_VERSION < 373) Then Err.Raise vbObjectError, , "This table requires at least BAM v1.5-373"
 
Last edited:
That BAM_VERSION avoids a possible error if loading the table without BAM, by ignoring the gate spinning function entirely. In some tables that may be a saver, in others it's unnecessary, but it should never cause any trouble by itself.

About @madmrmax's question, the answer is yes. The gate has two possible "directions" and checks which one you triggered by looking at the ball's Velocity. Usually Velocity.Y is enough to distinguish it, even if the gate is slightly rotated, but if the gate is facing strictly to the left or right you would use Velocity.X instead. Sorry for not making this more clear on the code. The "spinning effect" itself is based on the toy's rotation, so there's no problem there.

These are the 3 things you must consider in this case:
1- Toy's rotation is important and works the same as gate rotation.
That means for one-directional gates, the toy on the left should have a rotation of ~90 and the one on the right should have a rotation of ~270.
2- On both lines of code inside GateTrigger_Hit that use Velocity.Y, you would use Velocity.X instead.
3- The one on the left must have another change: The mentioned line has (xBAM.Ball.Velocity.X < 0) should be changed to (xBAM.Ball.Velocity.X > 0) instead. In the very rare but possible case where a one-way gate should block the ball when it's going up (a rotation of ~180), the same change would be applied but with Velocity.Y

There are other things that can be tweaked, like the force, the damping effects, the minimum required speed, etc. My codes are pretty much examples meant to have a certain amount of configuration based on your specific case ;)
Thanks for the detailed response. Your comments match with what I found I needed to do. I'm looking to convert your code into a VB class so that table authors can "attach" a behavior to a gate and specify some additional parameters such as "one way or not" and "direction". I'll also be adding (since my table needs it) the concept of a "Controlled one way gate" whereby a solenoid can be pulsed to make a gate (heavy gate, not spinner) dual-way vs one, when needed.

I'll be sure and give your code credit!
 
Yeah, you could use something like this at the start of your table to make sure the player is using at least the version you used when making the table, or more specifically, the last version where all the functions you used were already implemented (since this is about compatibility, after all).
Code:
If (BAM_VERSION < 373) Then Err.Raise vbObjectError, , "This table requires at least BAM v1.5-373"

I used to show an error like this on my table mods. The only difference is I displayed an overlay in different languages that said something similar. It filled the entire screen so the end user couldn't play the table without at least reading enough of the message to figure out the letter to press to close the message.

I got away from using it though. I posted Medieval Castle without it and didn't get any complaints that resulted from not having BAM installed even though it requires BAM v1.5-373 which had been released one week prior to posting the table.
 
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: hellrzr2k1 has left the room.
      Back
      Top