I tried experimenting with utilizing a standard plunger oject as a type of impulse plunger and came away unsucessful, because I was unable to find a good way to control the power settings digitally without plunger lag. Therefore, I have just decided to add this to the thread for those that want to add an impulse plunger to utilize my alternative method for using an analog plunger to control an impulse plunger for more shot consistantcy.
Adding an Impulse Plunger to an existing table where there is none:First thing that needs to be done is declare the name of the impulse plunger at the top of the script. We are gonna use the name PlungerIM and are gonna put it before the Sub Table_Init. It can be placed on it's own line or added to another line, it doesn't matter.
Second thing that needs to be done is to set PlungerIM to be an Impulse Plunger. This will be added into the Sub Table_Init section. It can be placed at the beginning or the end, it doesn't matter, but for the sake of neatness, I usually put it right after the controller section at the top.
Dim PlungerIM 'add this'Sub Table_Init vpmInit Me With Controller ... End With ' Impulse Plunger' Const IMPowerSetting = 43 'Plunger Power' Const IMTime = 0.4 'Time in seconds for Full Plunge' Set plungerIM = New cvpmImpulseP With plungerIM .InitImpulseP swplunger, IMPowerSetting, IMTime .Random 0.3 .InitExitSnd "plunger2", "plunger" .CreateEvents "plungerIM" End With ...End Sub
Description of variables above:
IMPowerSetting - strength of the plunger
IMTime - time to pull plunger back, take the PTime interval and multiply it by the number of steps it goes through for the plunger animation. For example, if the PTime interval is set to 33 (ms) and there are 12 steps to the animation, the resulting time would be 396ms, or about .4 seconds as shown above.
swplunger - the trigger used to launch the ball
.random - amount of play in the plunger strength
The last thing that needs to be done to finish adding an impulse plunger to a table is to add a trigger named swplunger in the plunger lane if it doesn't already exist. This will need to be placed where the ball will rest. Usually there will be some sort of trigger there already, so you should be able to just copy the existing trigger and paste a new one on top of it and rename it to 'swplunger'.
This can be repeated to add a second impulse plunger as well. Just add a 2 to PlungerIM, IMPowerSetting, IMTime, and swplunger
Converting existing script to utilize newly added Impulse Plunger:In the KeyDown and KeyUp sections of the script, just change Plunger.pullback and Plunger.fire to PlungerIM.pullback and PlungerIM.fire, and they will then use the Impulse plunger for launching the ball instead of the Plunger Object.
If the table already incorporates analog plunger control, and you wish to utilize the Impulse Plunger for this purpose, you will need add the following script into the Sub Plunger_Timer section...
Dim PlungerPos2, PowerSetting, plcount : PowerSetting = PlungerIM.Strength '<-- added outside of the Plunger_Timer sub'
Sub Plunger_Timer
...
'added inside of the Plunger_Timer sub at the end'
If Plunger.Position < 2 and PlungerPos2 > 5 Then 'if current position is below 2 and reference position is above 5, will launch the ball'
PlungerIM.Strength = (PlungerPos2/25*PowerSetting) 'sets launch strength based on reference position'
PlungerIM.AutoFire 'launches the ball'
PlungerIM.Strength = PowerSetting 'restores default power setting for use with digital plunger'
PlungerPos2 = 0:plcount = 1
End If
If plcount mod 5 = 0 Then PlungerPos2 = Plunger.Position : plcount = 0 '<-- updates the reference position every 5th tick, or 200ms assuming a 40ms timer interval'
plcount=plcount+1
End Sub
Edited by koadic, 26 September 2012 - 12:23 PM.