Jump to content

Adding Manual Ball Control to a Visual Pinball Table


Recommended Posts

This is a repost of content from VPINBALL.  I do not know who the creator of this content is otherwise I would give him credit.   The attachment is a demo table that has ball control installed. Here was the original instructions:

 

Steps to add manual ball control to your VPX table:

 

1) Add a new timer to your table in the editor. Name the timer BallControl, check Enabled, and set Timer Interval = 1.

 

2) Add a new trigger to the ball shooter lane called “StartControl” or copy the “StartControl” trigger from the demo table.

 

3) Add a new trigger just above the drain called “StopControl” or copy the “StopControl” trigger from the demo table.

 

4) Add the following code inside the Sub Table1_KeyDown subroutine:

if keycode = 46 then ' C Key
     If contball = 1 Then
          contball = 0
     Else
          contball = 1
     End If
End If
if keycode = 48 then 'B Key
     If bcboost = 1 Then
          bcboost = bcboostmulti
     Else
          bcboost = 1
     End If
End If
if keycode = 203 then bcleft = 1 ' Left Arrow
if keycode = 200 then bcup = 1 ' Up Arrow
if keycode = 208 then bcdown = 1 ' Down Arrow
if keycode = 205 then bcright = 1 ' Right Arrow

 

5) Add the following code inside the Sub Table1_KeyUp subroutine:

if keycode = 203 then bcleft = 0 ' Left Arrow
if keycode = 200 then bcup = 0 ' Up Arrow
if keycode = 208 then bcdown = 0 ' Down Arrow
if keycode = 205 then bcright = 0 ' Right Arrow

 

6) Add the following code outside of any other subroutine for function:

Sub StartControl_Hit()
     Set ControlBall = ActiveBall
     contballinplay = true
End Sub

Sub StopControl_Hit()
     contballinplay = false
End Sub

Dim bcup, bcdown, bcleft, bcright, contball, contballinplay, ControlBall, bcboost
Dim bcvel, bcyveloffset, bcboostmulti

bcboost = 1 'Do Not Change - default setting
bcvel = 4 'Controls the speed of the ball movement
bcyveloffset = -0.01 'Offsets the force of gravity to keep the ball from drifting vertically on the table, should be negative
bcboostmulti = 3 'Boost multiplier to ball veloctiy (toggled with the B key)

Sub BallControl_Timer()
     If Contball and ContBallInPlay then
          If bcright = 1 Then
               ControlBall.velx = bcvel*bcboost
          ElseIf bcleft = 1 Then
               ControlBall.velx = - bcvel*bcboost
          Else
               ControlBall.velx=0
          End If

         If bcup = 1 Then
              ControlBall.vely = -bcvel*bcboost
         ElseIf bcdown = 1 Then
              ControlBall.vely = bcvel*bcboost
         Else
              ControlBall.vely= bcyveloffset
         End If
     End If
End Sub

 

7) Usage:

The “C” key toggles ball control. Press once to capture the ball. Press again to release the ball.

The “B” key toggles speed boost. Press once to enable the speed boost. Press again to disable the speed boost.

Use the arrow keys to move the ball around the table.

 

 

Ball_Control_Demo.zip

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...