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 → Problems using CreateThing () and PlayKey ()
Problems using CreateThing () and PlayKey ()
2002-06-30, 4:30 AM #1
Can anyone help me with this COG? When I use it, a ship template appears at the selected ghost position, but the keyframe animation doesn't play. Oh, and thanks again to Descent_pilot for showing me the 'if done' code...:

# Jedi Knight Cog Script
#
# ship_flyby.COG
#
# Description
# Cog for a ship to fly by when player enters a certain sector.
#
# Includes code designed by Descent-pilot in his key_player.cog
#
# This Cog is Not supported by LucasArts Entertainment Co

symbols

sector area
template shiptemplate
thing shipthing0
sound shipsound
keyframe flyby0
int done=0 local
message entered

end

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

code

entered:

if(!done) // So it doesn't play twice
{
done = 1;
creatething(shiptemplate, shipthing0); //Create a ship at ghostthing
PlayKey(shipdummy0, flyby0, 1, 0x4); // This is the line that will play the key
playsoundlocal(shipsound, 1, 0, 0); // This plays engine sounds
destroything(shipthing0); //destroys ship when animation finished
}
return;
# ........................................................................................
end
2002-06-30, 4:36 AM #2
Ok, I've spotted one obvious mistake I made. The PlayKey line should read:

PlayKey(shipthing0, flyby0, 1, 0x4);

But it still isn't working, so all ideas welcome!...
2002-06-30, 4:43 AM #3
do you have a .pup specified in the ship template?

------------------
Last week I cudn't evn spel grajuat, but now I is one.
2002-06-30, 6:02 AM #4
Yes, I did put a .pup file in this time - I've made that mistake before (one of many [http://forums.massassi.net/html/smile.gif]). Here is the template data anyhow:

# DESC: tiefighter with PUP file
# BBOX: -.35 -.41 -.48 .35 .38 .48
tiefighter_flt _zwalkstruct model3d=tief.3do size=.659152 movesize=.659152 puppet=cr.pup
2002-06-30, 7:59 AM #5
Something even more obvious, you arent capturing the ship...;

Blah = Creatething(..)

Playkey(Blah, ..)

------------------
I used to believe that we only want what we can't have. I was wrong. The truth is, the wonderful truth is, we only want what we think we can't have.

JK editing resources.
And when the moment is right, I'm gonna fly a kite.
2002-06-30, 8:31 AM #6
Try this: [http://forums.massassi.net/html/smile.gif]

Code:
# Jedi Knight Cog Script
#
# ship_flyby.COG
#
# Description
# Cog for a ship to fly by when player enters a certain sector.
#
# Includes code designed by Descent-pilot in his key_player.cog
#
# This Cog is Not supported by LucasArts Entertainment Co
#==============================================================#
symbols

sector    area
thing     ghost
thing     ship      local
template  shipTpl
sound     shipSnd
keyframe  flyby
int       done=0    local

message   entered

end
#==============================================================#
code
#------------------------------------------------------
entered:
	if(!done)
	{
		done = 1;
		ship = CreateThing(shipTpl, ghost);
		PlayKey(ship, flyby, 1, 0x4);
		PlaySoundLocal(shipSnd, 1, 0, 0);
		Sleep(GetKeyLen(flyby));
		DestroyThing(ship);
	}

Return;
#------------------------------------------------------
end


For this to work, create a thing with the ghost template in your level where you want the ship to appear.

BTW, you should enclose your cogscript inside UBB code tags.

------------------
Author of the JK DataMaster, Parsec, and the EditPlus Cog Files.
Visit Saber's Domain.

[This message has been edited by SaberMaster (edited June 30, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

↑ Up to the top!