Code/Example Codes and examples of codes to use in BAM

Coding and examples for future Pinball and BAM
This code "xBAM.VisibleCabParts = 0" sometimes it seems not to work.

not yet clear why in one of my tables it didn't work ... but in a new table it worked ..... so I have to move all the work done
 
It may not matter but I believe you should stop tracking just BEFORE you destroy ball
Code:
sub Kicker2_hit()
deleteTrackedBall(Kicker2)
Kicker2.DestroyBall
Timer3.Interval = 500
Timer3.Enabled = TRUE
end sub
Ok I am trying to add rolling ball sound code to Terry Reds and Slams Superman ultimate 4.0 they seem to use all 8 music channels is there any way to get rolling ball sounds to work with this or is 8 the limit?
 
Ok I am trying to add rolling ball sound code to Terry Reds and Slams Superman ultimate 4.0 they seem to use all 8 music channels is there any way to get rolling ball sounds to work with this or is 8 the limit?

it is a little complicated, but there is a way to overcome the limit....now, i believe that in rolling sound, it is necessary to have channel between 1 and 8 to work

but if all channels are occupied by music then you have to use "effectmusic"(to free a channel),now there will be many ways to use this "effectmusic" to overcome the limit, but I, can only explain to you what I use, and how I use it.
 
Last edited:
Maybe Ravarcade could expand the number of channels avalaible. Maybe...
But it's sure for the beginning 8 channels was enough.
 
Question how do I retrieve a highscore from nvram?
I am modding a table that always says congradulations high score even when you do not have one.
 
Maybe Ravarcade could expand the number of channels avalaible. Maybe...
But it's sure for the beginning 8 channels was enough.
Ya Slams ultimate tables use all of them really no need for rolling sounds on those so I am good.
 
Maybe Ravarcade could expand the number of channels avalaible. Maybe...
But it's sure for the beginning 8 channels was enough.
I hope you don't mind me to quote your post just to tag @ravarcade for visibility.
 
Question how do I retrieve a highscore from nvram?
I am modding a table that always says congradulations high score even when you do not have one.
You have ten varaibles for that: nvHighScore(x) with x = 1 to 10.
You have also nvHighScore1 to nvHighScore4.
FP help is useful...
 
Question how do I retrieve a highscore from nvram?
I am modding a table that always says congradulations high score even when you do not have one.
Something about score that you need to keep in mind is the ' xBAM.FixScore code will change the point of score overflow from 2 billion to 922 trillion points. You can read about it on a posting on this page:

 
More precisions about 'xBam.FixScore here -> How to use score/high score
Thank you no issues with this table and scores above 2 billion, it just was not retrieving the nvHighScore(10) and comparing it to current player highscore before stating congratulations you have a high score. I fixed it.
 
I tried explaining how VisibleCabParts works under the hood here. I don't recommend using values from -5 to 5 as suggested above, since that's just a few "blind" options of the whole deal with that property.



I have some basic ideas for BAM applications I'd like to explore, so I'll probably be posting them on this topic.

For now, the first one would be Power Bumpers.

Power Bumpers are a special kind of bumper that hits almost as hard as the phrase "Power Bumpers have more than 12 years". In the "pre-BAM era" they were constructed using a complex set of table objects, but BAM allows recreating its effect pretty effectively with only a normal bumper, a Timer and some spicy code :lol:

Be not afraid, the code is in fact pretty simple, and I also included in the demo some extra stuff: A rotating bumper which is just a variant of the same with an extra Timer, and an example in the code on how would you set the strength of the Bumper depending on the direction of the hit, just like ye olde EM-Kickers.

Have fun!
 

Attachments

  • PowerBumperDemo.fpt
    227.5 KB · Views: 10
I tried explaining how VisibleCabParts works under the hood here. I don't recommend using values from -5 to 5 as suggested above, since that's just a few "blind" options of the whole deal with that property.



I have some basic ideas for BAM applications I'd like to explore, so I'll probably be posting them on this topic.

For now, the first one would be Power Bumpers.

Power Bumpers are a special kind of bumper that hits almost as hard as the phrase "Power Bumpers have more than 12 years". In the "pre-BAM era" they were constructed using a complex set of table objects, but BAM allows recreating its effect pretty effectively with only a normal bumper, a Timer and some spicy code :lol:

Be not afraid, the code is in fact pretty simple, and I also included in the demo some extra stuff: A rotating bumper which is just a variant of the same with an extra Timer, and an example in the code on how would you set the strength of the Bumper depending on the direction of the hit, just like ye olde EM-Kickers.

Have fun!

Seems to work very cleanly. Bumpers have a good powerful punch but not spastic and crazy.
 
Damit, after I just coded in some things with the bumpers... :(

You should post this by itself. Once everything is 100 percent, then in the resources section, as things can get lost very quickly, so anything to make it easy to find is appreicated.

I will have a look at this... now!
 
Damit, after I just coded in some things with the bumpers... :(

You should post this by itself. Once everything is 100 percent, then in the resources section, as things can get lost very quickly, so anything to make it easy to find is appreicated.

I will have a look at this... now!
I would probably have trouble finding this again myself.
 
You should post this by itself. Once everything is 100 percent, then in the resources section, as things can get lost very quickly, so anything to make it easy to find is appreicated.
I'll do that, then. Some of the BAM ideas I have in mind right now barely deserve their own topic, but I guess I can reserve this only for the ones that won't include a demo.

For example, with BAM you can make triggers that act like Speed-modifier magnets. They're like PinBelts (basic Kickers) but preserving the direction of the ball when passing by, simply making it faster or slower by a speed ratio.

That's pretty easy to do with a few lines of code.
Code:
Sub MagnetTrigger_Hit()
    Dim cBall : Set cBall = xBAM.BallCloseTo(MagnetTrigger.X, MagnetTrigger.Y) ' Get current ball
    cBall.SetVelocity cBall.Velocity.X * 0.75, cBall.Velocity.Y * 0.75 ' The ball goes slower
End Sub

Once everything is 100 percent (…)
They are so simple I don't know what else to add, but I accept suggestions :-)
 
Going through the bumpers right now. Modified it for testing only. So far so good, though I have found the ball gets hung beween 2 bumpers very easy, something the power bumpers prevented. Also the odd case of FP being FP sometimes. I'm still moving bumpers around, the power bumpers used a custom trigger for the bumper skirt, so the diameter was larger than the normal stock skirts, so things are not as active as I would like.

Your code would work real handy for tough ramps in the center of the playfield. Maybe put that code in the one thread you have?
Sure a lot of people will use them, and maybe come up with a new application. even this code can be very handy to someone
 
My topic's title is as generic as this one, so for BAM stuff I believe this one is still more appropriate and easy to find.

Here's another example code.

Some modern pinball tables have a motor that makes the table shake a bit. You can think of it as the pinball equivalent of the typical console controller vibration when the game has Quick Time Events or things like that. The IPDB defines that as a Shaker Motor.

IPDB said:
Motors that are purposely designed to vibrate or shake when activated. Pinball machines use them to activate at certain times during play. Their only purpose is to shake the pinball cabinet so that the player can feel this movement during play.

BAM can simulate this effect with a Mini-Playfield that covers the whole table. All you need to do is create a Timer (I used an interval of 50), create the MiniPlayfield and make a function that defines the shaking properties.

Code:
Const BAM_VERSION = 0

Dim TableMiniplayfield
Dim TableShakeCounter, TableShakeFrames, TableShakeForce

Sub BAM_Init()
    ' Create the mini playfield
    Dim w, h, m : w = xBAM.Table.Width : h = xBAM.Table.Length : m = 256
    Set TableMiniplayfield = xBAM.CreateMiniPlayfield(-m, w+m, -m, h+m, -300, 300, w / 2, h / 2, 0)
End Sub

' Function call that shakes the table by an amount of milliseconds and with a defined force
Function ShakeTable(ByVal Frames, ByVal Force)
    If (BAM_VERSION = 0) Then Exit Function
    TableShakeTimer.Enabled = True
    TableShakeCounter = 0
    TableShakeFrames = Int(Frames / TableShakeTimer.Interval)
    TableShakeForce = Force
    PlayMusic 1, "ShakeMotor"
End Function

Sub TableShakeTimer_Expired()
    TableShakeCounter = TableShakeCounter + 1
    Dim CurrentForce : CurrentForce = TableShakeForce
    If ((TableShakeCounter Mod 2) = 0) Then CurrentForce = -CurrentForce
    TableMiniplayfield.MoveTo (xBAM.Table.Width / 2) + CurrentForce, (xBAM.Table.Length / 2), 0, 0, 0, 0, 1, TableShakeTimer.Interval / 1000
    If (TableShakeCounter >= TableShakeFrames) Then
        TableMiniplayfield.MoveTo (xBAM.Table.Width / 2), (xBAM.Table.Length / 2), 0, 0, 0, 0, 1, TableShakeTimer.Interval / 1000
        TableShakeTimer.Enabled = False
        StopMusic 1
    End If
End Sub

When you want the shake, you simply call the function. I used the flippers to test this.
Code:
            ' If the Left Flipper Key Has Been Press, Activate The Left Flipper(s)
            If (KeyCode = GetKeyCode(LeftFlipperKey)) Then
                LeftFlipper.SolenoidOn
                ShakeTable 500, 2
                PlaySound "Flipper"
            End If

            ' If the Right Flipper Key Has Been Press, Activate The Right Flipper(s)
            If (KeyCode = GetKeyCode(RightFlipperKey)) Then
                RightFlipper.SolenoidOn
                ShakeTable 500, -2
                PlaySound "Flipper"
            End If

If you deactivate the default Nudge (setting its force to 0 in the XML physics) you could use this to make a custom Nudge effect. I wouldn't recommend that except for very specific cases, since I believe FP cabinets use an analog Nudge mode instead.

Here's a custom nudge effect using this method, so it's a bit stronger than default.

View attachment nudge_example.mp4
 
Excellant, I was going to add a stronger nudge to the TiltFlex system. You keep reading my mind. ..
 
I have a real shaker motor in my cabinet, and I add support for it as much as possible for every table I add feedback too (PinEvent tables). It's my favorite feedback in the cabinet along with SSF.

Love seeing all these tidbits of lost treasures. I remember Steve coming on to GoPinball long ago sharing some things he discovered along these lines back then (the rotating bumper I think it was).
 
Made this thread sticky, in the attempt to get you to add more code so we all can steal it for our own tables. :)
 
Total Recall Table (very old) had a "shake" function. Not sure how it was done.
 
Total Recall Table (very old) had a "shake" function. Not sure how it was done.

Jurassic Park (U-Pro) and maybe other versions had it as well I think.
 
I have the code, used it in Jungle Girl

Code:
' --------------------- Shaker (loop) --------------------------

function RandomNumber(ByVal max)
    RandomNumber = Int(max * Rnd + 1)
end function

Const Earthquake                = 45        ' This paramater determines how much the ball is affected during the earthquake sequences.  I recommend
                                                ' setting it between 10 and 100.  A value of 30 or less produces a heavy effect.  A value of 50 produces a
                                                ' medium effect and a value of 70 or higher produces a moderate effect. 

Dim SDuration
' Code for shaking effect. Number is interval time
'SDuration=(MusicIntervalTime):ShakeIt(SDuration)                                                                                                    ' Shake effect

Sub Shakeit(SDuration)
    IF (fpTilted = TRUE) OR (GameInProgress=0) THEN StopShake():Exit Sub:END IF
    ShakerSequencer.Set true ,SDuration
    ShakethePF.Set true ,Earthquake
end Sub

Sub TurnOffAllFakePF()
    fakeE.render=false:fakeN.render=false:fakeO.render=false:fakeS.render=false
end sub

' swaps between different playfields
sub ShakethePF_expired()
        TurnOffAllFakePF()
        select case randomNumber(4)
            case 1:fakeE.render=true                           
            case 2:fakeN.render=true
            case 3:fakeO.render=true
            case 4:fakeS.render=true
        end select
        ShakethePF.Set true ,Earthquake
end sub

Sub ShakerSequencer_expired()
    TurnOffAllFakePF()
    ShakethePF.Set false
    ShakerSequencer.Set false
end sub

Sub StopShake()
    TurnOffAllFakePF()
    ShakethePF.Set false
    ShakerSequencer.Set false
END SUB

And then to access it.
Code:
        SDuration=50:ShakeIt(SDuration)
 
Here's another example of code you can use with BAM.

Using BAM's option to change the graphic via an attached ZIP file, and with a little correcting code, you can change the 14-Segmented displays, so they handle 15 or 16 segments instead. Also, it's not hard to have both versions of displays operative based on whether BAM is available or not.

The typical 16-segment display is very similar to the AlphaNumeric version used in FP but with an extra cut in the top and bottom lines, which could be useful in very specific cases (some lowercase characters, a custom font with thin letters, etc). That being said, the main potential of this would be for more customized displays.

square-display.png

This doesn't come without a little trade-off; with them, you can't use a decimal point or comma the same way as default, and some boredom effects may look a bit off. They may also be incompatible with more advanced Display Segment codes. That being said, I still find interesting this is possible.
 

Attachments

  • Square Display Demo.zip
    213.3 KB · Views: 2
Forum activity
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.
      Mibs Mibs: GeorgeH has posted a new reply in the thread "Sounds library".
      Back
      Top