This topic came up in VP10 thread but let's discuss it further here. Most of the recent tables use cController 1 = vPinmame, 2 = UVP, 3 = B2S and now 4 = B2S with DOF (disable VP mech related sounds). The proposal here is to add one more cController value.
cController = 0 which means "Read controller setting from the Visual Pinball\User\cController.txt file. Users can create the cController.txt file and put in desired default controller (1, 2, 3 or 4) and all tables with cController = 0 would launch with the desired controller. If you want to over-ride the default controller, just open the script and set it to 1,2,3 or 4 and then the value in cController.txt would be ignored. The benefit obviously is that you can download a table and put it on your laptop and it runs vPinMame. Download it to your pincab and the same table without script changes now runs B2S server with DOF
For this to work, authors would need to release future VP tables with script support to read from the cController.txt file and a default value of cController = 0. Below is a working version of LoadVPM subroutine that supports the cController.txt file (If this file does not exist the script below will create one automatically and default it to 1 (vPinmame)
Sound good? Sound bad? Thoughts? ![]()
[Note: Option 4 is used to disable VP mech sounds. One approach to do this relies on the use of the SoundFX function, so I have included a modified version of this which will work with the new LoadVPM sub]
'******************* Options *********************
' DMD/Backglass Controller Setting
Const cController = 0 '0=Use value defined in cController.txt, 1=VPinMAME, 2=UVP server, 3=B2S server, 4=B2S with DOF (disable VP mech sounds)
'*************************************************
Dim cNewController
Sub LoadVPM(VPMver, VBSfile, VBSver)
Dim FileObj, ControllerFile, TextStr
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
cNewController = 1
If cController = 0 then
Set FileObj=CreateObject("Scripting.FileSystemObject")
If Not FileObj.FolderExists(UserDirectory) then
Msgbox "Visual Pinball\User directory does not exist. Defaulting to vPinMame"
ElseIf Not FileObj.FileExists(UserDirectory & "cController.txt") then
Set ControllerFile=FileObj.CreateTextFile(UserDirectory & "cController.txt",True)
ControllerFile.WriteLine 1: ControllerFile.Close
Else
Set ControllerFile=FileObj.GetFile(UserDirectory & "cController.txt")
Set TextStr=ControllerFile.OpenAsTextStream(1,0)
If (TextStr.AtEndOfStream=True) then
Set ControllerFile=FileObj.CreateTextFile(UserDirectory & "cController.txt",True)
ControllerFile.WriteLine 1: ControllerFile.Close
Else
cNewController=Textstr.ReadLine: TextStr.Close
End If
End If
Else
cNewController = cController
End If
Select Case cNewController
Case 1
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."
Case 2
Set Controller = CreateObject("UltraVP.BackglassServ")
Case 3,4
Set Controller = CreateObject("B2S.Server")
End Select
On Error Goto 0
End Sub
'*************************************************************
'Toggle DOF sounds on/off based on cController value
'*************************************************************
Dim ToggleMechSounds
Function SoundFX (sound)
If cNewController= 4 and ToggleMechSounds = 0 Then
SoundFX = ""
Else
SoundFX = sound
End If
End Function




Contributor
Top
















are all trademarks of VPFORUMS.