PDA

View Full Version : Teleport what?



Edward
10-20-2003, 01:24 PM
Hi!
This COG is to teleport an object to somewhere else with some nice fancy graphics. But...


# 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[i],0x2);
SetFaceGeoMode(door0[i],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[i],0x2);
SetFaceGeoMode(door0[i],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[i],0x2);
SetFaceGeoMode(door0[i],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

gbk
10-20-2003, 06:38 PM
Its only teleporting the player because that all your telling it to teleport.

Go download OTS (http://www.massassi.net/levels/files/2533.shtml). 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 (http://12.220.251.111/ol/cogpad/cogpad.html).

Edward
10-20-2003, 11:53 PM
Not only the player... The console aswell!

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

/Edward

Edward
10-21-2003, 09:08 AM
Hm... Talk about express mail!

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

New problem:


# 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[i],0x2);
SetFaceGeoMode(door0[i],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[i],0x2);
SetFaceGeoMode(door0[i],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[i],0x2);
SetFaceGeoMode(door0[i],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

gbk
10-21-2003, 10:15 AM
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 (http://12.220.251.111/ol/cogpad/cogpad.html).

Edward
10-21-2003, 01:00 PM
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

gbk
10-21-2003, 01:25 PM
Umm . . . how many sectors do you have in your level?

------------------
Fight the future (http://12.220.251.111/ol/cogpad/cogpad.html).

Edward
10-21-2003, 02:43 PM
263