• We have added Language Translations for French, Italian and Spanish menus, you can change your language at the bottom of every page, bottom left in the footer.
  • Spanish (Español, Latin American) translations have been added for the Forums and Resource Manager (Downloads). You can change your Language Here!

BJs How-To series

JonPurpleHaze

Site Nudger
Staff member
BJ has created a series of five bare bones tutorials which should be of help to both our newer authors, as well as to even many of our more seasoned experienced developers. We\'ll all have less confusion and trouble adding needed features to our tables with these Generic-type table guides. Each of these tutorials is fully commented with easily understood instructions, but with nothing that might add to a new person\'s uncertainty.

The first thing you'll notice when you download and begin using BJ's great help aids will be the lack of any extras. There are no unwanted graphics or unrequired objects on the tables, and no script code that you won't use to implement these five standard features. But simply because they are basic doesn't at all mean that they are plain and boring. Our BJ has created five very wonderfully simple to use features that can be used just as he wrote them, or adapted for a bit more flair on your latest original.

We are grateful to our friend BJ for the time and effort he spent creating what we believe will be extremely helpfull to so many of us. Thank you so much BJ, and I'm sure everyone else will echo my own. BJ's How-To Series is available here, in our Tutorial & Support Files section.

 
Last edited by a moderator:

JonPurpleHaze

Site Nudger
Staff member
BJ's VP Objects Settings Tutorial

BJ has created what might prove to be one of the most needed and useful VP tools ever. He has taken all twenty VP Editor objects and listed every setting according to their properties, methods, and events, and shows us how and if these settings are achieved through the editor itself or in the code script, or even both, as in some situations. This should be useful to experienced as well as novice developers, since there simply is too much material for any of us to know everything off the top of our heads.

This important HTML document completes a project which began in the fall of 2002, at which time BJ and several other authors complied such a listing in a text file. While that document was invaluable to every author, it was a bit tedious and cumbersome, and required a lot of paper shuffling. This searchable HTML objects settings list will not only take the work out of our research, but should make us all more likely to "do it right the first time", rather than using the old trial and error method.

Once again BJ has shown us that he is much more than simply a clownish avatar with huge ears and a twisted sense of humor. He is the author of 11 VP original tables, including one of my all time favorites, in BallDropper, as well as 52 Card Pickup, Hillbilly Hellcats, and Sphere's Dream. BJ is also a Super Moderator for VPF, and one of the more helpful people who roam the forums. His quick wit, sense of humor, and willingness to help and encourage anyone has made him one of the most popular folks in the VP community.

Download zip file here.

Updated Jul 05, 2004 Written by tiltjlp
 
Last edited by a moderator:

JonPurpleHaze

Site Nudger
Staff member
Ball Plunger, Nice Touch

The "HowTo" series of Visual Pinball tables is presented mainly for the person who is trying to understand how to implement certain events in Visual Pinball scripting
So why create a stand-alone "How-To" table when there are many great tutorial tables already available? Because, as a "newbie", it can be very tedious and often confusing to sort thru lines and lines of scripting devoted to many different features of a table trying to find out how a certain feature is done. My thought was why not just present one feature on a table so that the tedium and confusion might be held to a minimum? The tables will look very dull and flat and very uninteresting and playing them will not be as full of flash and pizzazz as a full blown table. But the intent is, first, to present as clearly and simply as possible the underlying scripting and events of a given feature while, secondly, keeping the table's filesize to a minimum for the sake of convenience. And remember that this is not necessarily "how you do it". What I intended to do was to present the concept of a given feature and to show at least one way to implement the controls to create that feature. The code has been heavily, but simply, commented as to what is going on and why certain things are done. Not every nuance of a feature can be addressed in every case. But by gaining a general understanding of a feature's concept, much less frustration will be experienced when building your table. That helps contribute to keeping a table designer happy, and a happy table designer is a productive table designer! BJ The following is the script from BJ's tutorial table on Ball Plunger Nice Touch:
Code

' This variable will help us to keep track of whether to activate or
' deactivate the ball plunger on a "keydown" condition for a "professional"
' touch to your table
' (See "Table1_Init", "Gate_Hit" and "Drain_Hit" subroutines below)
Dim GameOn

Sub Table1_Init() 'process the following script when the table is 1st loaded
GameOn = 0 'zero is used as a "condition" to disable the plunger
ScoreText.text = "Press ""S"" to Start" & vbcr & Bullet6 _
"Plunger is Dead"
Bullet6 end Sub

Sub Table1_KeyDown(ByVal keycode)

if keyCode = 31 then ' Start key (S) is pressed
GameOn = 1 '1 is used as a "condition" to enable the plunger
ScoreText.Text = "GameOn = " & GameOn & vbcr & Bullet6 _
"Plunger is Active"
Bullet6 end if

if keycode = PlungerKey Then
'If GameOn = 1, plunger will be active, if it is zero, it will not.
'Nice professional Bullet6 touch to a VP table.
if GameOn = 1 then
Plunger.PullBack
ScoreText.Text = "GameOn = " & GameOn & vbcr & Bullet6 _
"Plunger is Active"
Bullet6 end if
Bullet6 end if

if keycode = LeftFlipperKey Then
LeftFlipper.RotateToEnd
PlaySound "FlipperUp"
Bullet6 end if

if keycode = RightFlipperKey Then
RightFlipper.RotateToEnd
PlaySound "FlipperUp"
Bullet6 end if

if keycode = LeftTiltKey Then
Nudge 90, 2
Bullet6 end if

if keycode = RightTiltKey Then
Nudge 270, 2
Bullet6 end if

if keycode = CenterTiltKey Then
Nudge 0, 2
Bullet6 end if

Bullet6 end Sub

Sub Table1_KeyUp(ByVal keycode)

if keycode = PlungerKey Then
Plunger.Fire
Bullet6 end if

if keycode = LeftFlipperKey Then
LeftFlipper.RotateToStart
PlaySound "FlipperDown"
Bullet6 end if

if keycode = RightFlipperKey Then
RightFlipper.RotateToStart
PlaySound "FlipperDown"
Bullet6 end if

Bullet6 end Sub

Sub Gate_Hit()
GameOn = 0 'zero is used as a "condition" to disable the plunger
ScoreText.text = "GameOn = " & GameOn & vbcr & _
"Plunger is Dead"
End Sub

Sub Drain_Hit()
Drain.DestroyBall
Plunger.CreateBall
PlaySound "Plunger"

'Plunger was deactivated when ball enters thru the Gate, so
'the plunger needs to be activated when the ball drains
GameOn = 1
ScoreText.Text = "GameOn = " & GameOn & vbcr & _
"Plunger is Active"
End Sub

Sub LeftSlingshot_Slingshot()
PlaySound "Bumper"
End Sub

Sub RightSlingshot_Slingshot()
PlaySound "Bumper"
End Sub

Sub Plunger_Init()
PlaySound "Plunger"
Plunger.CreateBall
End Sub


Updated Jun 22, 2005 Written by BJ
 

JonPurpleHaze

Site Nudger
Staff member
Multiple Player Routine

The "HowTo" series of Visual Pinball tables is presented mainly for the person who is trying to understand how to implement certain events in Visual Pinball scripting.
So why create a stand-alone "How-To" table when there are many great tutorial tables already available? Because, as a "newbie", it can be very tedious and often confusing to sort thru lines and lines of scripting devoted to many different features of a table trying to find out how a certain feature is done. My thought was why not just present one feature on a table so that the tedium and confusion might be held to a minimum? The tables will look very dull and flat and very uninteresting and playing them will not be as full of flash and pizzazz as a full blown table. But the intent is, first, to present as clearly and simply as possible the underlying scripting and events of a given feature while, secondly, keeping the table's filesize to a minimum for the sake of convenience. And remember that this is not necessarily "how you do it". What I intended to do was to present the concept of a given feature and to show at least one way to implement the controls to create that feature. The code has been heavily, but simply, commented as to what is going on and why certain things are done. Not every nuance of a feature can be addressed in every case. But by gaining a general understanding of a feature's concept, much less frustration will be experienced when building your table. That helps contribute to keeping a table designer happy, and a happy table designer is a productive table designer! BJ The following is the script from BJ's tutorial table on Multiple Players:
Code

' OOPS! The feature of Multiple Players, for this example, uses several
' tools in order to effect the expected results. All actions are commented
' as often and as simply as possible to keep your head from exploding.

' Lets create some variables to keep track of certain things
' The names describe pretty much what we're keeping track of
Dim HowManyPlayers, PlayerNumber
Dim ScoreP1, ScoreP2, ScoreP3, ScoreP4
Dim GameOn

Sub Table1_Init() 'do all this stuff when the table is first loaded
GameOn = 0
Light1.State = LightStateOff
Light2.State=0 ' same as "LightStateOff"
Light3.State=0
Light4.State=0
PlayerNumber = 0
ScoreP1 = 0
ScoreP2 = 0
ScoreP3 = 0
ScoreP4 = 0

'Display some information
ScoreText.Text = "Press ""5"" to Add a Player," & vbcr & _
"Press ""S"" to Start"
End Sub

Sub AddScore(Points) ' see the "HowTo_KeepScore" table for explanation
'In "case" the value of PlayerNumber is a certain value, do a certain
'action
Select case PlayerNumber
case 1
ScoreP1 = ScoreP1 + Points
ScoreText.Text = ScoreP1
case 2
ScoreP2 = ScoreP2 + Points
ScoreText.Text = ScoreP2
case 3
ScoreP3 = ScoreP3 + Points
ScoreText.Text = ScoreP3
case 4
ScoreP4 = ScoreP4 + Points
ScoreText.Text = ScoreP4
Bullet6 end Select
Bullet6 end Sub
Sub Drain_Hit() 'standard "Drain" script modified for this feature
Drain.DestroyBall

'Script modifications:
'Current player's ball has drained,
'Need to determine which player is next
If PlayerNumber < HowManyPlayers then
PlayerNumber = PlayerNumber + 1
Else
PlayerNumber = 1
End If

CheckScores() ' Call the Bullet6 next subroutine

Plunger.CreateBall
PlaySound "Plunger"
Bullet6 end Sub

Sub CheckScores()
'The following uses a feature called a "Collection"
'I have created a colletion of lights called PlayerLights that includes
'Light1 thru Light4 (one light for each player)
'This will allow easier access to all of the light states at once Bullet6 time
'A nifty feature you should learn to use. It's under the "Tables" menu
'selection on the Editor toolbar.
For Each Light in PlayerLights ' Nifty code to access all of the lights
Light.State = LightStatOff
Bullet6 next
'the following is Code to effect certain events under certain
'conditions or "cases"
'In this "case", the value of PlayerNumber is determined and, according
'to the value, light the appropriate light and display the appropriate
'score value
Select Case PlayerNumber
Case 1
Light1.State = 1
ScoreText.Text = ScoreP1
Case 2
Light2.State = 1
ScoreText.Text = ScoreP2
Case 3
Light3.State = 1
ScoreText.Text = ScoreP3
Case 4
Light4.State = 1
ScoreText.Text = ScoreP4
End Select
End Sub

Sub Bumper1_Hit()
AddScore (100)
'call the "AddScore" subroutine and hand it a value to process
End Sub

Sub Table1_KeyDown(ByVal keycode)

if KeyCode = 6 then ' Coin has been inserted
If HowManyPlayers = 0 then
PlayerNumber = 1
HowManyPlayers = 1
Light1.State = 1
ElseIf HowManyPlayers = 1 then
HowManyPlayers = 2
Light2.State = 1
ElseIf HowManyPlayers = 2 then
HowManyPlayers = 3
Light3.State = 1
ElseIf HowManyPlayers = 3 then
HowManyPlayers = 4
Light4.State = 1
ElseIf HowManyPlayers = 4 then
MsgBox "4 Players is the limit",0,"Player Number Exceeded"
End If
End If

If KeyCode = 19 and GameOn = 1 then' "R" Bullet6 key to Review Scores
MsgBox "Player 1 = " & ScoreP1 & vbcr & vbcr & Bullet6 _
"Player 2 = " & ScoreP2 & vbcr & vbcr & Bullet6 _
"Player 3 = " & ScoreP3 & vbcr & vbcr & Bullet6 _
"Player 4 = " & ScoreP4, 0, "REVIEW SCORES"
Bullet6 end if

if KeyCode = 31 then' "Start" key (S) has been pressed
GameOn = 1
If HowManyPlayers > 0 then
CheckScores()
Else
ScoreText.Text = "Insert Coin"
End If
PlaySound "Plunger"
Plunger.CreateBall
End If

If keycode = PlungerKey Then
If GameOn = 1 Then
Plunger.PullBack
End If
End If

If keycode = LeftFlipperKey Then
LeftFlipper.RotateToEnd
PlaySound "FlipperUp"
End If

If keycode = RightFlipperKey Then
RightFlipper.RotateToEnd

PlaySound "FlipperUp"
End If

If keycode = LeftTiltKey Then
Nudge 90, 2
End If

If keycode = RightTiltKey Then
Nudge 270, 2
End If

If keycode = CenterTiltKey Then
Nudge 0, 2
End If

End Sub

Sub Table1_KeyUp(ByVal keycode)

If keycode = PlungerKey Then
Plunger.Fire
End If

If keycode = LeftFlipperKey Then
LeftFlipper.RotateToStart
PlaySound "FlipperDown"
End If

If keycode = RightFlipperKey Then
RightFlipper.RotateToStart
PlaySound "FlipperDown"
End If

End Sub

Sub LeftSlingshot_Slingshot()
PlaySound "Bumper"
End Sub

Sub RightSlingshot_Slingshot()
PlaySound "Bumper"
End Sub


Updated Jun 22, 2005 Written by BJ
 

JonPurpleHaze

Site Nudger
Staff member
How To Keep Score

The "HowTo" series of Visual Pinball tables is presented mainly for the person who is trying to understand how to implement certain events in Visual Pinball scripting.
So why create a stand-alone "How-To" table when there are many great tutorial tables already available? Because, as a "newbie", it can be very tedious and often confusing to sort thru lines and lines of scripting devoted to many different features of a table trying to find out how a certain feature is done. My thought was why not just present one feature on a table so that the tedium and confusion might be held to a minimum?

The tables will look very dull and flat and very uninteresting and playing them will not be as full of flash and pizzazz as a full blown table. But the intent is, first, to present as clearly and simply as possible the underlying scripting and events of a given feature while, secondly, keeping the table's filesize to a minimum for the sake of convenience.

And remember that this is not necessarily "how you do it". What I intended to do was to present the concept of a given feature and to show at least one way to implement the controls to create that feature. The code has been heavily, but simply, commented as to what is going on and why certain things are done.

Not every nuance of a feature can be addressed in every case. But by gaining a general understanding of a feature's concept, much less frustration will be experienced when building your table. That helps contribute to keeping a table designer happy, and a happy table designer is a productive table designer!

BJ

The following is the code from BJ's HowTo Keep Score Tutorial Table:

Code

Dim Points 'this is the variable we will assign our points for scoring
Dim Score 'this is the variable we will use to keep our accumulated points

'The following will be processed when the table 1st loads
Sub Table1_Init()
Score = 0 ' Naturally!
ScoreText.Text = Score ' Show me the score
End Sub

Sub AddScore(Points) 'take whatever value is given and assign it to "Points"
' update the value of Score by adding the value given to Points to the
' Bullet6 current value of Score
Score = Score + Points
ScoreText.Text = Score ' Show me the money!
End Sub

Sub Bumper1_Hit()
AddScore(100)
' This "calls" the subroutine "AddScore" and hands it a value of 100
' Addscore takes the 100 and assigns it to the variable "Points" and
' then proceeds to process that variable by adding to the Bullet6 current value
' of "Score".
Playsound "Bumper" ' Plays a soundfile
Bullet6 end Sub

Sub Trigger1_Hit()
AddScore(50)
' Same deal as with the Bumper_hit but instead we hand Addscore only
' 50 Points
Playsound "Bumper"
Light1.State=1 ' Turn on "Light1", same as "= LightStateOn"
'NOTE: you can substitute "1" for true and "0" for false conditions
'(helps to reduce your typing keystrokes)
Light1.TimerEnabled = 1
'When Light1's built in timer is enabled, the Light1_Timer sub is
'started (see the Bullet6 next "Light1_Timer" subroutine)
'We could have added a separate Timer to do this, but it is better
'(keeps the table Bullet6 filesize smaller) to use the built-in Light timer
'instead of adding additional and unnecessary objects on the table.
End Sub

Sub Light1_Timer()
'when the Light1 timer is enabled, its assigned Bullet6 time setting will
'elapse (see the Timer Interval for Light1 in the editor) and then the
'following events will be processed
Light1.State = 0 'Turn Light1 off, same as "= LightStateOff"
Light1.TimerEnabled = 0 'Turn off Light1's Timer
End Sub

Sub Wall1_Hit()
Wall1.IsDropped = 1
' This wall will drop when hit
' Same as Wall1.IsDropped = True
'NOTE: Make sure the "Can Drop" box is checked under the wall's "State"
'options in the editor.
'Also note that the "bottom" of the end walls are set to -1 in the
'editor
'This will cause them to completely disappear when dropped.
'if they are left at zero, like the middle wall, the wall tops will
'remain visible on the table surface even when dropped since the
'table's surface is "zero".
AddScore(500)
PlaySound "Bumper"
End Sub

Sub Wall2_Hit() 'See comments for Wall1
Wall2.IsDropped = 1
AddScore(500)
PlaySound "Bumper"
Bullet6 end Sub

Sub Wall3_Hit() 'See comments for Wall1
Wall3.IsDropped = 1
AddScore(500)
PlaySound "Bumper"
End Sub

' The rest of the script is what comes up standard with any new table
' NOTE: the "Drain" subroutine has been modified to pop any dropped walls
' back up whenever a ball is drained (see "Sub Drain_Hit()" below).

Sub Drain_Hit()
Drain.DestroyBall

' Added the following code to the default "Drain" script
' This will pop any of the 3 dropped walls back up
Wall1.IsDropped = false 'similar to Wall1.IsDropped=0
Wall2.IsDropped = False
Wall3.IsDropped = False
'
--
'All remaining script is "standard"

Plunger.CreateBall
PlaySound "Plunger"
End Sub

Sub Table1_KeyDown(ByVal keycode)

If keycode = PlungerKey Then
Plunger.PullBack
End If

If keycode = LeftFlipperKey Then
LeftFlipper.RotateToEnd
PlaySound "FlipperUp"
End If

If keycode = RightFlipperKey Then
RightFlipper.RotateToEnd
PlaySound "FlipperUp"
End If

If keycode = LeftTiltKey Then
Nudge 90, 2
End If

If keycode = RightTiltKey Then
Nudge 270, 2
End If

If keycode = CenterTiltKey Then
Nudge 0, 2
End If

End Sub

Sub Table1_KeyUp(ByVal keycode)

If keycode = PlungerKey Then
Plunger.Fire
End If

If keycode = LeftFlipperKey Then
LeftFlipper.RotateToStart
PlaySound "FlipperDown"
End If

If keycode = RightFlipperKey Then
RightFlipper.RotateToStart
PlaySound "FlipperDown"
End If

End Sub

Sub LeftSlingshot_Slingshot()
AddScore(10) 'Added script to score 10 points
PlaySound "Bumper"
Bullet6 end Sub

Sub RightSlingshot_Slingshot()
AddScore(10) 'Added script to score 10 points
PlaySound "Bumper"
End Sub

Sub Plunger_Init()
PlaySound "Plunger"
Plunger.CreateBall
End Sub


Updated Jun 22, 2005 Written by BJ
 

JonPurpleHaze

Site Nudger
Staff member
5 Ball Multiball

The "HowTo" series of Visual Pinball tables is presented mainly for the person who is trying to understand how to implement certain events in Visual Pinball scripting.
So why create a stand-alone "How-To" table when there are many great tutorial tables already available? Because, as a "newbie", it can be very tedious and often confusing to sort thru lines and lines of scripting devoted to many different features of a table trying to find out how a certain feature is done. My thought was why not just present one feature on a table so that the tedium and confusion might be held to a minimum? The tables will look very dull and flat and very uninteresting and playing them will not be as full of flash and pizzazz as a full blown table. But the intent is, first, to present as clearly and simply as possible the underlying scripting and events of a given feature while, secondly, keeping the table's filesize to a minimum for the sake of convenience. And remember that this is not necessarily "how you do it". What I intended to do was to present the concept of a given feature and to show at least one way to implement the controls to create that feature. The code has been heavily, but simply, commented as to what is going on and why certain things are done. Not every nuance of a feature can be addressed in every case. But by gaining a general understanding of a feature's concept, much less frustration will be experienced when building your table. That helps contribute to keeping a table designer happy, and a happy table designer is a productive table designer! BJ The following is the script from BJ's tutorial table on multiball:
Code

' Declare a variable to keep track of the number
' of balls in play (those that are rolling around)
Dim BallsInPlay

' Declare a variable to keep track of how many
' balls are locked
Dim BallsLocked

' Create a subroutine that sets up various things
' when the table is first opened (INITialized)
Sub Table1_Init()
BallsInPlay = 0 ' No balls rolling around yet
BallsLocked = 0 ' and no balls locked yet
' Lets display the values just to keep track of what's going on
TextBox1.Text = "BallsInPlay: " & BallsInPlay
TextBox2.Text = "BallsLocked: " & BallsLocked
Bullet6 end Sub

' Default script that needs to be modified for our use
Sub Drain_Hit()
Drain.DestroyBall
PlaySound "ComputerButton"
BallsInPlay = BallsInPlay - 1 ' 1 Less ball rolling around now

TextBox1.Text = "BallsInPlay: " & BallsInPlay
TextBox2.Text = "BallsLocked: " & BallsLocked

' You normally don't want to create a ball when there are others
' still active on the table. Check to see what that value is:
If BallsInPlay = 0 then ' No balls are rolling around so,
Plunger.CreateBall
PlaySound "Plunger"
Bullet6 end if
Bullet6 end Sub

Sub CheckBallsInPlay()
' KEY NOTE: we could have typed all this code for each kicker hit,
' but it's easier to type it all out once in it's own subroutine
' and just type the name of the subroutine for each Kicker hit.
If BallsLocked = 5 then ' All locked up, kick 'em out
Kicker1.Kick 150, 10 ' Kick the ball (direction, force)
Kicker2.Kick 150, 10
Kicker3.Kick 150, 10
Kicker4.Kick 210, 10
Kicker5.Kick 210, 10
BallsLocked = 0 ' No more locked balls now
BallsInPlay = 5 ' We got 5 balls rolling around now
elseif BallsInPlay < 1 then ' No balls rolling around . . .
Plunger.CreateBall ' Create one to put into play
PlaySound "Plunger"
Bullet6 end if
' Lets see what those values are
TextBox1.Text = "BallsInPlay: " & BallsInPlay
TextBox2.Text = "BallsLocked: " & BallsLocked
End Sub

Sub Kicker1_Hit() ' This ball is locked up
Playsound "BumpBell"
BallsInPlay = BallsInPlay - 1
BallsLocked = BallsLocked + 1
CheckBallsInPlay()
Bullet6 end Sub

Sub Kicker2_Hit() ' This ball is locked up
Playsound "BumpBell"
BallsInPlay = BallsInPlay - 1
BallsLocked = BallsLocked + 1
CheckBallsInPlay()
End Sub

Sub Kicker3_Hit() ' This ball is locked up
Playsound "BumpBell"
BallsInPlay = BallsInPlay - 1
BallsLocked = BallsLocked + 1
CheckBallsInPlay()
Bullet6 end Sub

Sub Kicker4_Hit() ' This ball is locked up
Playsound "BumpBell"
BallsInPlay = BallsInPlay - 1
BallsLocked = BallsLocked + 1
CheckBallsInPlay()
End Sub

Sub Kicker5_Hit() ' This ball is locked up
Playsound "BumpBell"
BallsInPlay = BallsInPlay - 1
BallsLocked = BallsLocked + 1
CheckBallsInPlay()
Bullet6 end Sub

Sub Gate_Hit() ' A ball has passed onto the table
PlaySound "Fart-13"
BallsInPlay = BallsInPlay + 1
TextBox1.Text = "BallsInPlay: " & BallsInPlay
End Sub

' Standard default table scripting poop from here on down
Sub Table1_KeyDown(ByVal keycode) ' default script

If keycode = PlungerKey Then
Plunger.PullBack
End If

If keycode = LeftFlipperKey Then
LeftFlipper.RotateToEnd
PlaySound "FlipperUp"
End If

If keycode = RightFlipperKey Then
RightFlipper.RotateToEnd
PlaySound "FlipperUp"
End If

If keycode = LeftTiltKey Then
Nudge 90, 2
End If

If keycode = RightTiltKey Then
Nudge 270, 2
End If

If keycode = CenterTiltKey Then
Nudge 0, 2
End If

End Sub

Sub Table1_KeyUp(ByVal keycode) ' default script

if keycode = PlungerKey Then
Plunger.Fire
Bullet6 end if

if keycode = LeftFlipperKey Then
LeftFlipper.RotateToStart
PlaySound "FlipperDown"
Bullet6 end if

if keycode = RightFlipperKey Then
RightFlipper.RotateToStart
PlaySound "FlipperDown"
Bullet6 end if

Bullet6 end Sub

Sub Plunger_Init() ' default script
PlaySound "Plunger"
Plunger.CreateBall
End Sub


Updated Jun 22, 2005 Written by BJ
 

JonPurpleHaze

Site Nudger
Staff member
5 Ball Counter

The "HowTo" series of Visual Pinball tables is presented mainly for the person who is trying to understand how to implement certain events in Visual Pinball scripting.
So why create a stand-alone "How-To" table when there are many great tutorial tables already available? Because, as a "newbie", it can be very tedious and often confusing to sort thru lines and lines of scripting devoted to many different features of a table trying to find out how a certain feature is done. My thought was why not just present one feature on a table so that the tedium and confusion might be held to a minimum? The tables will look very dull and flat and very uninteresting and playing them will not be as full of flash and pizzazz as a full blown table. But the intent is, first, to present as clearly and simply as possible the underlying scripting and events of a given feature while, secondly, keeping the table's filesize to a minimum for the sake of convenience. And remember that this is not necessarily "how you do it". What I intended to do was to present the concept of a given feature and to show at least one way to implement the controls to create that feature. The code has been heavily, but simply, commented as to what is going on and why certain things are done. Not every nuance of a feature can be addressed in every case. But by gaining a general understanding of a feature's concept, much less frustration will be experienced when building your table. That helps contribute to keeping a table designer happy, and a happy table designer is a productive table designer! BJ The following is the script from BJ's tutorial table on 5 Ball Counter:
Code

' This will be assigned a number to keep track of how many pinballs have
' been played
Dim BallNo

Sub Table1_Init() 'when the table is first loaded, assign a value to BallNo
BallNo = 5 'this game will play only 5 pinballs
Light1.State = LightStateOff
Light2.State=0 ' same as "LightStateOff"
Light3.State=0
Light4.State=0
Light5.State=0
ScoreText.Text = "Balls to Play: " & BallNo
End Sub

Sub Gate_Hit() ' when a ball passes thru the chute gate
Light5.State=1 ' turn this light "on" (1 = "True")
ScoreText.Text = "Balls to Play: " & BallNo
End Sub

Sub Drain_Hit()
Drain.DestroyBall

'One ball is gone, subtract 1 from BallNo
BallNo = BallNo - 1
'As long as BallNo doesn't equal zero, there are more balls to play
if BallNo > 0 then
'A nifty way to determine which ball light to turn on
'to indicate which ball is going to be played
Select case BallNo
case 1
Light1.State = LightStateOn
case 2
Light2.State=1 ' same as "LightStateOn"
Case 3
Light3.State=1
Case 4
Light4.State=1
Case 5
Light5.State=1
End Select
ScoreText.Text = "Balls to Play: " & BallNo ' tell me what ball is playing
Plunger.CreateBall
PlaySound "Plunger"
else 'If BallNo is zero, all balls have been played
ScoreText.Text = "GameOver"
PlaySound "whuuuuh"
'Notice that we don't create another ball at the plunger . . .
'. . . how sad!
Bullet6 end if
Bullet6 end Sub

'Standard table scripting follows
Sub Table1_KeyDown(ByVal keycode)

If keycode = PlungerKey Then
Plunger.PullBack
End If

If keycode = LeftFlipperKey Then
LeftFlipper.RotateToEnd
PlaySound "FlipperUp"
End If

If keycode = RightFlipperKey Then
RightFlipper.RotateToEnd
PlaySound "FlipperUp"
End If

If keycode = LeftTiltKey Then
Nudge 90, 2
End If

If keycode = RightTiltKey Then
Nudge 270, 2
End If

If keycode = CenterTiltKey Then
Nudge 0, 2
End If

End Sub

Sub Table1_KeyUp(ByVal keycode)

If keycode = PlungerKey Then
Plunger.Fire
End If

If keycode = LeftFlipperKey Then
LeftFlipper.RotateToStart
PlaySound "FlipperDown"
End If

If keycode = RightFlipperKey Then
RightFlipper.RotateToStart
PlaySound "FlipperDown"
End If

End Sub

Sub Plunger_Init()
PlaySound "Plunger"
Plunger.CreateBall
End Sub


Updated Jun 22, 2005 Written by BJ 1648 reads
 
General chit-chat
Help Users
  • No one is chatting at the moment.
    Top