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 → A cog request
A cog request
2005-08-24, 4:29 PM #1
I would appreciate it if someone would write a cog that simply does:
1) The player activates a thing or mat.
2) A sound is played once.
3) A different sound is looped continuously until
4) The player activates this thing or mat again.
5) And it can be done as many times as wanted
2005-08-24, 7:19 PM #2
Basically it does the following:

When Activated(ON) it makes a noise and loops another noise UNTIL it's Activated again(OFF) ?

What do you mean by The player activates a thing or mat? Would a cog with an activated message and pulse be enough? I've never placed cogs in JED before...

ReT
2005-08-24, 7:54 PM #3
This should do it.
Code:
# reid_sound.cog
#
# By Emon, August 2005
#
# Some sound making thing for Reid.
#
#==============================================================================
symbols

surface		switch
thing		switchThing

sound		onSound
sound		loopSound

flex		volume=1
flex		minSoundDist=-1
flex		maxSoundDist=-1
flex		offDelay=1

int			channel					local
int			on=0					local

message		activated
message		deactivated

end
#==============================================================================
code

#------------------------------------------------------------------------------
activated:
	if(!on)
	{
		setSurfaceCel(switch, 1);
		channel = playSoundPos(onSound, getSurfaceCenter(switch), volume,
							   minSoundDist, maxSoundDist, 0x0);
		channel = playSoundPos(loopSound, getSurfaceCenter(switch), volume,
							   minSoundDist, maxSoundDist, 0x1);
	}
	else
	{
		setSurfaceCel(switch, 0);
		stopSound(channel, offDelay);
	}
	return;

end


Description of symbols.

switch and switchThing = The switch, either a surface or a thing. You can use either.
onSound = The first sound to play when the switch is hit.
loopSound = The sound to loop.
volume = The volume of the sound, 0.0 to 1.0.
minSoundDist/maxSoundDist = The minimum and maximum sound distances for the sound to be heard. The sound will be played at full volume within the min dist and fade to 0 towards the max dist. They default to -1, which will tell JK to use the default distances.
offDelay = A fade delay, in seconds for when the sound turns off. If you set this to 2.0, the sound will fade to a volume of 0 over 2.0 seconds.

This COG will also animate the surface switch. When it's activated it will switch to the second cel (cel #1) and switch back to the first cel when it's activated again (cel #0).
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2005-08-25, 6:46 PM #4
The cog has 1 problem: When you activate the thing/surface again, it doesn't shut it off, its only will start a new sound loop that mixes with the first one.
2005-08-25, 6:54 PM #5
Code:
# reid_sound.cog
#
# By Emon, August 2005
#
# Some sound making thing for Reid.
#
#=================================================  
symbols

surface		switch
thing		switchThing

sound		onSound
sound		loopSound

flex		volume=1
flex		minSoundDist=-1
flex		maxSoundDist=-1
flex		offDelay=1

int			channel					local
int			on=0					local

message		activated
message		deactivated

end
#=================================================  
code

#------------------------------------------------------------------------------
activated:
	if(!on)
	{
		setSurfaceCel(switch, 1);
		channel = playSoundPos(onSound, getSurfaceCenter(switch), volume,
							   minSoundDist, maxSoundDist, 0x0);
		channel = playSoundPos(loopSound, getSurfaceCenter(switch), volume,
							   minSoundDist, maxSoundDist, 0x1);
                on = 1;
	}
	else
	{
		setSurfaceCel(switch, 0);
		stopSound(channel, offDelay);
                on = 0;
	}
	return;

end


That should fix his code, he forget to change the var hehe
</sarcasm>
<Anovis> mmmm I wanna lick your wet, Mentis.
__________
2005-08-25, 8:03 PM #6
Ok thanks.

Where did you learn how to write in the cog language?
2005-08-25, 8:22 PM #7
Some tutorials here on massassi, some old hack tutorials and mostly just messing around and learning by mistakes.
</sarcasm>
<Anovis> mmmm I wanna lick your wet, Mentis.
__________
2005-08-25, 9:04 PM #8
Knowing the syntax and then just memorizing every command and what it does over time.
visit my project

"I wonder to myself. Why? Simply why? Why why? Why do I ask why? Why do I need to find out why? Why do I have to ask why as a question? Why is why always used to find out why? Why is the answer to why always why? Why is there no final answer to why? Simply why not? Holy cow, this is pretty deep, meaningful **** I wrote. Glad I wrote it down. Oh man."
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ [slog], Echoman
2005-08-26, 12:46 AM #9
The DataMaster (THE cog reference) also contains some useful tutorials: [url]www.geocities.com/sabersdomain[/url]
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2005-08-27, 2:09 PM #10
WOW ty I already made a cog(a doorbell :) )

↑ Up to the top!