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 → Whats wrong with this cog?
Whats wrong with this cog?
2004-04-10, 7:09 AM #1
The sound works correctly, plays the correct sound at the correct location... but no sparks appear. I can't figure out whats wrong with it.

Code:
# Jedi Knight Cog Script
#
# DS_sparks.cog
#
# This cog will create sparks at a ghost position at a user
# defined interval, volume, and max distance
#
# [DSettahr]
#
# (C) 2004 by DSettahr.  You may use or modify this cog as you like as long as you
# provide credit to me.

symbols

	message		startup
	message		pulse
	thing 		ghostthing
	float		interval=5.0
	flex		distance=-1
	flex		volume=1.0
	vector		ghostposition				local
	int		garbage					local
	template	sparks=+sparks				local
	sound		snd=00ElectrExplo01.wav 		local

end

code

startup:
	//Get the position of the ghost object
	ghostposition = GetThingPos( ghostthing );

	//Set the pulse rate from the user defined interval
	SetPulse( interval );

	return;

pulse:

	PlaySoundPos( snd, ghostposition, 1.0, -1, distance, 0 );
	CreateThing( sparks, ghostposition );

	return;
end


------------------
And everything under the sun is in tune, but the sun is eclipsed by the moon...
DSettahr's Homepage | Cantina Cloud | Rally NY
2004-04-10, 7:28 AM #2
Nevermind, I figured out whats wrong with it. CreateThing() takes a thing object and creates the new thing at its position, rather than a vector position.

------------------
And everything under the sun is in tune, but the sun is eclipsed by the moon...
DSettahr's Homepage | Cantina Cloud | Rally NY
2004-04-10, 7:28 AM #3
Heres the fixed version if anyone wants to use it.

Code:
# Jedi Knight Cog Script
#
# DS_sparks.cog
#
# This cog will create sparks at a ghost position at a user
# defined interval, volume, and max distance
#
# [DSettahr]
#
# (C) 2004 by DSettahr.  You may use or modify this cog as you like as long as you
# provide credit to me.  Thanks to Elmo for helping with a bug in this cog.

symbols

	message		startup
	message		pulse
	thing 		ghostthing
	float		interval=5.0
	flex		distance=-1
	flex		volume=1.0
	vector		ghostposition				local
	int		garbage					local
	template	sparks=+sparks				local
	sound		snd=00ElectrExplo01.wav 		local

end

code

startup:
	//Get the position of the ghost object
	ghostposition = GetThingPos( ghostthing );

	//Set the pulse rate from the user defined interval
	SetPulse( interval );

	return;

pulse:

	//Play the sound at the ghost position
	PlaySoundPos( snd, ghostposition, 1.0, -1, distance, 0 );

	//Create the sparks at the ghost position
	CreateThing( sparks, ghostthing );

	return;
end


------------------
And everything under the sun is in tune, but the sun is eclipsed by the moon...
DSettahr's Homepage | Cantina Cloud | Rally NY

↑ Up to the top!