Jump to content



Photo
- - - - -

How to use controller.vbs for SS tables in depth

Tutorials Visual Pinball

  • Please log in to reply
15 replies to this topic

#1 arngrim

arngrim

    DJ Force Feedback

  • VIP
  • 2,188 posts
  • Location:Charleroi, Belgium

  • Flag: Belgium

  • Favorite Pinball: Monster bash



Posted 08 January 2016 - 05:57 PM

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

 

323646Sanstitre.png

 

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)

 

'ForceDisableB2S = 0
'DOFContactors   = 2
'DOFKnocker      = 2
'DOFChimes       = 2
'DOFBell         = 2
'DOFGear         = 2
'DOFShaker       = 2
'DOFFlippers     = 2
'DOFTargets      = 2

'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.


#2 Knorr

Knorr

    Enthusiast

  • Platinum Supporter
  • 221 posts
  • Location:Amstetten

  • Flag: Austria

  • Favorite Pinball: Dirty Harry

Posted 08 January 2016 - 07:01 PM

Thx for that explanation! I will do my best with the next table :)

#3 gtxjoe

gtxjoe

    VPF Veteran

  • VIP
  • 5,060 posts

  • Flag: United States of America

  • Favorite Pinball: Medieval Madness, AbraCadabra



Contributor

Posted 08 January 2016 - 07:42 PM

This needs to be a tutorial... Oh wait, it is !   :)

 

Thanks arngrim



#4 arngrim

arngrim

    DJ Force Feedback

  • VIP
  • 2,188 posts
  • Location:Charleroi, Belgium

  • Flag: Belgium

  • Favorite Pinball: Monster bash



Posted 08 January 2016 - 09:18 PM

if somebody wants to confirm a table, send it to me and i will check and revert to you ;)

#5 ninuzzu

ninuzzu

    Enthusiast

  • Members
  • PipPipPip
  • 179 posts

  • Flag: Italy

  • Favorite Pinball: Tommy, BDK, Hook and many more....

Posted 25 January 2016 - 07:12 PM

Somehow I missed this...very useful, thank you!


Videotutorials: plastic ramps in blender------>part1     part2


#6 scrivy

scrivy

    Hobbyist

  • Platinum Supporter
  • 24 posts

  • Flag: United States of America

  • Favorite Pinball: Creature from the Black Lagoon

Posted 01 February 2016 - 05:20 PM

arngrim:

 

Every table created with Controller.vbs is creating problems for my cabinet and here is why:

Everything on my system is configured correctly and has always worked until Controller.vbs arrived.   The b2s server is installed, controller.txt exists in the User folder, latest Controller.vbs file is installed in the Scripts folder, table.vpx and backglass.b2s are installed in the Tables folder with the exact same names.   The correct rom file exits in the roms folder.

With forcedisableB2S=0 in Controller.txt, Line in table script containing ".GameName = CGameName" creates an error "Can not create ActiveX Component".   Game can not start.

With forcdedisableB2S=1 configured in Controller.txt, the table loads but no backglass (proves it sees Controller.txt found in User folder)

Last problem which is huge is the fact that due to system limitations with some backglasses that are too intensive, I have to only use a static backglass that is loaded with menu system PinballX.   I then drag the DMD to the correct spot.   Controller.vbs configuration allows for no individual handling of this exception on a per game basis.   It's either all tables have to have a backglass or none of them.  This is very problematic for those with systems that can't handle the load of a two screen overhead.

Do you have any solutions to these problems?   I have tried both vpx 10 and 10.1... same problem.  I am on an XP Windows system.   If this problem is not solved my ability to play future games will come to an end.



#7 Outhere

Outhere

    Pinball Wizard

  • Platinum Supporter
  • 4,720 posts

  • Flag: United States of America

  • Favorite Pinball: M M

Posted 01 February 2016 - 06:22 PM

When you put VP 10 on did you do the full install or the standalone?

Are all your VBS files in the script folder or in a table folder or do you have them in both places and if you have it in both places are the VBS files identical to each other?

I have read in other post where people that are running XP are having a hard time with the newest VP...

-
As far as the back glass did you try making changes to the back glass software, another words right click the back glass when its running and you can change some of the settings in there and make sure it's running in exe.


 



#8 gtxjoe

gtxjoe

    VPF Veteran

  • VIP
  • 5,060 posts

  • Flag: United States of America

  • Favorite Pinball: Medieval Madness, AbraCadabra



Contributor

Posted 02 February 2016 - 02:10 AM

For the forceddisableB2S=0 and game not starting, post a specific table and backglass link so we can see if we have the same issue

Wanting to use a static backglass and not directb2s backglass, why don't you just delete the directb2s backglass file?

There might still be a benefit to allow table by table over-ride, I can send arngrim some ideas...

Edited by gtxjoe, 02 February 2016 - 02:10 AM.


#9 Slydog43

Slydog43

    Pinball Wizard

  • Platinum Supporter
  • 3,006 posts
  • Location:Hackettstown, NJ

  • Flag: United States of America

  • Favorite Pinball: Addams Family, All Williams 90's Games

Posted 02 February 2016 - 04:50 AM

Can this be used with VP9.x tables as well as VPX tables?



#10 arngrim

arngrim

    DJ Force Feedback

  • VIP
  • 2,188 posts
  • Location:Charleroi, Belgium

  • Flag: Belgium

  • Favorite Pinball: Monster bash



Posted 02 February 2016 - 10:23 AM

scrivy, can you copy the content of the vbs into the script of one table and try to see if that change something
i can also teamview your system if it doesn't work
yes definitely it is for vp9 also
scrivy, remove the call of the vbs when you migrate the code to the script

#11 scrivy

scrivy

    Hobbyist

  • Platinum Supporter
  • 24 posts

  • Flag: United States of America

  • Favorite Pinball: Creature from the Black Lagoon

Posted 14 March 2016 - 07:00 PM

When you put VP 10 on did you do the full install or the standalone?

Are all your VBS files in the script folder or in a table folder or do you have them in both places and if you have it in both places are the VBS files identical to each other?

I have read in other post where people that are running XP are having a hard time with the newest VP...

-
As far as the back glass did you try making changes to the back glass software, another words right click the back glass when its running and you can change some of the settings in there and make sure it's running in exe.


I installed the standalone.    My VBS files are in the script folder and no place else.   No duplications.   I can't do anything with the back glass because the table can't load it and complains"Can not create ActiveX Component". .   The problem I am testing this on is Dirty Harry, VP10 version and the only directb2s available for download here.



#12 scrivy

scrivy

    Hobbyist

  • Platinum Supporter
  • 24 posts

  • Flag: United States of America

  • Favorite Pinball: Creature from the Black Lagoon

Posted 14 March 2016 - 07:16 PM

For the forceddisableB2S=0 and game not starting, post a specific table and backglass link so we can see if we have the same issue

Wanting to use a static backglass and not directb2s backglass, why don't you just delete the directb2s backglass file?

There might still be a benefit to allow table by table over-ride, I can send arngrim some ideas...

 

For testing purposes, use VP10 Dirty Harry versions and the directb2s posted on vpforums.    Deleting the directb2s file accomplishes nothing.   "forceddisableB2S=1" in "User/Controller.txt" disregards the directb2s and doesn't load it (wouldn't matter if the directb2s file was there or not).    I wouldn't want to do have this kind of a global setting because then all tables would ignore the back glass.    "forceddisableB2S=0" in "controller.txt"  creates an "Active X" error (doesn't matter if the directb2s file is there or not).   Please let me know if you can duplicate this problem with Dirty Harry.



#13 scrivy

scrivy

    Hobbyist

  • Platinum Supporter
  • 24 posts

  • Flag: United States of America

  • Favorite Pinball: Creature from the Black Lagoon

Posted 14 March 2016 - 07:31 PM

scrivy, can you copy the content of the vbs into the script of one table and try to see if that change something
i can also teamview your system if it doesn't work
yes definitely it is for vp9 also
scrivy, remove the call of the vbs when you migrate the code to the script

Arngrim:

 

I did  exactly what you said, compiled the script and tried to play the table.   I got the same ActiveX error with "forceddisableB2S=0" set in Controller.txt .   I am testing on VP10 Dirty Harry and the directb2s back glasses that are posted here on vpforums.



#14 BigBoss

BigBoss

    Pinball Fan

  • VP Dev Team
  • PipPipPipPip
  • 749 posts

  • Flag: ---------

  • Favorite Pinball: Attack From Mars, Metallica, Theatre Of Magic, Shadow, Star Trek

Posted 10 April 2016 - 11:50 PM

This is all great. Where does someone actually get the controller.vbs file? Now there are tables using it and it's extremely hard to find. Searching "Visual pinball x" in the search box only provides a stand alone exe.



#15 Outhere

Outhere

    Pinball Wizard

  • Platinum Supporter
  • 4,720 posts

  • Flag: United States of America

  • Favorite Pinball: M M

Posted 11 April 2016 - 12:12 AM

http://www.vpforums....982#entry330264



#16 arngrim

arngrim

    DJ Force Feedback

  • VIP
  • 2,188 posts
  • Location:Charleroi, Belgium

  • Flag: Belgium

  • Favorite Pinball: Monster bash



Posted 24 August 2016 - 06:11 AM

update in the first post, about the new controller.vbs, everything that is red ;)





Also tagged with one or more of these keywords: Tutorials, Visual Pinball