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 → Teleport what?
Teleport what?
2003-10-20, 10:24 AM #1
Hi!
This COG is to teleport an object to somewhere else with some nice fancy graphics. But...
Code:
# Teleporter
#
# By Edward
symbols

message		startup
message		activated
message		pulse

thing		inthere		local

sector		chamber

template	upstuff
template	dissapear
template	extra

surface		door0
surface		door1
surface		door2
surface		door3
surface		door4
surface		door5

thing		destination

thing		emitter

thing		con

int		i		local

int		on=0		local

sound		doors
sound		going
sound		nope

thing		player		local

thing		ont		local

end
#
code
startup:
	SetSectorAdjoins(chamber,1);
	for(i=0; i<6; i=i+1) {
		SetAdjoinFlags(door0,0x2);
		SetFaceGeoMode(door0,0); }
	SetPulse(0.1);
return;
activated:
	If(GetSenderRef()!=con) return;
	player=GetSourceRef();
	If(on!=0) return;
	on=1;
	PlaySoundThing(doors,emitter,1,-1,10,0xC0);
	for(i=0; i<6; i=i+1) {
		ClearAdjoinFlags(door0,0x2);
		SetFaceGeoMode(door0,4); }
	Sleep(1);
	inthere=FirstThingInSector(chamber);
	if(inthere==-1)
	{
		PlaySoundThing(nope,player,1,-1,-1,0x0);
		sleep(1);
	}
	else
	{
		on=2;
		sleep(1);
		SetSectorAdjoins(chamber,0);
		PlaySoundThing(going,emitter,1,-1,10,0xC0);
		sleep(1);
		inthere=FirstThingInSector(chamber);
		while(inthere!=-1)
		{
			CreateThing(dissapear,inthere);
			TeleportThing(inthere,destination);
			CreateThing(dissapear,inthere);
			ont=inthere;
			inthere=NextThingInSector(ont);
		}
		sleep(1);
		on=1;
		SetSectorAdjoins(chamber,1);
		sleep(1);
	}
	PlaySoundThing(doors,emitter,1,-1,10,0xC0);
	for(i=0; i<6; i=i+1) {
		SetAdjoinFlags(door0,0x2);
		SetFaceGeoMode(door0,0); }
	on=0;
return;
pulse:
	if(on!=2) return;
	CreateThing(upstuff,emitter);
return;
end

All works well. Nothing in chamber, make a sound (nope). But, when I place something there (example I placed was a Sequencer) the console (con) and me got teleported to the destination, but not the stuff in the chamber. HELP!

/Edward
Edward's Cognative Hazards
2003-10-20, 3:38 PM #2
Its only teleporting the player because that all your telling it to teleport.

Go download OTS. Play it for a minute, and realize that the teleporters in OTS do exactally what you need.


Crack open the gob in your favorite gob editor, and take a look at 'ots_teleport.cog'. (I think thats the name of it..) It will contain the code to do what you want.

------------------
Fight the future.
And when the moment is right, I'm gonna fly a kite.
2003-10-20, 8:53 PM #3
Not only the player... The console aswell!

But I'll have a look in the OTS...

/Edward
Edward's Cognative Hazards
2003-10-21, 6:08 AM #4
Hm... Talk about express mail!

Anyway, all seems to be well! The Seq teleported as planned.

New problem:
Code:
# Teleporter
#
# By Edward
symbols

message		startup
message		activated
message		pulse

thing		inthere		local

sector		chamber

template	upstuff
template	disappear
template	extra

surface		door0
surface		door1
surface		door2
surface		door3
surface		door4
surface		door5

thing		destination

thing		emitter

thing		con

int		i		local

int		on=0		local

sound		doors
sound		going
sound		nope

thing		player		local

thing		ont		local

end
#
code
startup:
	SetSectorAdjoins(chamber,1);
	for(i=0; i<6; i=i+1) {
		SetAdjoinFlags(door0,0x2);
		SetFaceGeoMode(door0,0); }
	SetPulse(0.1);
return;
activated:
	If(GetSenderRef()!=con) return;
	player=GetSourceRef();
	If(on!=0) return;
	on=1;
	PlaySoundThing(doors,emitter,1,-1,10,0xC0);
	for(i=0; i<6; i=i+1) {
		ClearAdjoinFlags(door0,0x2);
		SetFaceGeoMode(door0,4); }
	Sleep(1);
	inthere=FirstThingInSector(chamber);
	if(inthere==-1)
	{
		PlaySoundThing(nope,player,1,-1,-1,0x0);
		sleep(1);
	}
	else
	{
		on=2;
		sleep(1);
		SetSectorAdjoins(chamber,0);
		PlaySoundThing(going,emitter,1,-1,10,0xC0);
		sleep(1);
		for(i=0; i<=GetThingCount(); i=i+1)
		{
			if(GetThingSector(i)==chamber)
			{
				CreateThing(disappear,i);
				TeleportThing(i,destination);
				CreateThing(disappear,i);
			}
		}
		sleep(1);
		on=1;
		SetSectorAdjoins(chamber,1);
		sleep(1);
	}
	PlaySoundThing(doors,emitter,1,-1,10,0xC0);
	for(i=0; i<6; i=i+1) {
		SetAdjoinFlags(door0,0x2);
		SetFaceGeoMode(door0,0); }
	on=0;
return;
pulse:
	if(on!=2) return;
	CreateThing(upstuff,emitter);
	CreateThing(extra,destination);
return;
end

How come I'm getting several disappear effects at the destination and only one where the thing used to be?

/Edward
Edward's Cognative Hazards
2003-10-21, 7:15 AM #5
Becuase there problably isnt enough time for the object to be created before the parent is teleported away, ergo, its created at the new position.

Adda Sleep(0.1); inbetween them, or the like. It should fix it.

------------------
Fight the future.
And when the moment is right, I'm gonna fly a kite.
2003-10-21, 10:00 AM #6
OK, I've added a sleep(0.05); on either end of the TeleportThing, and it seems to me it is creating the disappearing thing for evey object in the level.

I only have 39 objects.

/Edward
Edward's Cognative Hazards
2003-10-21, 10:25 AM #7
Umm . . . how many sectors do you have in your level?

------------------
Fight the future.
And when the moment is right, I'm gonna fly a kite.
2003-10-21, 11:43 AM #8
263
Edward's Cognative Hazards

↑ Up to the top!