alessandroLino
New Member
- Joined
- May 30, 2013
- Messages
- 1
- Reaction score
- 0
Has anyone had consistent success with playing sounds? I'm testing out the client and have been able to play sounds in response to some events like a creature talking, but i'm only able to play one kind of sound, as in one file, if i change the file name to play another one it will simply remain silent. I feel like the issue is on the files rather than on the code.
Is there any specific setup to do on the files, besides being ogg? Also the onDeath event seems to fire twice for no reason
Code:
local musicB = "music/erreur"
local musicChannel = g_sounds.getChannel(2)
local intsounds = 100
function init()
g_sounds.preload(musicB)
connect (g_game, { onGameStart = startup, onGameEnd = close, onTalk = checkTalk })
connect (Creature, { onDeath = checkDeath })
end
function terminate()
disconnect (g_game, { onGameStart = startup })
end
function startup()
musicChannel:stop(3)
musicChannel:enqueue(musicB, 0)
end
function close()
musicChannel:stop(3)
end
function playSound(name)
file = "sounds/" .. name
g_sounds.preload(file)
channel = g_sounds.getChannel(intsounds)
channel:stop(intsounds)
channel:play(file, 0)
intsounds = intsounds+1 -- quick hack to get multiple sounds playing at once
end
function checkDeath(creature)
if creature:getName() == "Goblin" then
playSound("die_goblin2")
modules.game_textmessage.displayMessage(MessageModes.Blue, 'The goblin dies an horrible death.')
end
end
function checkTalk(name, level, mode, text, channelId, pos)
if text == "Hahahaha!" and name == "Goblin" then
playSound("laugh_goblin")
modules.game_textmessage.displayMessage(MessageModes.Blue, 'The goblin laughs at you.') -- debug
end
end
Is there any specific setup to do on the files, besides being ogg? Also the onDeath event seems to fire twice for no reason