![]() |
|
#1
|
|||
|
|||
|
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
|
|||
|
|||
|
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.
__________________
Member number: 3 Meat lover? Watch: http://www.chooseveg.com/animal-cruelty.asp |
|
#3
|
|||
|
|||
|
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
|
|||
|
|||
|
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
|
|||
|
|||
|
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 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")
__________________
![]() Email me your lua scripts ill fix them or help you fix them and Email you back on what you wanted :D |
![]() |
|
|
|||
|
|||
|
|
| Thread Tools | |
| Display Modes | |
|
|