PSP Hacks - Forums
Go Back   PSP Hacks - Forums > Tech Talk > LUA Scripting

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 06-01-2007, 09:13 AM
Johnnsen Johnnsen is offline
PSP Veteran
 
Join Date: Dec 2006
Location: the Ozzfest
Posts: 1,286
Johnnsen User Has a Beginner Reputation
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
Reply With Quote
  #2  
Old 06-01-2007, 04:00 PM
LordCthulu LordCthulu is offline
Senior Member
PSP Veteran
 
Join Date: Mar 2005
Posts: 1,029
LordCthulu User Has a Beginner Reputation
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.
__________________
Member number: 3
Meat lover? Watch: http://www.chooseveg.com/animal-cruelty.asp
Reply With Quote
  #3  
Old 06-01-2007, 04:16 PM
Johnnsen Johnnsen is offline
PSP Veteran
 
Join Date: Dec 2006
Location: the Ozzfest
Posts: 1,286
Johnnsen User Has a Beginner Reputation
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
Reply With Quote
  #4  
Old 07-13-2007, 11:57 PM
silverfox silverfox is offline
PSP Hacker
 
Join Date: Nov 2005
Location: the year 2021
Posts: 946
silverfox User Has a Beginner Reputation
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.
Reply With Quote
  #5  
Old 08-23-2008, 12:08 AM
lua scripter lua scripter is offline
PSP Newbie
 
Join Date: Aug 2008
Posts: 14
lua scripter User Has a Beginner Reputation
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
__________________


Email me your lua scripts ill fix them or help you fix them and Email you back on what you wanted :D
Reply With Quote
Reply

 



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:38 PM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©