-
Notifications
You must be signed in to change notification settings - Fork 0
Fixing VBScripts for Standalone VPX
This page documents known issues with the VBScript interpreter in Visual Pinball Standalone, along with workarounds. Many issues have been fixed by the Wine team, and the Visual Pinball team has added several missing features (e.g., support for Eval
, Execute
, ExecuteGlobal
, and GetRef
). For more details, refer to the linked external resources.
Note
Many newer tables already know about these issues and work with no updates.
- Syntax and Parsing Issues
- Declaration and Definition Issues
- Array and Evaluation Issues
- Loop and Type Conversion Issues
- Execution Issues
- Object and Shell Issues
Issue:
' does not work
addscore (starstate+1)*1000
Workarounds:
-
Option 1:
addscore 1000*(starstate+1)
-
Option 2:
addscore ((starstate+1)*1000)
Tip
This issue is hard to spot as the parser does not provide an exact error line. Bisecting the script may help locate the problem.
See: [Wine Bug #54177]
Issue:
' does not work
If isGIOn <> Not IsOff Then
Workaround:
If isGIOn <> (Not IsOff) Then
See: [Wine Bug #55093]
Issue:
' does not work
else keygrad1 = 0 end if
Workaround:
else
keygrad1 = 0
end if
Issue:
' does not work
If Keycode = StartGameKey Then
:pupevent 800
End If
Workaround:
If Keycode = StartGameKey Then
pupevent 800
End If
See: [Wine Bug #55037]
Issue:
' does not work
Dim x
x = data
Const data = 1
Workaround:
Const data = 1
Dim x
x = data
Important
Always define constants before using them to prevent runtime errors.
Issue:
' does not work
DTArray(i)(4) = DTCheckBrick(Activeball,DTArray(i)(2))
Workaround:
DTArray(i).animate = DTCheckBrick(Activeball,DTArray(i).prim) ' move to class approach
Note
This is one of the most common issues. It can be automatically patched by vpxtool.
See: [DTArray Drop Targets], [STArray Standup Targets], and [Wine Bug #53877]
Issue:
' does not work
dy = -1*(EVAL("roachxy" & xx)(1)(roachstep) - EVAL("roachxy" & xx)(1)(roachstep-1)) 'delta Y
Workaround:
dim roachxy : roachxy = EVAL("roachxy" & xx)
dy = -1*(roachxy(1)(roachstep) - roachxy(1)(roachstep-1)) 'delta Y
Issue:
' This code loops 16 times on Windows but on Linux it leads to a very large numerical value.
' This results in the loop iterating an extremely high number of times.
Dim i, num
num = "16"
For i = 0 To num
WScript.Echo i
Next
Workaround:
For i = 0 To CInt(num)
See: [Wine Bug #55052]
Issue:
' does not work
For i = 0 To 127: Execute "Set Lights(" & i & ") = L" & i: Next
Workaround:
For i = 0 To 127
If IsObject(Eval("L" & i)) Then
Execute "Set Lights(" & i & ") = L" & i
End If
Next
Issue:
' does not work (notice no End If)
If FlasherOnG = False then FlasherTimer3.Enabled = 1: Else
FlasherTimer4.Enabled = 0
Workaround:
If FlasherOnG = False then FlasherTimer3.Enabled = 1
FlasherTimer4.Enabled = 0
See: [Wine Bug #55006]
Issue:
' does not work
Dim WshShell : Set WshShell = CreateObject("WScript.Shell")
GetNVramPath = WshShell.RegRead("HKEY_CURRENT_USER\Software\Freeware\Visual PinMame\globals\nvram_directory")
Warning
There is no workaround because the Standalone version will not support WScript.Shell
.
Tip
Sometimes you can just comment out the line.
Issue:
' CorTracker
Public Sub Update() ' tracks in-ball-velocity
Dim str, b, AllBalls, highestID : AllBalls = gBOT
Workaround:
Public Sub Update() ' tracks in-ball-velocity
Dim str, b, AllBalls, highestID : AllBalls = getballs
Note
VBScript uses reference counters for objects. In this case, using gBOT
may reduce a ball's reference count to zero, leading to its destruction and causing subsequent code to crash when accessing a destroyed object.
Many of these issues stem from differences in how VBScript is interpreted in the Wine environment compared to native Windows environments. Where possible, workarounds are provided. For further automation, consider using tools like vpxtool.
Tip
If you encounter any new issues, check the Wine project's bug tracker for similar reports.
This document is intended to help developers quickly identify and resolve common VBScript issues in Visual Pinball Standalone.