Jump to content



Photo
- - - - -

How to program multiball for custom VPX tables?

tutorial development multiball scripting coding

  • Please log in to reply
3 replies to this topic

#1 purpmctaxi

purpmctaxi

    Neophyte

  • Members
  • Pip
  • 4 posts

  • Flag: France

  • Favorite Pinball: austin powers

Posted 07 February 2025 - 07:01 AM

Hello VPForums,

 

I have created 2 of my own tables in the past on VPX

I will post images of each ones when I get home but for now a couple questions:

 

First of all is this the right category to post in if we are making our own tables?

 

I want to take it further because right now the gameplay is very basic, only started added a scoreboard to the second table. Does anyone know how to add a multiball feature?

 

Where can I find tutorials on how to program the tables storyline, DMD, etc. to really evolve into a real playable game?

 

I know I probably sound like a noob and I am, so any help would be greatly appreciated thank you!!!



#2 jpsalas

jpsalas

    Grand Schtroumpf

  • VIP
  • 7,206 posts
  • Location:I'm Spanish, but I live in Oslo (Norway)

  • Flag: Norway

  • Favorite Pinball: I like both new and old, but I guess I prefer modern tables with some rules and goals to achieve.



Posted 07 February 2025 - 04:38 PM

Hi purpmctaxi!

 

I know how to program a multiball, but it is not easy to explain. But you need to count the balls, both when you create them and when they drain. And you also need a system to create the ball at the plunger to start the multiball. But maybe you want to add a physical lock to hold the balls until you release them. In any case there are a lot of to be done in the script. Take a look at any of my original tables, as I have written a lot of comments in the script. Horrorburg is a later table, and the script rules aren't very complicated, so the script is not very big. What you need to check is the first part of the script, until the main rules start, at about line 2860, where it says " Table Specific Script Starts Here". I have used some multiball variables like bMultiBallMode and bMultiBallStarted, so searching for those variables will show you where they are used. I know it is not easy, but there are a lot of comments in the script, which I guess will help you understand.

 

Greetings

JP


If you want to check my latest uploads then click on the image below:

 

vp.jpg

 

Next table? A tribute table to Stern's Foo Fighters


#3 Bedoga

Bedoga

    Neophyte

  • Members
  • Pip
  • 9 posts

  • Flag: Puerto Rico

  • Favorite Pinball: Pokemon Ruby and Saphire Pinball

Posted 11 February 2025 - 04:34 AM

I'm fairly new to this as well, and JPSalas' tables have been a great help in learning. I'm using his Pokémon table as a reference to create my own. Below is something that’s working for me—it's not complete, but hopefully, it's a good starting point. There are probably some missing elements, but so far, it’s been effective for me. Although the Table crashes once you reach the BallsPerGame total of 6 balls.
 

'***************************************
'___Little Template for Multiball___
'***************************************
 
'--- Constants ---
Const BallSize = 50  ' Ball radius size
Const MaxMultiballs = 5 ' Maximum number of balls allowed on the playfield at once
Const BallsPerGame = 6 ' Total number of balls available for the game
 
'--- Variables ---
Dim BallsRemaining ' Tracks how many balls are left in the game
Dim BallsOnPlayfield ' Tracks the number of balls currently in play
BallsOnPlayfield = 0
BallsRemaining = BallsPerGame
 
'--- Multiball Variables ---
Dim mBalls2Eject ' Number of balls left to be ejected for multiball
Dim bMultiBallMode ' Flag to indicate if multiball mode is active
 
'--- Initialization ---
Sub Table1_Init()
    mBalls2Eject = 0
    bMultiBallMode = False
    CreateMultiballTimer.Enabled = False ' Ensure the timer starts in a disabled state
End Sub
 
'--- Start Multiball ---
Sub StartMultiball(balls)
    AddMultiball(balls) ' Add the specified number of balls to multiball queue
End Sub
 
'--- Ball Creation Logic ---
' This function adds balls to the queue and starts the timer to release them one at a time
Sub AddMultiball(nballs)
    mBalls2Eject = mBalls2Eject + nballs ' Add new balls to the queue
    CreateMultiballTimer.Enabled = True ' Start the timer to release them one by one
End Sub
 
' Timer event that controls ball release one at a time
Sub CreateMultiballTimer_Timer()
    If mBalls2Eject > 0 And BallsOnPlayfield < MaxMultiballs Then
        CreateNewBall() ' Create a new ball and kick it into play
        mBalls2Eject = mBalls2Eject - 1 ' Decrease the count of balls left to eject
        
        ' Stop the timer only when all balls have been ejected
        If mBalls2Eject = 0 Then 
            CreateMultiballTimer.Enabled = False
        End If
    Else
        ' Safety check to prevent infinite loops
        CreateMultiballTimer.Enabled = False
    End If
End Sub
 
' Function to create and launch a new ball into play
Sub CreateNewBall()
    If BallsRemaining > 0 Then ' Only create a new ball if there are any left in the game
        BallRelease.CreateSizedBall BallSize / 2 ' Spawn a new ball
        BallRelease.Kick 90, 7 ' Kick the ball into play (90 degrees, strength 7)
        
        BallsOnPlayfield = BallsOnPlayfield + 1 ' Increase the count of active balls
        BallsRemaining = BallsRemaining - 1 ' Decrease the count of balls left in the game
        
        If BallsOnPlayfield > 1 Then bMultiBallMode = True ' Enable multiball mode
    End If
End Sub
 
'--- Drain Handling ---
' When a ball drains, decrease the count of active balls
Sub Drain_Hit()
    Drain.DestroyBall ' Remove the ball from play
    BallsOnPlayfield = BallsOnPlayfield - 1 ' Update the number of balls in play
    
    ' If all balls drain and multiball was active, reset multiball mode
    If BallsOnPlayfield = 0 And bMultiBallMode Then
        bMultiBallMode = False
        ' Additional logic for ending multiball mode can go here
    End If
End Sub
 
'--- Multiball Trigger Event ---
' This function is triggered when a ball lands in Kicker001
Sub Kicker001_Hit()
    AddMultiball 3 ' Start a multiball sequence by adding 3 balls
    CreateMultiballTimer.Interval = 1000 ' Set the delay for each ball release
End Sub
 

Edited by Bedoga, 11 February 2025 - 04:37 AM.


#4 purpmctaxi

purpmctaxi

    Neophyte

  • Members
  • Pip
  • 4 posts

  • Flag: France

  • Favorite Pinball: austin powers

Posted 12 February 2025 - 06:55 PM

 

I'm fairly new to this as well, and JPSalas' tables have been a great help in learning. I'm using his Pokémon table as a reference to create my own. Below is something that’s working for me—it's not complete, but hopefully, it's a good starting point. There are probably some missing elements, but so far, it’s been effective for me. Although the Table crashes once you reach the BallsPerGame total of 6 balls.
 

'***************************************
'___Little Template for Multiball___
'***************************************
 
'--- Constants ---
Const BallSize = 50  ' Ball radius size
Const MaxMultiballs = 5 ' Maximum number of balls allowed on the playfield at once
Const BallsPerGame = 6 ' Total number of balls available for the game
 
'--- Variables ---
Dim BallsRemaining ' Tracks how many balls are left in the game
Dim BallsOnPlayfield ' Tracks the number of balls currently in play
BallsOnPlayfield = 0
BallsRemaining = BallsPerGame
 
'--- Multiball Variables ---
Dim mBalls2Eject ' Number of balls left to be ejected for multiball
Dim bMultiBallMode ' Flag to indicate if multiball mode is active
 
'--- Initialization ---
Sub Table1_Init()
    mBalls2Eject = 0
    bMultiBallMode = False
    CreateMultiballTimer.Enabled = False ' Ensure the timer starts in a disabled state
End Sub
 
'--- Start Multiball ---
Sub StartMultiball(balls)
    AddMultiball(balls) ' Add the specified number of balls to multiball queue
End Sub
 
'--- Ball Creation Logic ---
' This function adds balls to the queue and starts the timer to release them one at a time
Sub AddMultiball(nballs)
    mBalls2Eject = mBalls2Eject + nballs ' Add new balls to the queue
    CreateMultiballTimer.Enabled = True ' Start the timer to release them one by one
End Sub
 
' Timer event that controls ball release one at a time
Sub CreateMultiballTimer_Timer()
    If mBalls2Eject > 0 And BallsOnPlayfield < MaxMultiballs Then
        CreateNewBall() ' Create a new ball and kick it into play
        mBalls2Eject = mBalls2Eject - 1 ' Decrease the count of balls left to eject
        
        ' Stop the timer only when all balls have been ejected
        If mBalls2Eject = 0 Then 
            CreateMultiballTimer.Enabled = False
        End If
    Else
        ' Safety check to prevent infinite loops
        CreateMultiballTimer.Enabled = False
    End If
End Sub
 
' Function to create and launch a new ball into play
Sub CreateNewBall()
    If BallsRemaining > 0 Then ' Only create a new ball if there are any left in the game
        BallRelease.CreateSizedBall BallSize / 2 ' Spawn a new ball
        BallRelease.Kick 90, 7 ' Kick the ball into play (90 degrees, strength 7)
        
        BallsOnPlayfield = BallsOnPlayfield + 1 ' Increase the count of active balls
        BallsRemaining = BallsRemaining - 1 ' Decrease the count of balls left in the game
        
        If BallsOnPlayfield > 1 Then bMultiBallMode = True ' Enable multiball mode
    End If
End Sub
 
'--- Drain Handling ---
' When a ball drains, decrease the count of active balls
Sub Drain_Hit()
    Drain.DestroyBall ' Remove the ball from play
    BallsOnPlayfield = BallsOnPlayfield - 1 ' Update the number of balls in play
    
    ' If all balls drain and multiball was active, reset multiball mode
    If BallsOnPlayfield = 0 And bMultiBallMode Then
        bMultiBallMode = False
        ' Additional logic for ending multiball mode can go here
    End If
End Sub
 
'--- Multiball Trigger Event ---
' This function is triggered when a ball lands in Kicker001
Sub Kicker001_Hit()
    AddMultiball 3 ' Start a multiball sequence by adding 3 balls
    CreateMultiballTimer.Interval = 1000 ' Set the delay for each ball release
End Sub
 

 

Thank you Bedoga, you and JP are very helpful. I will try this in my latest table and see if it runs, will post in a different thread the two tables I have so far and make them downloadable as well. You are welcome to test them out, any feedback (positive and negative) will greatly be appreciated!


Edited by purpmctaxi, 12 February 2025 - 06:56 PM.






Also tagged with one or more of these keywords: tutorial, development, multiball, scripting, coding