(Shortened for simplicity's sake)
.GameName cGameName
NVOffset (1)
.Run
End With
Explanation of how it works:
- Upon adding NVOffset(n), it will check if a table using the same rom has been previously run with a different version, and if so, backup the .nv file for the previous version run
- It will then create/rename a placeholder .txt file that specifies the version being run (so it can be checked on future runs).
- And finally, if changing versions, it will grab the last backed up .nv file for the version being run (if it exists) and copy that to the current .nv file
Original post, kept for posterity's sake
_______________________________________________________________
The following will allow you to use a single ROM for multiple table and have it behave as if it were a completely separate ROM for each. This its handy for those odd tables that use the same ROM as a different table, or you just have different versions of the same table and want to keep separate high scores for each. In the following code, the version is set to 0, as this allows the code to be copied and pasted into any table, new or old without effecting anything by default.
Create the following at the end of the table script (or almost anywhere really) in each table that you want to use this functionality, then just set the version number to 1, 2, etc. to have them keep separate nvrams
Dim check,v,vv,nvpath
Const version = 0 'change this in other tables to call different versions of the nvram
nvpath = controller.installdir & "\nvram\"
Set check = CreateObject("Scripting.FileSystemObject")
For v=1 to 10 'check up to 10 possible versions using same rom, it's overkill, but can be changed to a lower number
If check.FileExists(nvpath & cGameName & " v" & v & ".txt") Then vv=v : exit For : End If
vv=0
Next
If vv=version or version = 0 Then
exit Sub
ElseIf vv=0 Then
check.CreateTextFile nvpath & cGameName & " v" & version & ".txt", True
exit Sub
Else
check.moveFile nvpath & cGameName & " v" & vv & ".txt", nvpath & cGameName & " v" & version & ".txt"
If check.FileExists(nvpath & cGameName & ".nv") Then
check.copyFile nvpath & cGameName & ".nv", nvpath & cGameName & " v" & vv & ".nv", True
End If
If check.FileExists(nvpath & cGameName & " v" & version & ".nv") Then
check.copyFile nvpath & cGameName & " v" & version & ".nv", nvpath & cGameName & ".nv", True
End If
End If
End Sub