Ok, here's my cog:
It works fine, but after the 3rd track, the sound stops. I'm almost positive that there's no bug in this code, so what in the world is the problem? Or is the code buggy and CogWriter and I are just blind? Thanks!
Code:
# 00_music.cog # # Soundtrack Code for (Edited for security reasons). # # TheTwistedSpasm # # This cog is not supported be LEC symbols sound track0=track0.wav local sound track1=track1.wav local sound track2=track2.wav local sound track3=track3.wav local sound track4=track4.wav local flex cursound local flex randfig=0 local flex soundlen local int music=0 local int player local int randnum=0 local message startup message activated message timer end code startup: player = GetLocalPlayerThing(); Return; activated: if(!Music) { Print("Music Enabled"); music = 1; SetInvActivated(116, 1); SetTimer(1); Return; } else if(Music) { Print("Music Disabled"); music = 0; SetInvActivated(116, 0); StopSound(cursound, 3.0); Return; } Return; timer: Print("This proves my L33T cogging skillz!"); //Making sure the timer worked right if(Music) { randfig = Rand(); if(randfig <= 0.2) randnum = 0; if(randfig <= 0.4 && randfig > 0.2) randnum = 1; if(randfig <= 0.6 && randfig > 0.4) randnum = 2; if(randfig <= 0.8 && randfig > 0.6) randnum = 3; if(randfig > 0.8) randnum = 4; cursound = PlaySoundLocal(track0[randnum], 0.4, 0, 0x0); Print("Track"); PrintInt(randnum); soundlen = GetSoundLen(track0[randnum]); Sleep(soundlen); //stop the cog till the song's done StopSound(cursound, 1.0); //make sure the track stops SetTimer(10 + (Rand()*50)); //set a random time till next track Return; } Return; end
It works fine, but after the 3rd track, the sound stops. I'm almost positive that there's no bug in this code, so what in the world is the problem? Or is the code buggy and CogWriter and I are just blind? Thanks!
Cynic (sin'ik) n. One of a sect of ancient Greek philosophers who held that virtue is the ultimate goal of life, their doctrine gradually coming to symbolize insolent self-righteousness.
Drink So-Be, and play longer!
Drink So-Be, and play longer!