Variable velocity Kicker-Plunger Demo

By Will Degelmann / druadic
This is a simple tutorial on how to create a "kicker" plunger for those who cannot use a default plunger within Visual Pinball. Sometimes the default plunger cannot be used in some tables because of the angle or placement of a specific area. This can help any of the scripters out there that need an alternative to a normal plunger. Sometimes too little room can be a major headache for the author and this works just great; you can even create different ways to make this plunger work with some time. I originally made this for my Whiz Ball table for Visual Pinball since a normal plunger was not too conventional and could not accomplish what I wanted a "spring loaded slapper" for an old machine to do. The result is this tutorial.

First things first: You can set this "kicker" plunger up at anytime which means it doesn't have to wait until the game is finished or completely scripted. Trust me, it's very easy and you can do this in about 3 minutes. Actually it's better just to put this "kicker" plunger in before you start on anything else scripting wise.

Enter the Visual Pinball program and goto the backdrop icon. Click it. Next, look below for the timer icon. Click it and drag a timer to anywhere on the backdrop. You can leave this timer alone since you can control the intervals (or seconds) within your table at anytime. Once you have the timer placed on the backdrop, you may want to add two textboxes but make sure you place them where they will not be in the way of the game or anywhere you don't want them to be. If you want a textbox to show the words VELOCITY you can make one - the first textbox you will lay down will be TextBox1. It's named automatically within Visual Pinball. Once TextBox1 is placed, click on it. Now, to the right you'll see the menu has changed for that particular box. At the bottom right hand side, type in the words VELOCITY and hit the enter key. Okay, that one is done, now for the next one! This is the box that will show the actual velocity adding up, one by one during gameplay. Goto the right side of the Visual Pinball program and once again click on the textbox icon. Place another textbox on the backdrop which is now automatically named TextBox2. Once you have placed the textbox where you want it, you're done here! If you wish, you do not have to add a textbox with the words VELOCITY but it might help the player to understand what it's used for during gameplay.

Okay, you have both textboxes placed on your backdrop along with the timer. When the timer was placed into the backdrop, it was automatically named timer1. During the course of your scripting KEEP TRACK OF ALL TIMERS AND TEXTBOXES or you might have problems later ESPECIALLY if you're new to this type of programming. Just a quick warning. Maybe writing all these items down on a sheet of paper might just help you later on.

Let's now go to the main screen of Visual Pinball to place our "kicker" plunger. On the right side of the screen, click on the backdrop icon again to close the backdrop. Now, to the left side of the screen are many items that can be added to your table. Look for the word Kicker and click on it. Move your mouse to the area you want the kicker to be placed. You can always come back and move it later with the mouse, but for now just drop it anywhere on the playfield. If this is the first kicker to be placed, it will be named Kicker1. If there is more than a single kicker on the playfield, take note of the number it is by clicking on the kicker and looking on the upper right side of the screen. It will show what number the kicker has been named. Now since you have you kicker placed, it's time for the scripting.

On the left upper side, you'll see an icon that shows Script - click on it. Another screen will come up showing what is in the script for the table about to be made. At the VERY TOP of the script, place your mouse there and click. An icon will appear waiting for you to type. At the VERY TOP line of the script (line 0) type the following:

Dim S

This command will now be known by the Visual Pinball program as an actual item using the Dim statement. MAKE SURE you use a capital S instead of a small or lower case s just in case later you wish to use a small s. Visual Pinball's script now understands this item will be used later within the script. This capital S is going to be used for the "seconds" to be used with the timer we recently placed and our backdrop. Now onto scripting part two of our "kicker" plunger.

Now, press the ENTER KEY TWICE to make two lower lines appear blank. We must now control the timer BEFORE a new game is played otherwise it will go bonkers before the player has a chance to use it. That would not look right, so we need to fix this. Next you'll be adding the following lines below. MAKE SURE you hit the ENTER KEY after each line is typed.
Sub Kicker#_Init()
S = 20
TextBox2.Text = "20"
Kicker#.CreateBall
End Sub



TAKE NOTE: The # is the number of the kicker used for the plunger. If the kicker was named Kicker1 then place 1 at the # shown above in both places. If it was another number, place that in the correct number in the following # areas shown above.

What the above does is the following: Sub Kicker#_Init() is telling Visual Pinball to prepare the table before the player starts. S = 20 tells Visual Pinball our seconds (or S) is at a lowest setting of 20. If it's any lower, the ball will not get enough kick from the kicker itself. This can be changed later if you wish to do so. TextBox2.Text = "20" is showing the player on the screen that the lowest possible kick from the "kicker" plunger is currently 20. This resets later in the scripting. Kicker#.CreateBall makes a ball appear BEFORE a game is started and is ready to be fired. If you wish not to have this happen before the player presses a key, remove this line and place it in the script where you would like it later. End Sub tells Visual Pinball all preparations before the game are complete and the program (once finished) is ready to go.

Okay, since we have the main parts of the script ready for the game before it starts, let's start on the next area of scripting. This next section has to be placed within a specific area, so pay attention. Look for the line: Sub Table1_KeyDown(ByVal keycode) and click your mouse just below it. The icon will appear below the line. If it doesn't, just move the cursor with the arrow keys to get it below the line mentioned. We are now going to place the keypress used by the player to add velocity to the kicker before it is launched. Next, you'll be adding the following lines below and be sure to remember that after each line is typed you press the ENTER KEY to add the next line. For now, we'll be using the F KEY for the plunger. This can be changed later by changing the keycode = #. For now, let's use key F by doing the following:

If keycode = 33 Then
Timer1.Interval = 50
Timer1.Enabled = True
If S => 100 Then
S = 100:TextBox2.Text = "" & S
Timer1.Enabled = False
End If
End If

If keycode = 33 Then is telling Visual Pinball if key F is pressed and HELD DOWN that the "kicker" plunger is going to be adding velocity to the timer. Once the F key is released, the kicker will use that amount of seconds to launch the ball from the kicker. Timer1.Interval = 50 is used to count a 50th of each second to add to the seconds added to the timer. This can be changed later to any amount you wish. The higher the amount, the SLOWER it becomes. Timer1.Enabled = True is used to activate timer1 when the F KEY is pressed. While the key is pressed the seconds count up for the velocity amount. If S=> 100 Then is used to stop the timer once the highest amount of velocity is hit. In this case 100 is the highest. This can be changed at anytime later if you wish. S = 100:TextBox2.Text = "" & S is used for if S = 100 then it will show 100 to the player and stay at 100. Timer1.Enabled = False shuts the timer off once the highest number of velocity has been reached. Here, it's 100. The first End If ends the first section If S=> 100 Then. The second End If ends the keypress altogether.

We've now added the items for when the F key has been pressed. We now need to add script to when the F key is not used or released by the player in the game. Look for the following line: Sub Table1_KeyUp(ByVal keycode) and place your cursor below it. We can now add the next lines needed as follows:

If keycode = 33 Then
Timer1.Enabled = False
Kicker1.Kick 0,S
S = 20:TextBox2.Text = "" & S
End If


The above lines control when the F key has been depressed. Timer1.Enabled = False is turning off the timer since the player no longer has the F key pressed. Kicker#.Kick 0,S is telling our numbered "kicker" plunger to kick straight up and with the added seconds "S" that are being added using timer1. This scripting (for timer1) will be added below and you can further understand how this works. S = 20:TextBox2.Text = "" & S is telling us since the F key has been depressed that the "kicker" plunger has now been reset and also shows this to the player when the game is played. End If is ending the keypress. I hope I didn't have to remind you to hit the ENTER KEY after each line that was typed!

Since we have the above done, let's get this timer script finished. This is what controls ALL of the velocity and seconds that are used by our "kicker" plunger. We now will add the following BELOW the last End If you typed AND the End Sub statement used for the keyup command. So, move your cursor under End Sub and press enter. Now, we're ready to add the following lines to make timer1 work:

Sub Timer1_Timer()
S = S + 1
If S => 100 Then
S = 100
Timer1.Enabled = False
End If
TextBox2.Text = "" & S
End Sub


Sub Timer1_Timer() is what controls what the timer1 does. Whenever the timer1 is active, the program goes here to check. S = S + 1 is the seconds that count up and shows the player how fast the velocity is gaining to the "kicker" plunger. The next three lines (as the same as above) show that once the highest amount of velocity is hit, the timer1 is deactivated and turned off leaving the kicker at it's highest velocity of 100. TextBox2.Text = "" & S shows on the game screen how fast the velocity is adding up using our textbox. End If closes the timer1 in the script.

Press the ENTER KEY to go down a line. So we now have almost all of the scipting we need done, but since a "drain" kicker was added when you opened the new script (if it was a new table you're working on) then let's use it to destroy the ball and return to the "kicker" plunger by adding the following lines:

Sub Drain_Hit()
Drain.DestroyBall
Kicker1.CreateBall
End Sub


Now, the above lines of script are saying that once the ball enters the drain, it is destroyed for the next ball to come up. Drain.DestroyBall does this. Kicker1.CreateBall makes a new ball appear in the "kicker" plunger we have placed on the playfield and afterwards this ends for the next cycle to begin.

You've done it! You've made an actual "kicker" plunger to use with any type of pinball creation you put your mind to. If you still have difficulty understanding what has all happened or just didn't get the scripting right, please look below for a link to an actual VPT file. This VPT file can be used within the Visual Pinball engine itself. Unzip the file and place it on your desktop. Double click on the blue colored icon and the program will pop up. You can immediately play from this screen to see what the above script has done when played on the screen. If you want to see the script itself, press the ESC key and then choose "quit to editor" and look around at what the program is doing. I hope this tutorial has been helpful to someone out there that is into Visual Pinball or just starting.

REMEMBER: You can change many different things within the tutorial and see how things work. Pay attention to what you change though because sometimes changing certain things can change how the script runs. Take notes and keep track of what the script and program is doing. Enjoy your new "kicker" plunger and have fun!
Download Variable velocity Kicker/Plunger Demo

Updated Jul 06, 2004 Written by druadic
 
Last edited:
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: Popotte has posted a new reply in the thread "How Do I Move a DMD on the Backbox Using Script...
      Back
      Top