Jump to content




Photo
- - - - -

Script to define a global controller setting (vPinmame, UVP, B2S or B2S with DOF)


  • Please log in to reply
33 replies to this topic

#1 gtxjoe

gtxjoe

    Pinball Wizard

  • VIP
  • 4,137 posts

  • Flag: United States of America

  • Favorite Pinball: Medieval Madness, AbraCadabra



Contributor

Posted 10 January 2015 - 02:52 AM

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


#2 gamefixer

gamefixer

    Pinball Fan

  • Silver Supporter
  • 574 posts
  • Location:Prosper, Texas

  • Flag: United States of America

  • Favorite Pinball: BK2K

  • PS3 Gamer Tag: gamefixer
  • 360 Gamer Tag: gamefixer

Posted 10 January 2015 - 03:40 AM

looks good to me. Having to modify the script on a newly downloaded table is pretty much guaranteed on my machine so changing that 1 to a 0 instead of 3 would be easy. 



#3 arngrim

arngrim

    DJ Force Feedback

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

  • Flag: Belgium

  • Favorite Pinball: Monster bash



Posted 10 January 2015 - 05:50 AM

excellent, thanks joe!
i will provide the txt for all my mods so there won't be any excuse :D

#4 takut

takut

    Enthusiast

  • Members
  • PipPipPip
  • 142 posts

  • Flag: Germany

  • Favorite Pinball: Tales of the Arabian Night

Posted 10 January 2015 - 10:50 AM

Great :tup:

 

I add your options script to a table and it works perfect. This is a very good solution to use the same tables without script change on my desktop computer and on the cab.



#5 unclewilly

unclewilly

    sofa king.....

  • VIP
  • 4,716 posts
  • Location:Baltimore, Maryland

  • Flag: United States of America

  • Favorite Pinball: tz, tom, big hurt, who dunnit



Posted 10 January 2015 - 11:52 AM

That is excellent.

1 question about the sound function.
do you need to have the togglemechsound variable in there,?
seems as if the ccontroller check should be all you need for the condition of that statement.

I dont think it will be much trouble getting authors to add t&e new loadvpm script.

The hard part will be getting them to use the sound functio . Especially if they are not cabinet users.

This is one case where i think a mod should be allowed without author permission.

If the site had a dof section. And mods to the script to change the sound coding to make this possible.

As its a functionality mod.

I dont have dof in my mini cab yet as i decided to build a mame cab before dumping more money in\o my pincab. But there are some things i like to turn the sound off for like the plunger sounds.

I have to edit most tables anyway for plunger support and i like to send all the mechanical sounds to my playfield tv speakers for now to give the illusion they are coming from below the playfield

"it will all be ok in the end, if it's not ok, it's not the end"
 
Monster Bash VP10 WIP https://dl.dropboxus... (vpx)WIP15.vpx

uw2.gif


#6 gtxjoe

gtxjoe

    Pinball Wizard

  • VIP
  • 4,137 posts

  • Flag: United States of America

  • Favorite Pinball: Medieval Madness, AbraCadabra



Contributor

Posted 10 January 2015 - 03:58 PM

togglemechsound

It is a hook to all you to temporarily re-enable the VP mech sounds with a button press.  If you add something to the keydown sub like,  if keycode = 3 then togglemechsound = 1     This will turn on the vp sounds during that session (for VP cab DOF users that unplug the DOF power and temp re-enable VP sounds).    Changing ccontroller.txt from 4 to 3 will now do the same thing.  

 

soundFX use.  arngrim has been championing this.  I think if he gets a table that does not use it yet, he adds support for it. This is where that sound manager with different categories would be better and more flexible



#7 unclewilly

unclewilly

    sofa king.....

  • VIP
  • 4,716 posts
  • Location:Baltimore, Maryland

  • Flag: United States of America

  • Favorite Pinball: tz, tom, big hurt, who dunnit



Posted 10 January 2015 - 05:26 PM

I agree. A second sound manager for just meck sounds with a volume slider.

Do you have dof gtx?

Im pretty sure we have the same cab from vpcabs

"it will all be ok in the end, if it's not ok, it's not the end"
 
Monster Bash VP10 WIP https://dl.dropboxus... (vpx)WIP15.vpx

uw2.gif


#8 arngrim

arngrim

    DJ Force Feedback

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

  • Flag: Belgium

  • Favorite Pinball: Monster bash



Posted 10 January 2015 - 06:12 PM

awesome, first mod that will use it is Excalibur DOF on his way.

 

to be complete, you need to add this in the end of the routine for the exceptional DOF calls outside the roms, it doesn't hurt if the table don't use it

 

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



#9 Shockman

Shockman

    Pinball Fan

  • VIP
  • 1,636 posts
  • Location:Portland Or.

  • Flag: United States of America

  • Favorite Pinball: Star Trek

Posted 10 January 2015 - 07:17 PM

This is one case where i think a mod should be allowed without author permission.

 

 

People don't need permission to mod. They need permission to release mods. There is NOT one case where permission is irrelevant. One could just say "It did not have that sound thing"


Mr. & Mrs. PAC-MAN https://www.dropbox.... WIP_4.vpx?dl=0

ICE COLD BEER,  ZEKE'S PEAK,  ICE COLD ROOT BEER  https://www.dropbox....D0IrcigG9a?dl=0

Other arcade games https://www.dropbox....LMmazmcfGa?dl=0

Arcade WIPhttps://www.dropbox....GKxYhviH_a?dl=0


#10 gtxjoe

gtxjoe

    Pinball Wizard

  • VIP
  • 4,137 posts

  • Flag: United States of America

  • Favorite Pinball: Medieval Madness, AbraCadabra



Contributor

Posted 11 January 2015 - 02:39 AM

UW, I built my own cab with 39" playfield.  I have had LEDwiz and the RGB flashers and strobes since I built it.  I am in the process of adding the contactors.



#11 unclewilly

unclewilly

    sofa king.....

  • VIP
  • 4,716 posts
  • Location:Baltimore, Maryland

  • Flag: United States of America

  • Favorite Pinball: tz, tom, big hurt, who dunnit



Posted 11 January 2015 - 02:51 AM

@user
i guess that is why the patching system was created.

"it will all be ok in the end, if it's not ok, it's not the end"
 
Monster Bash VP10 WIP https://dl.dropboxus... (vpx)WIP15.vpx

uw2.gif


#12 freneticamnesic

freneticamnesic

    A Faint Ghost Through the Raindrops

  • VIP
  • 3,245 posts
  • Location:Portland, OR

  • Flag: United States of America

  • Favorite Pinball: Star Trek, Black Hole, AFM, Fast Draw, Tron, AMH

  • 360 Gamer Tag: sixgunsounddd

Posted 11 January 2015 - 03:04 AM

And this is where I'd put my cab...

51287-IF-I-HAD-ONE-cat-gif-wId1.gif

If I HAD ONE!



#13 unclewilly

unclewilly

    sofa king.....

  • VIP
  • 4,716 posts
  • Location:Baltimore, Maryland

  • Flag: United States of America

  • Favorite Pinball: tz, tom, big hurt, who dunnit



Posted 11 January 2015 - 04:29 AM

Lmao

"it will all be ok in the end, if it's not ok, it's not the end"
 
Monster Bash VP10 WIP https://dl.dropboxus... (vpx)WIP15.vpx

uw2.gif


#14 yagesz

yagesz

    Enthusiast

  • Platinum Supporter
  • 303 posts
  • Location:Wyoming

  • Flag: United States of America

  • Favorite Pinball: TAF, TSPP, Metallica, CV

Posted 11 January 2015 - 05:20 AM

Thank you for this. I have been requesting this one feature forever.



#15 Mirkin

Mirkin

    Enthusiast

  • Members
  • PipPipPip
  • 130 posts

  • Flag: United Kingdom

  • Favorite Pinball: Funhouse F14 Defender

Posted 11 January 2015 - 01:15 PM

OK people excuse me if I'm being dumb here but would it not be possible to have script file that defines the position of the DMD as well.

I'm having major issues with mine moving about all the time and this seems like a solution.

Then again I might be talking out of my ass!


You can't take it with you so you might as well waste it on pinball!


#16 freneticamnesic

freneticamnesic

    A Faint Ghost Through the Raindrops

  • VIP
  • 3,245 posts
  • Location:Portland, OR

  • Flag: United States of America

  • Favorite Pinball: Star Trek, Black Hole, AFM, Fast Draw, Tron, AMH

  • 360 Gamer Tag: sixgunsounddd

Posted 11 January 2015 - 02:22 PM

Yea you could, but BigBoss created the SetDMD app which does this all in one shot - it's available on his website http://pinballbulbs....les/setdmd.html



#17 Mirkin

Mirkin

    Enthusiast

  • Members
  • PipPipPip
  • 130 posts

  • Flag: United Kingdom

  • Favorite Pinball: Funhouse F14 Defender

Posted 11 January 2015 - 05:54 PM

Yea you could, but BigBoss created the SetDMD app which does this all in one shot - it's available on his website http://pinballbulbs....les/setdmd.html

I've tried this tool and it works well, but:-

The problem that I'm having is that I set all the DMD positions and then they just start going all over the place. Especially after running physmod. I would like to have a script that will over-write the DMD positions in the registry each time I start a game so that the issue is masked.

 

Edit:-

I think I found a way to load a registry back-up before and after I run a table from pinballX. It's looking solid at the moment. The DMD's haven't moved at all.


Edited by Mirkin, 11 January 2015 - 06:30 PM.

You can't take it with you so you might as well waste it on pinball!


#18 gtxjoe

gtxjoe

    Pinball Wizard

  • VIP
  • 4,137 posts

  • Flag: United States of America

  • Favorite Pinball: Medieval Madness, AbraCadabra



Contributor

Posted 11 January 2015 - 06:56 PM

I am curious - Ae you enabling  the "Position PinMame" or "Use PinMame in Front End" in the Pinballx settings?  I have these both set to No and I have not run into losing my pinmame position.

 

If you want to script a pinmame window location/size in the script if would follow this format:

.Games(cGameName).Settings.Value("dmd_pos_x")=3840
        .Games(cGameName).Settings.Value("dmd_pos_y")=0
        .Games(cGameName).Settings.Value("dmd_width")=1024
        .Games(cGameName).Settings.Value("dmd_height")=300
 
 
 
Controller.Games("rom").Settings.Value("dmd_pos_x")=3840
        Controller.Games("rom").Settings.Value("dmd_pos_y")=0
        Controller.Games("rom").Settings.Value("dmd_width")=1024
        Controller.Games("rom").Settings.Value("dmd_height")=300

Edited by gtxjoe, 11 January 2015 - 08:51 PM.


#19 Mirkin

Mirkin

    Enthusiast

  • Members
  • PipPipPip
  • 130 posts

  • Flag: United Kingdom

  • Favorite Pinball: Funhouse F14 Defender

Posted 11 January 2015 - 08:05 PM

Hi Joe

I have both items set to "no".

I had a reply here [site reference removed] that says physmod can mess some peoples DMD's up. I had no issues until I started using it so I think it must be the problem somehow.

It's had me scratching my head a lot and as you know I'm learning about this all the time.

I didn't really want to go down the route of editing all my scripts so I found a work around as I described.

Just for information, would I have to put both of the blocks shown above into the script or just one. If just one, how would I decide which? Maybe I'll start adding this to any new tables.

Thanks again for all your advice.

 

Edit:-

I just re-read this article http://www.vpforums....als&article=136

I've edited the default DMD position/size keys so hopefully this will stop the issue.


Edited by Noah Fentz, 25 July 2015 - 05:19 PM.

You can't take it with you so you might as well waste it on pinball!


#20 gtxjoe

gtxjoe

    Pinball Wizard

  • VIP
  • 4,137 posts

  • Flag: United States of America

  • Favorite Pinball: Medieval Madness, AbraCadabra



Contributor

Posted 11 January 2015 - 08:53 PM

search the script for DMDOnly and you would have to look at the the style/approach of coding that was used by the author in that section.  Those are two examples