Posted 10 May 2012 - 07:48 AM
Alright, if you are interested, I have adapted a small part of JP's code to keep it in line with what you already have and inserted it into your code to allow for the analog plunger...
Just need to make some minor adjustments to the plunger in the editor first, namely:
Check Enable Mechanical Plunger box
Change Break Over Velocity from 30 to 20 (think this only effects analog plungers anyway)
Check Timer Enabled box
Change Timer Interval to 40
Then make the following changes to your script:
under the KeyDown Sub, change
CODE
If keycode = PlungerKey Then
Plunger.PullBack
PlaySound "SSPlungePull"
PRdir=0
PRLight.TimerInterval=60
PRLight.TimerEnabled=true
End If to
CODE
If keycode = PlungerKey Then
Plunger.TimerEnabled=false
Plunger.PullBack
PlaySound "SSPlungePull"
PRdir=0
PRLight.TimerInterval=60
PRLight.TimerEnabled=true
End If under the KeyUp Sub, change
CODE
If keycode = PlungerKey Then
Plunger.Fire
PlaySound "SSPlungeRel"
PRLight.TimerInterval=10
PRdir=1
If InPlunger=1 Then
PlaySound "Shoot"
End If
End If to
CODE
If keycode = PlungerKey Then
Plunger.TimerEnabled=true
Plunger.Fire
PlaySound "SSPlungeRel"
PRLight.TimerInterval=10
PRdir=1
If InPlunger=1 Then
PlaySound "Shoot"
End If
End If (Along with Plunger timer being enabled at the start, it allows the animation to work for the plunger key even if an analog plunger is connected, differing from JP's current script (for now))
And after your PRLight_Timer Sub, add the following:
CODE
Dim PRpullNew, PRpullOld
PRpullNew = 0:PRpullOld = 0
Sub Plunger_Timer()
If Plunger.MotionDevice> 0 Then
PLU(PRpullOld).WidthBottom = 0:PLU(PRpullOld).WidthTop = 0
PRpullNew = (Plunger.Position \ 2) - 2
If PRpullNew<0 Then PRpullNew=0
PLU(PRpullNew).WidthBottom = 30:PLU(PRpullNew).WidthTop = 30
PRLight.State=Abs(PRLight.State-1)
PRPullOld = PRPullNew
End If
End Sub
small explanation on the above code, Plunger.Position goes from 1-25 (or 0-24, not sure), so when it's divided by 2, it can yield a value of up to 12, which is why I subtracted 2 at the end, otherwise it will go out of range of the subscript.
I understand how the analogue plunger works now. I'm gonna update my earlier tables with this code.