Jump to content



Photo
- - - - -

Random Sound Failures


  • Please log in to reply
3 replies to this topic

#1 SpectreRose

SpectreRose

    Hobbyist

  • Members
  • PipPip
  • 28 posts

  • Flag: ---------

  • Favorite Pinball: I love too many I can't decide!

Posted 27 March 2015 - 10:21 AM

I've been working on a table recently, and the general layout is almost to my satisfaction. As such, I have started to dive into coding. I've taken 3 classes for this topic in college (two for Visual Basic, one for C++) and yet despite coming out with high grades, I can't really write code to save someone's life.

 

So I've tried to find what I like in other machines, and emulate and modify the examples I find in their scripts for use as needed in my own project. My current problem lies in a randomly played sound effect when I lose a ball in the sink.

 

Here's the random number generator:

function RandomNumber(ByVal max)
    RandomNumber = Int(max * Rnd+1)
end function

Here's the event that keeps giving me problems:

Sub EndOfBall()
    Dim BonusDelayTime

    'AddDebugText "EndOfBall"
    Select Case RandomNumber(2)
        Case 1: PlaySound 3, "vo_HeSucked", TRUE, SoundVolume
        Case 2: PlaySound 3, "vo_KeepUp", TRUE, SoundVolume
    End Select

I get the error message Wrong Number of Arguments or Invalid Property Assignment: 'PlaySound'

 

If I remove:   ,TRUE, SoundVolume

Then it results in the message Type Mismatch: 'PlaySound'

 

If I remove the 3 after PlaySound, then it tells me Argument not Optional: 'PlaySound'

 

I don't understand what is going on here, or what I'm doing wrong. The initial format, PlaySound 3, "vo_HeSucked", TRUE, SoundVolume has worked everywhere else in the code. Is it a problem with my random number generator?

 

 



#2 gtxjoe

gtxjoe

    VPF Veteran

  • VIP
  • 5,157 posts

  • Flag: United States of America

  • Favorite Pinball: Medieval Madness, AbraCadabra



Contributor

Posted 27 March 2015 - 09:13 PM

RandomNumber looks fine.  Where did you get the Playsound format?  

 

Playsound before VP 9.1.6

PlaySound "name",loopcount,volume

 

Playsound before VP10

PlaySound "name",loopcount,volume,pan,randompitch

 

Playsound in VP10

PlaySound(string, int loopcount, float volume, float pan, float randompitch, int pitch, bool usesame, bool restart)

 

and of course the basic usage

Playsound "name"



#3 SpectreRose

SpectreRose

    Hobbyist

  • Members
  • PipPip
  • 28 posts

  • Flag: ---------

  • Favorite Pinball: I love too many I can't decide!

Posted 27 March 2015 - 09:39 PM

I followed examples in the coding used in the STERN recreations on Future Pinball by SLAMT1LT.

 

Update: Interesting. The format Case 1: PlaySound "vo_HeSucked" works perfectly. Thank you, gtxjoe!


Edited by SpectreRose, 28 March 2015 - 12:58 AM.


#4 gtxjoe

gtxjoe

    VPF Veteran

  • VIP
  • 5,157 posts

  • Flag: United States of America

  • Favorite Pinball: Medieval Madness, AbraCadabra



Contributor

Posted 28 March 2015 - 01:01 AM

LOL, I posted VP info for an FP topic.  At least you got something working out of it ;)