Code: Select all
if pad:cross() then
if Music.playing() then
Music.stop()
gunshot:play()
else
gunshot:play()
end
end
Moderators: Shine, Insert_witty_name
Code: Select all
if pad:cross() then
if Music.playing() then
Music.stop()
gunshot:play()
else
gunshot:play()
end
end
Code: Select all
music:play()
music = true
if pad:cross() then
if music == true then
music:stop()
gunshot:play()
else
gunshot:play()
end
end
Code: Select all
if pad:cross() then
if Music.playing() then
Music.stop()
gunshot:play()
else
gunshot:play()
end
end
Mr_Snuffle has started such a library, which can be done in pure Lua:darklitch wrote:I am just getting started. How can i detect it as only pressed once? In other languages there are things like on (release) and on (press) is there anything like this in lua?
You need version 0.11 for System.sleep, but it is not a good idea to use it to avoid multiple event on on key press. See http://www.luaplayer.org/gallery/calculator.lua.txt for an example how to do it the right way.darklitch wrote:When I tried the System.sleep(25) thing, I got the error "attempt to call field 'sleep' (a nil value)" at first i thought it was because i forgot to add the 25 in it, but it was there. I tried something called wait(25), but that does not do what i want because when i call it, my sound works but my crosshair stops moving when i use it. Any suggestions?