BAM Request: Ability to get the BAM Ball reference from a Kicker

madmrmax

Weeeeeee
Site Supporters
Joined
Sep 21, 2017
Messages
462
Solutions
1
Reaction score
237
Points
55
Favorite Pinball Machine
Indiana Jones (Williams)
For the Theatre of Magic mirror effect, I've decided I will track the balls (up to 4) that are on the table. The problem is that the script for the table is doing a lot of kicker destroy balls/create balls. This has the unfortunate issue of me losing track of a ball reference. Getting the ball reference from one kicker to the ball reference to another kicker causes a lot of coding and BAM calls, which do not seem efficient.

It should be simple to have kicker1.CreateBall actually return a BAM reference to the ball.

My work around:
Since I can't get a reference to the ball, I then have to call
xBam.BallCloseTo(x,y,z).
But kickers do not have a "Z" value, and since the table has ramps and different heights with hidden kickers on different levels, I need Z.
So, I rely on retrieving the ObjectInfo for the kicker like: xBAM.FindObject(kicker.Name).Position

All of this could be simplified if there was just an "Ext" method for a Kicker that would give me a BAM ball reference.
set bamBall = kicker1Ext.CreateBall(...)
or
set bamBall = kicker1Ext.GetBall() ' can return nothing if there isn't a ball?

where hidden kickers are used to move the ball between a magnet and drop it, or between trunk magnet and when it drops it

@ravarcade is this something you would be able to provide via BAM?
 
Last edited:
This is not a simple problem.

Here is BAM v382. This version when new ball is create it is assigned to xBAM.Ball property (like for hit events).
Inside there is also test table.

When ball is created its position is printed few times: Newton Frame Counter, ball position X/Y/Z
1. Right after CreateBall from xBAM.Ball
2. Right after CreateBall from xBAM.BallCloseTo(KickerPosition.X, ...)
3. In next 5 physics frame (from NewtonPhysicsTicks subroutine).

Issue is: In subroutine, where ball is create, ball position is invalid (FP don't set correct position). It is updated in next physics frame.
1739723836942.png

So, you can't rely on ball information in that moment.
But object is valid. You can for example assign xBAM.Ball.ExtInt1 = 314 or xBAM.Ball.ExtFloat1 = 3.14
and read that values later.

There is different way to "checkout" what is happening with balls on table. You can use xBAM.EnumBalls
Code:
Sub PrintBallPosition(ball)
  AddDebugText xBAM.NewtonCounter & ": -> " & ball.Position.X &", "& ball.Position.Y &", "& ball.Position.Z
End Sub

Sub NewtonPhysicsTick()
    xBAM.EnumBalls 4, 0, "PrintBallPosition"
End Sub


First argument of function is maximum of balls you want to process. (0 means all).
Second argument is not used.
Third is name of subroutine to call. That subroutine has one argument "ball".

Note: Before call, all balls are sorted by speed. In this code sample position of 4 fastest balls is printed.
 
This is not a simple problem.

Here is BAM v382. This version when new ball is create it is assigned to xBAM.Ball property (like for hit events).
Inside there is also test table.

When ball is created its position is printed few times: Newton Frame Counter, ball position X/Y/Z
1. Right after CreateBall from xBAM.Ball
2. Right after CreateBall from xBAM.BallCloseTo(KickerPosition.X, ...)
3. In next 5 physics frame (from NewtonPhysicsTicks subroutine).

Issue is: In subroutine, where ball is create, ball position is invalid (FP don't set correct position). It is updated in next physics frame.
View attachment 46143

So, you can't rely on ball information in that moment.
But object is valid. You can for example assign xBAM.Ball.ExtInt1 = 314 or xBAM.Ball.ExtFloat1 = 3.14
and read that values later.

There is different way to "checkout" what is happening with balls on table. You can use xBAM.EnumBalls
Code:
Sub PrintBallPosition(ball)
  AddDebugText xBAM.NewtonCounter & ": -> " & ball.Position.X &", "& ball.Position.Y &", "& ball.Position.Z
End Sub

Sub NewtonPhysicsTick()
    xBAM.EnumBalls 4, 0, "PrintBallPosition"
End Sub


First argument of function is maximum of balls you want to process. (0 means all).
Second argument is not used.
Third is name of subroutine to call. That subroutine has one argument "ball".

Note: Before call, all balls are sorted by speed. In this code sample position of 4 fastest balls is printed.
Thanks @ravarcade! For EnumBalls is there a different sort mechanism supported vs. sort by speed? I see the second parameter to EnumBalls is "order".

I'll try out the new bam.dll build and try things out!

Regarding xBam.Ball -- how long (# of frames, etc) is that valid for? With multiple balls on a table, is the xBam.Ball only valid within the _Hit after the calling CreateBall?
 
The second EnumBalls parameter is not used. “Order” was supposed to give script developers the ability to define the desired order, but no one was interested in using it.

xBAM.ball will always point to ball in last event. So, any hit event will change it. If in same physics frame 2 hits occured, for two _hit procedures it will be different ball.

In v382 this is also updated on ball creation.

So, if in script you use "xBAM.Ball" it is valid for short time, but if you store that value in global variable, that variable will be valid always (until you change it) or ball will be destroyed.
 
Thanks @ravarcade! Regarding ball, do you know why BallInfo.ID doesn't return the BallId value?
 
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:
    MedievilMadness has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    Pinbalbilly has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    flipjuice has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    apollo2000 has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    Gmelo1 has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    jose49 has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    darcel has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    cocopops has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    Nightvoice has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    drew1 has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    Cicero Silva has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    manstein has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    1000 has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    Destruck62 has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    WeadlyDeapon has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    SaixXemnas has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    Gege has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    Fatmeatball has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    titomajo has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    daveseawater has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    rockin ray has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    Citron68 has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    hammerpower has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    max37170 has left the room.
  • Chat Bot Mibs Chat Bot Mibs:
    OZZOLO has left the room.
      Chat Bot Mibs Chat Bot Mibs: OZZOLO has left the room.
      Back
      Top