Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Could some make me a sound cog?
Could some make me a sound cog?
2001-12-10, 7:59 AM #1
Could some make me (or tell me where to find) a cog that, when a switch is pressed, a sound is heard in specific sectors?

I need this fairly quickly, and I'll give you credit if it works... [http://forums.massassi.net/html/wink.gif]
2001-12-10, 9:57 AM #2
Code:
#12/2001 GBK
Symbols
Message Activated
Sound Sound_to_play
Surface Switch
Sector Sector_to_use
End
Code
Activated:
Playsoundpos(Sound_to_play, Getsectorcenter(Sector_to_use), 1.0, -1, 10.0, 0);
Stop;
End


To steal a phrase from Cavey - Credit me. [http://forums.massassi.net/html/smile.gif]

BTW, I dont know if it works, I just typed it into the box. But it should... [http://forums.massassi.net/html/biggrin.gif]

------------------
Success is the inverse relationship between effort, gain, and loss.
And when the moment is right, I'm gonna fly a kite.
2001-12-10, 10:27 AM #3
Ewww, GBK... your cog is ugly!

Code:
# Jedi Knight Cog Script
#
# Soundthingy.COG
#
# [Cave_Demon, 12/10/2001]
# 
#
# This Cog is Not supported by LucasArts Entertainment Co

symbols
surface	switch
sound		playsound
sector		playsector
int		act=0		local
flex		volume=4
message activated


end

# ========================================================================================

code
activated:
if(act == 0)
{
act = 1;
SetSurfaceCel(switch, 1);
SetSurfaceCel(switch, 0);
  PlaySoundPos(playsound, GetSectorCenter(playsector), volume, 10, 10, 0x1000);
Sleep(GetSoundLen(playsound));
act = 0;
}
else
if(act == 1)
{
Return;
}
Return;

# ........................................................................................

end


This cog plays the sound only once, and it actually "animates" the switch [http://forums.massassi.net/html/tongue.gif]

Credit me.

------------------
Punainen tiili kädes, sinä vapauteesi juokse.
Välil maan ja taivaan raha menee rahan luokse.
Alas kapitalismin kahleet, näin unessani enteen.
Elä aatteidesi puolesta, vedä vielä kerran henkee.

Punainen Tiili kädes, huomenna kaikki muuttuu.
Raha enää vain muisto, rakkaus enää vain puuttuu.
Alas kapitalismin kahleet, näin unessani enteen.
Elä aatteidesi puolesta, vedä vielä kerran henkee.

[This message has been edited by Cave_Demon (edited December 10, 2001).]
WHAT?
2001-12-10, 12:19 PM #4
Umm, Cavey, you do realize 'Volume' wont go past 1.0, dont you?

------------------
Success is the inverse relationship between effort, gain, and loss.
And when the moment is right, I'm gonna fly a kite.
2001-12-11, 5:11 AM #5
Cave_Demon, your cog doesn't work. When I tried to press the switch it didn't do anything.

The switch didn't even go green!!

Any suggestions? [http://forums.massassi.net/html/confused.gif] [http://forums.massassi.net/html/frown.gif]
2001-12-11, 5:28 AM #6
Try this one on for size. It allows you to specify weither or not to allow multiple playings. (BTW, I changed it to ghost-based, getting sounds to work off sectorcenters is a pain in the @ss.)

 

Code:
#12/2001 GBK
Symbols
Message Activated
Sound Sound
Surface Switch
Thing Ghost
Int Onetime=1
Int Channel=-1		Local
End
Code
Activated:
If(Channel != -1) Stop; 
Setwallcel(Switch, 1);
Channel = Playsoundpos(Sound, Getthingpos(Ghost), 1.0, -1, 100.0, 0);
Sleep(Getsoundlen(Sound));
Setwallcel(Switch, 0);
If(Onetime != 0) Stop;
Channel = -1;
Stop;
End


It works, I tested it. [http://forums.massassi.net/html/biggrin.gif]

------------------
Success is the inverse relationship between effort, gain, and loss.
And when the moment is right, I'm gonna fly a kite.
2001-12-11, 5:29 AM #7
Hmm... well, i made it at 23:00 (11:00 pm) and didn't test it [http://forums.massassi.net/html/smile.gif]

What do you mean with that volume won't go under 1.0? I know it doesn't!

------------------
Punainen tiili kädes, sinä vapauteesi juokse.
Välil maan ja taivaan raha menee rahan luokse.
Alas kapitalismin kahleet, näin unessani enteen.
Elä aatteidesi puolesta, vedä vielä kerran henkee.

Punainen Tiili kädes, huomenna kaikki muuttuu.
Raha enää vain muisto, rakkaus enää vain puuttuu.
Alas kapitalismin kahleet, näin unessani enteen.
Elä aatteidesi puolesta, vedä vielä kerran henkee.
WHAT?
2001-12-11, 5:30 AM #8
Ooops, forgot to mention - the 'Onetime' variable determines the multiple playability. Set it to 0 to play evry time the switch is pressed, else itll play only once.

------------------
Success is the inverse relationship between effort, gain, and loss.
And when the moment is right, I'm gonna fly a kite.
2001-12-11, 5:32 AM #9
Volume in 'sound' cog verbs wont go PAST 1.0. In your cog, you had the volume preset to 4.

------------------
Success is the inverse relationship between effort, gain, and loss.
And when the moment is right, I'm gonna fly a kite.

↑ Up to the top!