Jump to content



Tutorial info Visit support topic

  • Added on: Dec 20 2013 12:25 AM
  • Date Updated: Dec 24 2013 11:59 PM
  • Views: 12241
 


* * * * *
2 Ratings

Basic VPinmame table recreation

How to start a new pinball table based on a real machine (with ROM/VPinmame integration)

Posted by mfuegemann on Dec 20 2013 12:25 AM
Hello,
 
creating my first table from scratch, I made some notes and now want to publish them as there were no tutorial so basic as I have wished for. For me the hardest part was to understand, that table creation with a link to VPinmame and using the table ROMs is not difficult at all.
To encourage You to just start creating, I compiled the following lines. I am quite aware of my limited knowledge regarding VPin table creation, but if one thinks comments are necessary, I will be glad to improve this tutorial. So send me every hint You have on this matter, please.
As RAB was the table, I created while writing down this notes, You can refer to the actual script of this table (both desktop or FS version). It is in general a good idea to check out other tables for elegant approaches to a specific problem or for new ideas. If You want to mod an existing table or want to use resources introduced by other developers, ask before You start - this can save You quite a bit of time.
 
Visual Pinball – Table Creation with ROM integration
 
0. Preliminaries
 
Before You should start with the actual table creation it is necessary to collect sufficient documentation and pictures of the Pin to be recreated.
- Playfield picture (bring it to the correct proportions and scale to max. 4096 pixels, if larger)
- Plastics
- schematic playfield-drawing (using a graphics program, match this drawing to the playfield picture using layers and adjust the elements to the actual playfield picture)
- Operators handbook with light-, switch- and solenoidnumbers
- Videos of the table in action (Youtube etc.) or a real table to compare the simulation with
- Keep the VBS-documentation close (http://www.vpforums....als/vbsdoc.html)
 
1. Creating a new table
 
Create a new table and add two timers:
PinMameTimer  enabled  Interval=1
PulseTimer    enabled  Interval=40
 
2. Script - loading VPinmame
 
The following lines will be placed at the start of the table script (*.VBS-filename depends on the pinball manufacturer, constants for lights and sound):
 

Option Explicit
LoadVPM "01560000","DE.VBS",3.1
Sub LoadVPM(VPMver, VBSfile, VBSver)
  On Error Resume Next
  If ScriptEngineMajorVersion < 5 Then MsgBox "VB Script Engine 5.0 or higher required"
  ExecuteGlobal GetTextFile(VBSfile)
  If Err Then MsgBox "Unable to open " & VBSfile & ". Ensure that it is in the same folder as this table. " & vbNewLine & Err.Description : Err.Clear
  If Err Then MsgBox "Can't Load VPinMAME." & vbNewLine & Err.Description
  if VPinMAMEDriverVer < VBSver Or Err Then MsgBox VBSFile & " ver " & VBSver & " or higher required."
End Sub
Const UseSolenoids=1,UseLamps=1,SSolenoidOn="SolOn",SSolenoidOff="SolOff",SFlipperOn="FlipperUp",SFlipperOff="FlipperDown",SCoin="coin3"

 
 
3.  Script - table-init
 
The next procedure initializes the table and establishes a link to VPinmame. The name of the procedure consists of the table name (Editor-Option Table - Name) and "_init"
 

Sub RAB_Init
 vpminit me

 On Error Resume Next
  Set Controller=CreateObject("VPinMAME.Controller")
  If Err Then MsgBox "This game requires VPinMAME.":Exit Sub

 Const cgamename = "rab_320"                                                       'this is the actual rom file name from Your VPinmame ROM folder without the .zip extension
  Controller.GameName=cGameName
  Controller.SplashInfoLine="Adventures of Rocky and Bullwinkle and Friends" & vbNewLine & "Created by ..."
  Controller.HandleKeyboard=0
  Controller.ShowTitle=0
  Controller.ShowFrame=0
  Controller.HandleMechanics=0
  Controller.Run
  If Err Then MsgBox Err.Description
  On Error Goto 0
 
  PinMAMETimer.Interval=PinMAMEInterval
 PinMAMETimer.Enabled = true

  vpmNudge.TiltSwitch=1                       'apply the correct switchnumber
  vpmNudge.Sensitivity=2
End Sub

 
4. Trough
 
For the handling of the balls in play You need several items
- Outhole or Drain (Kicker at the lower end of the table, capturing lost balls) - adjust the surrounding walls in a way that every ball ends at this kicker.
  Within the script the following already existing function will be modified: 

  Sub Drain_Hit()
   vpmTimer.PulseSwitch(10),0,0              'apply the correct switchnumber
   bsTrough.AddBall Me
   playsound "outhole" 
  End Sub

 
- Ball Release (Kicker next to the Plunger lane, feeding the next ball into play) - create a space next to the plunger lane so that the ball can roll towards the plunger an place a invisible gate in front of it.
- Ballstack to handle the balls
  The following code will be added to the procedure <Table>_Init:


  Set bsTrough=New cvpmBallStack
      bsTrough.InitSw 0,13,12,11,0,0,0,0                 'apply the correct switchnumbers - refer to the VBS-documentation
      bsTrough.InitKick BallRelease,90,5                 'the ball release kicker in the example is named "BallRelease"
      bsTrough.InitExitSnd "BallRel","Solenoid"
      bsTrough.Balls=3                                   'specify the correct ball count
   

  Add the variable declaration before the procedure <Table>_Init:


  Dim bsTrough

  
5. Playfield (insert) lights
 
Place every playfield lamp mentioned in the documentation on the playfield and adjust the position to the playfield schematic. The final adjustments will later be done according to the playfield picture.
Using a lights collection makes the light handling very easy. Therefore You have to create a new collection (Table - Collection Manager) to which all playfield-lamps (no flashers) will be added. For every lamp You have to specify the light number from the manual within the field "Timer Interval" (Timer enabled = false).
Adding the statement
 

vpmMapLights AllLights                 'AllLights is the name of the collection

 
to the procedure <Table>_Init gives over the control of all Your playfield lights to VPinmame.
 
6. Key-mapping
 
Delete the procedure Plunger_Init from the script. Add the following line to the procedure "Sub rab_KeyDown(ByVal keycode)", to let the standard keystrokes be handled by the program:
 
If KeyDownHandler(keycode) Then Exit Sub
 
Add the following line to prcedure "Sub rab_KeyUp(ByVal keycode)", to let the standard keystrokes be handled by the program:
 
If KeyUpHandler(keycode) Then Exit Sub
 
>>> if necessary a special handling for keys not recognized by the *.vbs file can be added (for instance, if the standard is using wrong switch numbers) <<<


If keycode = LeftFlipperKey Then Controller.Switch(15) = True:End if
If keycode = RightFlipperKey Then Controller.Switch(16) = True:End if

 
7. Solenoid-assignment using SolCallback
 
Before the procedure <Table>_Init You have to add assignments for every solenoid You want to use. This can be done by assigning a standard-VPinmame-procedure
or by a call of Your own procedures:
 
Using VPinmame:

SolCallback(12) = "vpmSolDiverter RampDiverter,true,"   'Sol12 Ramp Diverter

SolCallback(17) = "vpmSolSound ""Bumper"","             'Sol17 Left Bumper

 
Using own procedures or object methods:


SolCallback(1)  = "bsTrough.SolIn"                      'Sol1 Outhole
SolCallback(2) = "bsTrough.SolOut"                    'Sol2 Ball Release
SolCallback(22) = "LaserKick"                             'Sol22

 

Sub LaserKick(Enabled)
 if enabled then LaserKickPlunger.fire
End Sub

 
It is a good idea to list all solenoids mentioned within the documentation (commented) and add every assignment one by one
 
>>> from this point on You can run the table, as all basics are functional <<<
 
8. Playfield-elements (Walls, Ramps etc.)
 
Using pictures of the actual table, schematics and the documentation all playfield elements will be placed on the playfield. Keep in mind, that the ball is 48 units in diameter, so all the standard walls should be 50 units high. If You are unsure, if a ball can travel through a specific area, You can create a light with a radius of 25 units and drag it with the mouse along the passage in question.
Elements You have to place on the table are walls, ramps and also Saucers and Triggers, that will be connected to VPinmame in the next step.
 
9. Switch-assignment using procedures
 
To transmit signals to VPinmame a set of two procedures per switch has to be added to the script:
 

sub trigger34_hit:Controller.Switch(34)=1:End Sub     'switch 34
sub trigger34_unhit:Controller.Switch(34)=0:End Sub

 

Elements like Bumpers, Targets, Droptargets will need only the Trigger_Hit event:
 

sub Bomb_25_hit:vpmTimer.pulseSw 25:Playsound "Target1":End Sub       'switch 25

 
10. Flashers
 
Flashers will be triggered by Solenoid-calls. Here You have several options too.
First playfield-flashers can be handled like playfield lights:
 

SolCallback(18) = "sol18"

 

Sub Sol18(Enabled)
 flasher18.state=abs(Enabled)            'flasher18 is a light
End Sub

 
The second option are EM-reels with an on/off image:
 

SolCallback(19) = "EMReel.SetValue "

 
To accomplish this, an EM-reel with two pictures (Digit Range 0->1, Use Image Grid = True) has to be placed on the Backdrop. The image used by the EM-reel consists of two pictures of the flasher lamp (lit/unlit) with identical dimensions. Set the property "Images per Row" of the EM-reels according to the orientation of the two picture parts (1 or 2).
 
Additional options for flashers are alpha ramps to lighten areas of the playfield when the flasher is activated and droppable walls to show different versions of the playfield.
 
11. Test of basic functionality
 
How does playing the table feel? Are the ramps too steep, turns too wide/narrow? Does the ball drain too often? Are the returning balls directed to the correct flippers?
The best way here is to compare the simulation to a test video or the real table, where possible. Before You adjust the features try to figure out the best settings for gravity, table slope and contact friction, as those settings greatly affect the ball paths on the table.
To prevent excessive ball jumps You can place a trigger at the top of each ramp reducing the Z (=up) velocity of the ball:
 

Sub Trigger1_Hit
 Activeball.velz=0
End Sub

 
12. Toys and game specific functions
 
The next step is the implementation of game specific toys like magnets, VUKs, holes, motors which require a separate approach in almost every case.
 
13. Visual finish
 
The last step is to add the plastics, decals and the apron to the table. For the plastics You create a copy of the playfield picture for every layer/level of plastics. So You can add different pictures to the plastic-walls and are able to create overlapping plastics. Keep in mind that the picture shown at the top of a wall is always a part of a complete playfield sized picture.
You can adjust the shapes of the playfield lights to the playfield picture, tune the ramps with edges, place nicer posts and rubbers etc.
A nice trick is to use invisible elements to handle the ball physics (for instance a flat ramp) and place uncollidable but visible elements to do the visual job (as multiple wires for the invisible ramp mentioned before).
Define the visual settings for the display on the screen. This can be done within the backdrop options using the fields within the section "Colors&Formatting"
 
14. Final test
 
Test the table with different preference settings (Video - Preferences) and if possible using different hardware.
For testing purposes it is convinient to place a pair of trigger/kicker onto the table to send the ball to a specific area of choice. The trigger will be placed inside the plunger lane and the kicker at the desired area:
 

Sub Trigger_Hit()

  Trigger.destroyball

  Kicker.createball

  Kicker.kick 270,25      'angle, force

End Sub

 
You should disable the kicker to avoid catching a ball rolling over this kicker during normal gameplay after the test started.
 
15. Release
 
If You plan to release Your table, plan for several days of continued support, as despite all efforts, You undertook testing Your table, new things will be discovered by the community almost instantly. Fixing major issues in time is a kind move and will secure future support by the crowd You just started to feed.
 
 
Regards
Michael