Ulysses

General => Developers Corner => Topic started by: Golden-Death on October 29, 2006, 11:30:45 PM

Title: CURSE YOU SOUND
Post 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.

Code: [Select]
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

Title: Re: CURSE YOU SOUND
Post by: Golden-Death on October 30, 2006, 09:30:21 PM
Perhaps this is an engine bug, it only works in SWEPS. Not even ulx playsound works.
Title: Re: CURSE YOU SOUND
Post by: Megiddo on October 30, 2006, 10:17:45 PM
Are you trying to play mp3s?
Title: Re: CURSE YOU SOUND
Post by: JamminR on October 31, 2006, 04:30:39 PM
Quote from: Megiddo
Are you trying to play mp3s?

Answering for GD...
Code: [Select]
GTMSongList = _file.Find( "sound/"..GTM.SongFolder.."*.mp3" );
:D Yes
Title: Re: CURSE YOU SOUND
Post by: Golden-Death on November 01, 2006, 03:35:28 PM
Are you trying to play mp3s?
Yes, but wavs do not work either.
Title: Re: CURSE YOU SOUND
Post by: Megiddo on November 01, 2006, 04:00:52 PM
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?
Title: Re: CURSE YOU SOUND
Post by: Golden-Death on November 01, 2006, 07:40:05 PM
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.

Code: [Select]
] lua_openscript GuessThatMusic/init.lua
] startmusicgame
Picked: 3
GTMSongs/s1.mp3
A game of 'Guess That Music' by Golden-Death has been started!