Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ''keydown
- 'if KeyCode = LeftFlipperKey then vpmFlipsSam.FlipL True : vpmFlipsSam.FlipUL True
- 'if KeyCode = RightFlipperKey then vpmFlipsSam.FlipR True : vpmFlipsSam.FlipUR True
- ''KeyUp
- 'if KeyCode = LeftFlipperKey then vpmFlipsSam.FlipL False : vpmFlipsSam.FlipUL False
- 'if KeyCode = RightFlipperKey then vpmFlipsSam.FlipR False : vpmFlipsSam.FlipUR False
- dim vpmFlipsSAM : set vpmFlipsSAM = New cvpmFlipsSAM : vpmFlipsSAM.Name = "vpmFlipsSAM"
- '*************************************************
- Sub InitVpmFlipsSAM()
- vpmFlipsSAM.CallBackL = SolCallback(vpmflipsSAM.FlipperSolNumber(0)) 'Lower Flippers
- vpmFlipsSAM.CallBackR = SolCallback(vpmFlipsSAM.FlipperSolNumber(1))
- On Error Resume Next
- if cSingleLflip or Err then vpmFlipsSAM.CallbackUL=SolCallback(vpmFlipsSAM.FlipperSolNumber(2))
- err.clear
- if cSingleRflip or Err then vpmFlipsSAM.CallbackUR=SolCallback(vpmFlipsSAM.FlipperSolNumber(3))
- On Error Goto 0
- msgbox "~Debug-Active Flipper subs~" & vbnewline & vpmFlipsSAM.SubL &vbnewline& vpmFlipsSAM.SubR &vbnewline& vpmFlipsSAM.SubUL &vbnewline& vpmFlipsSAM.SubUR' &
- End Sub
- 'Sam does not use consistent solenoid numbers for flippers. These are for Star Trek LE
- 'indexed properties for now '0=left 1=right 2=Uleft 3=URight
- vpmFlipsSam.FlipperSolNumber(0) = 15
- vpmFlipsSam.FlipperSolNumber(1) = 16
- 'vpmFlipsSam.FlipperSolNumber(2) = sULFlipper
- vpmFlipsSam.FlipperSolNumber(3) = 12
- InitVpmFlipsSAM
- vpmflipssam.tiltsol True 'make sure this is on for SS flippers
- 'New Command -
- 'vpmflipsSam.RomControl=True/False - True for rom controlled flippers, False for FastFlips (Assumes flippers are On)
- 'Debug Stuff ~~~~~~~~~~~~~
- Sub TestFF_Timer() 'Testing switching back and forth between fastflips and rom controlled flips on a timer
- me.interval = 500'RndNum(100, 500)
- vpmFlipsSAM.RomControl = Not vpmFlipsSAM.RomControl
- End Sub
- tb.timerinterval = -1 : tb.timerenabled=1 'debug textbox
- Sub tb_Timer()
- tb.text = vpmFlipsSAM.SolState(0) & " " & vpmFlipsSAM.ButtonState(0) & " " & vbnewline & vpmFlipsSAM.romcontrol
- End Sub
- '~~~~~~~~~~~~~~~~~~~~~~~~~~
- Class cvpmFlipsSAM 'test fastflips with support for both Rom and Game-On Solenoid flipping
- Public TiltObjects, DebugOn, Name, Delay
- Public SubL, SubUL, SubR, SubUR, FlippersEnabled, LagCompensation, ButtonState(3), Sol 'set private
- Public RomMode, SolState(3)'set private
- Public FlipperSolNumber(3) '0=left 1=right 2=Uleft 3=URight
- Private Sub Class_Initialize()
- dim idx :for idx = 0 to 3 :ButtonState(idx)=0:SolState(idx)=0: Next : Delay=0: FlippersEnabled=0: DebugOn=0 : LagCompensation=0 : Sol=0 : TiltObjects=1
- SubL = "NullFunction": SubR = "NullFunction" : SubUL = "NullFunction": SubUR = "NullFunction"
- RomMode=False :FlipperSolNumber(0)=sLLFlipper :FlipperSolNumber(1)=sLRFlipper :FlipperSolNumber(2)=sULFlipper :FlipperSolNumber(3)=sURFlipper
- End Sub
- 'set callbacks
- Public Property Let CallBackL(aInput) : if Not IsEmpty(aInput) then SubL = aInput :SolCallback(FlipperSolNumber(0)) = name & ".RomFlip(0)=":end if :End Property 'execute
- Public Property Let CallBackR(aInput) : if Not IsEmpty(aInput) then SubR = aInput :SolCallback(FlipperSolNumber(1)) = name & ".RomFlip(1)=":end if :End Property
- Public Property Let CallBackUL(aInput): if Not IsEmpty(aInput) then SubUL = aInput :SolCallback(FlipperSolNumber(2)) = name & ".RomFlip(2)=":end if :End Property 'this should no op if aInput is empty
- Public Property Let CallBackUR(aInput): if Not IsEmpty(aInput) then SubUR = aInput :SolCallback(FlipperSolNumber(3)) = name & ".RomFlip(3)=":end if :End Property
- Public Property Let RomFlip(idx, ByVal aEnabled)
- aEnabled = abs(aEnabled)
- SolState(idx) = aEnabled
- If Not RomMode then Exit Property
- Select Case idx
- Case 0 : execute subL & " " & aEnabled
- Case 1 : execute subR & " " & aEnabled
- Case 2 : execute subUL &" " & aEnabled
- Case 3 : execute subUR &" " & aEnabled
- End Select
- End property
- Public Property Let RomControl(aEnabled) 'todo improve choreography
- RomMode = aEnabled
- If aEnabled then 'Switch to ROM solenoid states or button states
- Execute SubL &" "& SolState(0)
- Execute SubR &" "& SolState(1)
- Execute SubUL &" "& SolState(2)
- Execute SubUR &" "& SolState(3)
- Else
- Execute SubL &" "& ButtonState(0)
- Execute SubR &" "& ButtonState(1)
- Execute SubUL &" "& ButtonState(2)
- Execute SubUR &" "& ButtonState(3)
- End If
- End Property
- Public Property Get RomControl : RomControl = RomMode : End Property
- public DebugTestKeys, DebugTestInit 'orphaned (stripped out the debug stuff)
- Public Property Let Solenoid(aInput) : if not IsEmpty(aInput) then Sol = aInput : end if : End Property 'set solenoid
- Public Property Get Solenoid : Solenoid = sol : End Property
- 'call callbacks
- Public Sub FlipL(ByVal aEnabled)
- aEnabled = abs(aEnabled) 'True / False is not region safe with execute. Convert to 1 or 0 instead.
- DebugTestKeys = 1
- ButtonState(0) = aEnabled 'track flipper button states: the game-on sol flips immediately if the button is held down (1.1)
- If FlippersEnabled and Not Romcontrol or DebugOn then execute subL & " " & aEnabled end If
- End Sub
- Public Sub FlipR(ByVal aEnabled)
- aEnabled = abs(aEnabled) : ButtonState(1) = aEnabled : DebugTestKeys = 1
- If FlippersEnabled and Not Romcontrol or DebugOn then execute subR & " " & aEnabled end If
- End Sub
- Public Sub FlipUL(ByVal aEnabled)
- aEnabled = abs(aEnabled) : ButtonState(2) = aEnabled
- If FlippersEnabled and Not Romcontrol or DebugOn then execute subUL & " " & aEnabled end If
- End Sub
- Public Sub FlipUR(ByVal aEnabled)
- aEnabled = abs(aEnabled) : ButtonState(3) = aEnabled
- If FlippersEnabled and Not Romcontrol or DebugOn then execute subUR & " " & aEnabled end If
- End Sub
- Public Sub TiltSol(aEnabled) 'Handle solenoid / Delay (if delayinit)
- If delay > 0 and not aEnabled then 'handle delay
- vpmtimer.addtimer Delay, Name & ".FireDelay" & "'"
- LagCompensation = 1
- else
- If Delay > 0 then LagCompensation = 0
- EnableFlippers(aEnabled)
- end If
- End Sub
- Sub FireDelay() : If LagCompensation then EnableFlippers 0 End If : End Sub
- Public Sub EnableFlippers(aEnabled) 'private
- If aEnabled then execute SubL &" "& ButtonState(0) :execute SubR &" "& ButtonState(1) :execute subUL &" "& ButtonState(2): execute subUR &" "& ButtonState(3)':end if
- FlippersEnabled = aEnabled
- If TiltObjects then vpmnudge.solgameon aEnabled
- If Not aEnabled then
- execute subL & " " & 0 : execute subR & " " & 0
- execute subUL & " " & 0 : execute subUR & " " & 0
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment