A couple more switches from the manual (see the Switch Matrix Grid) are switch 53 which is the launch button and switch 54 which is the start button.
I tried and tried to get configure the table to work like the real machine with the launch button to put the ball into play (you simply hit the button and immediately the ball launches down the shooter lane rather than having a pull back plunger) but for some reason I just couldn’t get it to work right yet. Rather than trying to figure it out now in the time I have (which will probably end up taking me a couple weeks more) I thought I’d just go ahead and post the instructions for a regular pull back and release plunger. If at a later time I figure it out (or if anyone wants to post how to fix it) we can change over to the proper ball launch then.
So, before we start adding to the script we need to add a couple plunger objects to our table. One is the one we control and the other is the computer controlled autoplunger.
Start by adding a plunger object to our table:

Make sure it is called Plunger (without any numbers after it). Change the Release speed to 160. This plunger is the one we control. Now make a copy of it (CTRL-C) and then paste a duplicate on top of it (CTRL-V). Make sure this copy is called Plunger1.
Now go into the script. At around line 34 (right after the End Sub line of the LoadVPM routine) add the following code:
CODE
SolCallBack(1) = "SolTrough"
SolCallBack(2) = "vpmSolAutoPlunger Plunger1,0,"
Sub SolTrough(Enabled)
If Enabled Then
bsTrough.ExitSol_On
vpmTimer.PulseSw 15
End If
End Sub
Dim bsTrough
Your script window should look like this:

Here’s a brief description of what this code does.
SolCallBack(1) = "SolTrough"
This tells
VPM that when solenoid 1 is activated we will run our subroutine called SolTrough. If you refer to the Coils Detaled Chart from the manual you will see that coil number 1 is our trough up-kicker which is the coil/solenoid that kicks the ball into the shooter lane.
SolCallBack(2) = "vpmSolAutoPlunger Plunger1,0,"
This next line tells
VPM that solenoid 2 is an autoplunger and the plunger object on our table is called Plunger1. When solenoid 2 is fired
VPM will automatically pull back the Plunger1 object and release it which in turn automatically launches the ball.
The next 6 lines of scrip are the SolTrough subroutine that is ran when solenoid 1 is activated. When this subroutine is ran it will also pulse switch 15 which is the 4-ball trough VUK opto (refer to the Switch Matrix Grid from the manual).
VPM will pulse this switch just as if a ball was passing though the opto on the real table.
The last line of code, Dim bsTrough is used to declare a variable name (Dim is short for Dimension which means that the computer will dimension memory for our variable). In this case it is bsTrough which stands for a ball stack trough. Anytime you use a variable in the script you must include it in a Dim statement or you will get errors in your script. The next bit of code that we will add will use this variable.
Now add the following code around line 75 (right after the Table1 Init routine and just before the Const PD_LightSystemVersion = 5.5 line.
CODE
Set bsTrough=New cvpmBallStack
bsTrough.InitSw 0,14,13,12,11,0,0,0
bsTrough.InitKick BallRelease,80,6
bsTrough.InitExitSnd "BallRel","Solon"
bsTrough.Balls=4
Sub Table1_KeyDown(ByVal KeyCode)
If KeyCode=PlungerKey Then Plunger.Pullback
If KeyDownHandler(KeyCode) Then Exit Sub
End Sub
Sub Table1_KeyUp(ByVal KeyCode)
If KeyCode=PlungerKey Then Plunger.Fire
If KeyUpHandler(KeyCode) Then Exit Sub
End Sub
Sub Drain_Hit:bsTrough.AddBall Me:End Sub
Sub sw16_Hit:Controller.Switch(16)=1:End Sub
Sub sw16_unHit:Controller.Switch(16)=0:End Sub
Your script window should look like this:

Here’s a brief description of what this code that we added does.
The first 5 lines set up our ball stack with switches 14, 13, 12, and 11. The exit kicker is our object called BallRelease and it will kick the ball at an angle of 80 degrees (not sure why I used 80 rather than 90 which would be straight to the right I don’t know) and a force of 6. When the ball is kicked out it will play the sound named BallRel. You would have to import the sound you want (or in this case BallRel.wav) through the Table, Sound Manager menu. The last line tells
VPM that our ball stack contains 4 balls total (did you notice prior to adding today’s script info that if you play the table the
DMD keeps saying “4 balls missing”). It won’t anymore after this!
The next four lines of code are for our subroutine when a key on the keyboard is pushed down. We have it set up that when the plunger key (the “Enter”) is held down our object called Plunger is pulled back.
You can probably guess what the next four lines of code are. Yup, once a key is held down and then it is let up this subroutine is run. We’ve told
VPM that after the plunger key is let go to fire the object called Plunger and thus shoot the ball down the shooter lane.
The next line of code, Sub Drain_Hit:bsTrough.AddBall Me:End Sub, tells
VPM that when the Drain object on our table is hit to add a ball to the ball stack called bsTrough.
The last two lines of code are for switch 16 which is in the shooter lane right above the plunger. The first of these two lines tells
VPM that if our sw16 trigger object is hit (ie a ball is sitting on it) then switch 16 is enabled. If our sw16 trigger object does not have a ball on it (or hitting it) then switch 16 is disabled. All of this is to know whether a ball is sitting in the shooter lane waiting to be launched or not.
Now that we have added all of this to our script, if you go and “play” the table now, you will be able to add coins/credits to the game, start a new game, have a ball kicked into the shooter lane and be able to launch it.
If anyone has anything (better explanation of the script) or any corrections, please feel free to post.
Edited by wtiger, 13 November 2010 - 01:48 AM.