Results 1 to 5 of 5

Thread: Stupid Question. Help please

  
  1. #1
    Johnnsen is offline -Hacks Veteran
    Join Date
    Dec 2006
    Location
    the Ozzfest
    Posts
    1,287
    Rep Power
    14

    Default

    Hi,
    could you tell me how to make a sound only play once when a button is pressed? I made it, that the sound is played when X is pressed, but it should only play once, not all the time while pressed. Could you help me?

    Butcher Of Bitches

  2. #2
    LordCthulu is offline Senior Member -Hacks Enthusiast
    Join Date
    Mar 2005
    Posts
    578
    Rep Power
    15

    Default

    You mean like, if you hold down x, you only want it to play once?
    Off the top of my head, you could use a variable, say set it to 0. When x is pressed, set it to 1 and play the sound. If the variable is 1, don't play the sound , if it's 0, play it. Then when x is... done being pressed (lol) make it 0 again.
    Oldest psp-hacks member ever.

  3. #3
    Johnnsen is offline -Hacks Veteran
    Join Date
    Dec 2006
    Location
    the Ozzfest
    Posts
    1,287
    Rep Power
    14

    Default

    Yeah, that is how I would do it in every other scripting language, but what the hell? Doesnt work here so good. I dont know how to set the function to X not being pressed...lol
    Butcher Of Bitches

  4. #4
    silverfox is offline -Hacks Hacker
    Join Date
    Nov 2005
    Location
    the year 2021
    Posts
    869
    Rep Power
    15

    Default

    im not familiar with lua but shouldnt their be a function to check when the sound has reached the end of the stream...and if so, when the function returns a posotive value when the sound has played entireley, make the int 0 then...

    if not, set up two variables...one is x, and the button can not be pressed when x = 1, then make an if statment for when x = 1, to incrament another variable.

    remmeber, a loop should run through once every millersecond...so take the total length of the sound effect and convert it to miller seconds...and when the incramented variable reaches that number...switch x back to 0

    http://www.psp-hacks.com/file/1126
    good programmers know something, then experiment.

  5. #5
    lua scripter is offline -Hacks Newbie
    Join Date
    Aug 2008
    Posts
    14
    Rep Power
    0

    Default

    yup heres the code

    Code:
    while true do
    pad = Controls.read()
    
    if pad:cross() then
    screen.flip() screen.waitVblankStart(5) "file name":play()
    end
    
    
    screen.waitVblankStart()
    screen.flip()
    end
    on this you need a audio file thats small and has a very low sound rate

    go to media-convert.com get your file in there and then you need to make SURE you convert it to .wav
    then when you get the screen were yo choose the codact make sure its on mono and 2500zK or something like that then make sure your sound is loaded by using this code
    Code:
    "name the file"=Sound.load("music/"file name".wav")
    music is the folder

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •