I know I've been asking a lot of questions of you guys lately, but I still don't consider myself much of a programmer since most problems I come across aren't ones I know the answers to (or can easily find solutions for).
That said, I have a situation where I want to implement a different sound every time a drop target in a particular bank is hit.
Example: 4 Bank Drop Targets - The first one hit plays Sound1 (It doesn't necessarily have to be DropTarget1). The second one hit will play Sound2, unless Sound1 is still playing. (I imagine I'll have to use a Timer for this.) Then the third will play Sound3, unless still muted by MuteTimer1 or 2. The fourth one at this time doesn't have any sound so don't worry about that.
I figure it must use a Select Case in there somewhere, but I wouldn't know how to tell the script to do it this way. Any ideas?
As always, I appreciate the help you guys have been providing.
UPDATE:
For anyone who has been following this, I figured out the problem. I wanted to use a nested variable local to the specific subroutine, however that was not working as intended. Every time the Drop Targets got hit, they would only count to 1, even if they were supposedly directed to increment higher.
Instead, I changed the local "Dim HitCount" into a Global "Dim DT1HitCount". I don't know why, but it's working like this now.
That said, Here is my solution:
Sub DropTarget1_hit()
DT1HitCount = (DT1HitCount + 1)
If (DT1HitCount = 1) Then
PlaySound "vo_Help1"
DT1Mute1.Enabled = TRUE 'DT1Mute is a Timer'
Else
If (DT1HitCount = 2) AND DT1Mute1.Enabled = FALSE Then
PlaySound "vo_Help2"
DT1Mute2.Enabled = TRUE
Else
If (DT1HitCount = 3) AND DT1Mute1.Enabled = FALSE AND DT1Mute2.Enabled = FALSE Then
PlaySound "vo_Help3"
Else
If (DT1Hitcount = 4) Then
'I can add something here later...'
End If
End If
End If
End If
Select Case(fpEventID)
Case 1: DT1Light1.state = BulbOn
Case 2: DT1Light2.state = BulbOn
Case 3: DT1Light3.state = BulbOn
Case 4: DT1Light4.state = BulbOn
End Select
If(DropTarget1.dropped = TRUE) Then
AddScore(5000)
DT1Timer1.Enabled = TRUE
DT1Timer2.Enabled = TRUE
Else
AddScore(500)
End If
End Sub
Sub DT1Timer1_Expired()
'This one plays a sound and makes the lights flash, warning the player that a reset is incoming.'
DT1Timer1.Enabled = FALSE
PlaySound "vo_Reset", (SoundVolume)
DT1Light1.state = BulbBlink
DT1Light2.state = BulbBlink
DT1Light3.state = BulbBlink
DT1Light4.state = BulbBlink
End Sub
' Here is where the Drop Targets reset, including the DT1HitCount.'
Sub DT1Timer2_Expired()
DT1Timer2.Enabled = FALSE
DT1Light1.FlashForMS 100, 50, BulbOff
DT1Light2.FlashForMS 100, 50, BulbOff
DT1Light3.FlashForMS 100, 50, BulbOff
DT1Light4.FlashForMS 100, 50, BulbOff
DT1Target1.SolenoidPulse()
DT1HitCount = 0
PlaySound "DropTargetReset"
End Sub
' The following Mute Timers keep sound from playing on top of each other.'
' The timer interval is set to last the duration of the selected sound.'
Sub DT1Mute1_Expired()
DT1Mute1.Enabled = FALSE
End Sub
Sub DT1Mute2_Expired()
DT1Mute2.Enabled = FALSE
End Sub
Also, I nested each increment of DT1HitCount to save space and tidy it up a little.
Edited by SpectreRose, 28 April 2015 - 07:06 AM.




Top

Contributor








are all trademarks of VPFORUMS.