Wouldn't this be better in terms of logic flow?
if playerMove == "no" and not tankidle:playing() then
tankdrive:stop()
tankidle:play()
end
if playerMove == "yes" and not tankdrive:playing() then
tankidle:stop()
tankdrive:play()
end
OK I've been stuck with this all weekend with no luck, can some one tell me whats wrong with this bit of code:
if playerMove == "no" and loopCount == 0 then
tankidle:play()
loopCount = loopCount + 1
loopCount2 = 0
tankdrive:stop()
end
if playerMove == "yes" and loopCount2 == 0 then
tankdrive:play()
loopCount2 = loopCount2 + 1
loopCount = 0
tankidle:stop()
end
Its playing .wav sounds and they are looped.
I did also try doing another way of playing it using the
local sound = filename
voice = sound:play()
but that didn't work very well, beacause every time I tried to stop one sound it was ok but if i tried stoping the other it just wouldn't work.
So if someone could help me out here please.
Wouldn't this be better in terms of logic flow?
if playerMove == "no" and not tankidle:playing() then
tankdrive:stop()
tankidle:play()
end
if playerMove == "yes" and not tankdrive:playing() then
tankidle:stop()
tankdrive:play()
end
Okay.. In that case, I need to know what it actually does and what you want it to do in as much detail as possible. How are you trying to stop both sounds?
Well its for a tank game that I'm making and I want it so that when the tanks moving it plays one sound and when its not moving it plays the other. But i also need it so it stops the other sound, or it sounds quite nasty. The sounds are also looped.
At the moment I have this:
if playerMove == "no" and loopCount == 0 then
local sound = tankidle
voice = sound:play()
loopCount2 = 0
loopCount = loopCount + 1
end
if voice:playing() and playerMove == "yes" then
voice:stop()
loopCount = 0
end
if playerMove == "yes" and loopCount2 == 0 then
local sound = tankdrive
noise = sound:play()
loopCount2 = loopCount2 + 1
end
This plays the stoped sound fine eg starts and stops at the right time, but the driving sound just keeps playing. If I try to add the STOP() command it crashes.
Completely untested.tankdriveVoice = tankdrive:play()
tankdriveVoice:stop()
tankidleVoice = tankidle:play()
tankidleVoice:stop()
while true do
if playerMove == "no" and not tankidle:playing() then
tankdriveVoice:stop()
tankidleVoice = tankidle:play()
end
if playerMove == "yes" and not tankdrive:playing() then
tankidleVoice :stop()
tankdriveVoice = tankdrive:play()
end
end
Dont look like thats working, I'll try and fiddle about with it a minute.
Do you have a PSP or Lua player on your PC?
Nevermind here you go have a look at the code attached, this is the whole code for it so far.
The sound stuff is under ------------drivin sounds------------.
.tankdriveVoice = tankdrive:play()
tankdriveVoice:stop()
tankidleVoice = tankidle:play()
tankidleVoice:stop()
while true do
if playerMove == "no" and not tankidleVoice:playing() then
tankdriveVoice:stop()
tankidleVoice = tankidle:play()
end
if playerMove == "yes" and not tankdriveVoice:playing() then
tankidleVoice :stop()
tankdriveVoice = tankdrive:play()
end
end
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks