The controller.vbs is a new vbs available in the vpx package, you may have seen some tables using, all done by me (not anymore ), i want to give the authors some explanations on how to fully implement it, so my wish is that i don’t need to go through every author on pm to give them the modded table, i can't do that for all the tables and there is really a need
Update : A new version of the controller.vbs arise in the Beta 10.2 VPX Package, it uses now the registry to store and read the controller values, instead of the controller.txt previously, the new controller.vbs is compatible with all tables that implements the controller.vbs, including VPX all versions, VP9 (perhaps VP8, but never tested it myself ), the controller values can be changed from the keys menu in VPX 10.2
or in the registry folder HKEY_CURRENT_USER\SOFTWARE\Visual Pinball\Controller\
And these are the default values that will be inserted at the first launch of the new vbs, 2 means Force Feedback and Digital Sounds (force feedback won't be used if you don't have DOF, no worries)
'DOFDropTargets = 2
So 3 new variables for splitting the sounds, explained below where to use them, still in red
A little bit of history, and some explanations why it is good to use it, first we had this to load the controller:
This is not required anymore
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
Set Controller=CreateObject("VPinMAME .Controller")
If Err Then MsgBox"Can't Load VPinMAME."&vbNewLine&Err.Description
If VPMver>""Then If Controller.Version<VPMver Or Err Then MsgBox"VPinMAME ver "&VPMver&" required.":Err.Clear
If VPinMAMEDriverVer<VBSver Or Err Then MsgBox VBSFile&" ver "&VBSver&" or higher required."
On Error Goto 0 End Sub
Because it is integrated into the controller.vbs, which auto detects if B2S.Server is installed so users don’t need to update the script
They were other more complex implementations, which use the ccontroller.txt for example.
You can remove the related code if you mod a table that has it:
'*DOF method for rom controller tables by Arngrim********************
'*******Use DOF 1**, 1 to activate a ledwiz output*******************
'*******Use DOF 1**, 0 to deactivate a ledwiz output*****************
'*******Use DOF 1**, 2 to pulse a ledwiz output**********************
Sub DOF(dofevent, dofstate)
If cController>2 Then
If dofstate = 2 Then
Controller.B2SSetData dofevent, 1:Controller.B2SSetData dofevent, 0
Else
Controller.B2SSetData dofevent, dofstate
End If
End If
End Sub
'********************************************************************
Function SoundFX (sound)
If cController = 4 Then 'Table sounds disabled
SoundFX = ""
Else 'Table sounds enabled
SoundFX = sound
End If
End Function
Also somehow integrated into the controller.vbs
So basically, you have to call the controller.vbs at the very top of the script
On Error Resume Next
ExecuteGlobal GetTextFile("controller.vbs")
If Err Then MsgBox "You need the controller.vbs in order to run this table, available in the vp10 package"
On Error Goto 0
And you need to have a cGameName, the rom variable: like
Const cGameName = "dh_lx2"
And that's all for the basis part
Now let's talk about the SoundFX method
More and more cab users have Force Feedback on their cab, using the DOF interface, and the ini files of the Configtool that contains the mapping of the solenoid and switches for each rom.
The problem is if you have contactors to simulate the bumpers, slingshots, flippers, you don't want to hear the flipper or bumper sounds while the contactors are fired, it's duplicate.
So the SoundFX method avoid that problem, it needs 2 parameters, the sound to be played and a variable that says if you have the respective toy or not, if yes, it won't play the sound.
The value of that variable is taken from the controller.txt, which is created at the first usage of the controller.vbs, and asks you which toy you have.
I will show you the changes that i implement to make it DOF Compliant
So for the sounds that are simulated by contactors:
Flippers:
Sub SolLFlipper(Enabled)
If Enabled Then
PlaySound SoundFX("FlipperUpLeft",DOFFlippers):LeftFlipper.RotateToEnd
Else
PlaySound SoundFX("FlipperDown",DOFFlippers):LeftFlipper.RotateToStart
End If
End Sub
Bumpers:
Sub Bumper63_hit:vpmTimer.pulseSw 63:Playsound SoundFX("BumperLeft",DOFContactors):Me.TimerEnabled = 1: End Sub
Slingshots:
Sub RightSlingShot_Slingshot
PlaySound SoundFX ("SlingshotLeft",DOFContactors), 0, 1, 0.05, 0.05
Ball release is subject to soundfx also:
Set bsTrough = New cvpmBallStack
With bsTrough
.InitSw 0, 32, 33, 34, 35, 0, 0, 0
.InitKick BallRelease, 90, 10
.InitExitSnd SoundFX("BallRelease",DOFContactors), SoundFX("fx_Solenoid",DOFContactors)
.Balls = 4
.IsTrough = 1
End With
All kickers (the exit sounds only)
Set bsSafeHouse = New cvpmBallStack
bsSafeHouse.InitSaucer sw73, 73, 167, 22
bsSafeHouse.InitExitSnd SoundFX("SafeHouseKick",DOFContactors), SoundFX("fx_Solenoid",DOFContactors)
bsSafeHouse.KickForceVar = 2
bsSafeHouse.KickAngleVar = 0.8
Autoplungers
Sub AutoPlunge(Enabled)
if enabled then
AP = True
Kicker1.Kick 0,50
PlaySound SoundFX("Plunger",DOFContactors)
End if
End Sub
All Targets
Sub Standup27_Hit:vpmTimer.pulseSw 27:Standup27p.RotY=Standup27p.RotY -3:Playsound SoundFX("target",DOFTargets):Me.TimerEnabled = 1: End Sub
All Drop Targets
Set dtR=New cvpmDropTarget
dtR.InitDrop Array(sw1,sw2,sw3,sw4,sw5),Array(1,2,3,4,5)
dtR.InitSnd SoundFX("DTDrop",DOFDropTargets),SoundFX("DTReset",DOFContactors)
All Diverters
SolCallback(17)= "vpmSolDiverter OutGate, SoundFX(""gate"",DOFContactors), Not"
For the other toys, Knocker
SolCallback(6)= "vpmSolSound SoundFX(""Knocker"",DOFKnocker),"
For the moving parts of the playfield, like the gun of dirty harry, it is simulated by the Gear toy:
Sub SolGunMotor(Enabled)
If Enabled Then
PlaySound SoundFX("GunMotor",DOFGear)
GDir = -1
UpdateGun.Enabled=1
Controller.switch(77) = 1
Else
UpdateGun.Enabled=0
Controller.switch(77) = 0
StopSound "GunMotor"
End If
The Shaker sounds, rare but if the table has one, do like this
Sub ShakerMotor(enabled)
If enabled Then
ShakeTimer.Enabled = 1
PlaySound SoundFX("motor4",DOFShaker), 20
Else
ShakeTimer.Enabled = 0
End If
End Sub
Shaker is also used for Magnets
Sub PresenzaSuMagnete_Hit()
If DocMagnet.MagnetON= True Then DepotenziaMagnete.Enabled=True: Playsound SoundFX("Magnete",DOFShaker): SpegneLuciTavolo
PallaSuMagnete=1
End Sub
You have also the big Bell, i don't have an example next to me, but the variable is DOFBell, and DOFChimes for the chimes, this is more for EM tables, other discussion
The Nudge sounds must be muted like this, having force feedback assume playing on a cab, so we nudge for real
If keycode = LeftTiltKey Then LeftNudge 80, 1, 20:PlaySound SoundFX("nudge_left",0)
If keycode = RightTiltKey Then RightNudge 280, 1, 20:PlaySound SoundFx("nudge_right",0)
If keycode = CenterTiltKey Then CenterNudge 0, 1.2, 25:PlaySound SoundFX("nudge_forward",0)
The rest of the sounds are normally not subject to simulation with force feedback, like the rollovers, drain, ball going to holes,
Ok, following this you should be able to do a DOF Compliant table , because adding force feedback is something that is done externally from the script, and is contained inside the ini files of the configtool
I hope it is useful enough, if you have some questions, i'm here to help, helping you will help me in the end
Edited by arngrim, 23 December 2016 - 07:44 PM.