Feature time, this time an update to the scripts (via a new file called 'controller.vbs') by arngrim, to abstract DOF, B2S, VPM and EM controller handling, here the header of the vbs file:
***Controller.vbs version 1.0***'
by arngrim
This script was written to have a generic way to define a controller, no matter if the table is EM or SS based.
It will also try to load the B2S.Server and if it is not present (or forced off),
just the standard VPinMAME.Controller is loaded for SS generation games, or no controller for EM ones.
At the first launch of a table using Controller.vbs, it will launch a popup window to setup whether to use DOF, and if selected,
there will be additional options if one uses a certain type of toy, and to determine whether the sounds will be replaced by DOF calls (mostly for EM tables).
Controller.vbs will also create a Controller.txt inside the user folder of VP, here an example of its content:
forcedisableB2S=0
UseDOFcontactors=1
UseDOFKnocker=1
UseDOFChimes=0
UseDOFBell=1
UseDOFGear=1
UseDOFShaker=1
If B2S.Server is setup but one doesn't want to use it, one should change the first line to forcedisableB2S=1
Table script usage:
This needs to be added on top of the script on both SS and EM tables:
On Error Resume Next
ExecuteGlobal GetTextFile("Controller.vbs")
If Err Then MsgBox "Unable to open Controller.vbs. Ensure that it is in the same folder as this table."
On Error Goto 0
In addition the name of the rom (or the fake rom name for EM tables) is needed, because we need it for B2S (and loading VPM):
cGameName = "rom_name"
For SS tables, the traditional LoadVPM method must be -removed- from the script
as it is fully integrated into this script (leave the actual call in the script, of course),
so search for something like this in the table script and -comment out or delete-:
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
Set Controller = CreateObject("B2S.Server")
'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."
If VPinMAMEDriverVer <VBSver Or Err Then MsgBox VBSFile & " ver " & VBSver & " or higher required."
On Error Goto 0
End Sub
For EM tables, in the table_init, call:
LoadEM
Finally, all calls to the B2S.Server Controller properties must be surrounded by a B2SOn check, so for example:
If B2SOn Then Controller.B2SSetGameOver 1
Or "If ... End If" for multiple script lines that feature the B2S.Server Controller properties, for example:
If B2SOn Then
Controller.B2SSetTilt 0
Controller.B2SSetCredits Credits
Controller.B2SSetGameOver 1
End If
That's all 
Optionally, if one wants to add the automatic ability to mute sounds and switch to DOF calls instead
(based on the toy configuration that is set at the first run of a table), one can use three variants:
For SS tables:
PlaySound SoundFX("sound", DOF_toy_category)
If the specific DOF_toy_category (knocker, chimes, etc) is set to 1 in the Controller.txt,
it will not play the sound but play "" instead.
For EM tables, usually DOF calls are scripted and directly linked with a sound, so SoundFX and DOF can be combined to one method:
PlaySound SoundFXDOF("sound", DOFevent, State, DOF_toy_category)
If the specific DOF_toy_category (knocker, chimes, etc) is set to 1 in the Controller.txt,
it will not play the sound but just trigger the DOF call instead.
For pure DOF calls without any sound (lights for example), the DOF method can be used:
DOF(DOFevent, State)
This will be included in the next update..
Edited by toxie, 08 December 2015 - 11:23 PM.