Ulysses
General => Developers Corner => Topic started by: Golden-Death on October 29, 2006, 11:30:45 PM
-
For monkeys sake, I've been fooling around with this for ages. No matter how I try to get a sound to play using lua, it doesnt work.
It works with 'play' in console.
It works in an old swep I made
but in this script, no matter what I try, it won't (@*# play.
function PickRandSong()
GTMSongList = _file.Find( "sound/"..GTM.SongFolder.."*.mp3" );
GTMSongNum = table.getn(GTMSongList)
if GTMSongNum <= 3 then
local more = 4 - GTMSongNum
_PrintMessageAll(HUD_PRINTTALK, "You cant play with less than 4 songs! Add at least "..more.." more songs and try again.\n")
_PrintMessageAll(HUD_PRINTCONSOLE, "You cant play with less than 4 songs! Add at least "..more.." more songs and try again.\n")
return;
end
GTMSongPlayingNum = math.random(1,GTMSongNum)
_Msg("Picked: "..GTMSongPlayingNum.."\n")
_PlaySound( ""..GTM.SongFolder..GTMSongList[GTMSongPlayingNum].."\n")
_Msg( ""..GTM.SongFolder..GTMSongList[GTMSongPlayingNum].."\n")
end
-
Perhaps this is an engine bug, it only works in SWEPS. Not even ulx playsound works.
-
Are you trying to play mp3s?
-
Are you trying to play mp3s?
Answering for GD...
GTMSongList = _file.Find( "sound/"..GTM.SongFolder.."*.mp3" );
:D Yes
-
Are you trying to play mp3s?
Yes, but wavs do not work either.
-
I've heard from many sources that MP3's don't work, but wavs work fine.
EDIT: What's the output from the _Msg() function?
-
I've tried using the exact code that worked in a swep via console/this script, it doesn't play, but it works fine in the script.
And me entering:
_PlaySound("elvis.mp3") inside the swep works.
I put that exact same thing in a simple
function lol()
_PlaySound("elvis.mp3")
end
and it still doesnt work.
] lua_openscript GuessThatMusic/init.lua
] startmusicgame
Picked: 3
GTMSongs/s1.mp3
A game of 'Guess That Music' by Golden-Death has been started!