
The New Threat 3 |
| SOLVED! (Moderator: Edward) | Previous Topic | Next Topic |
| Page 1 of 1 |
|
# Platform Elevator with up-down and call switches. Support for 8 floors. # # By Edward flags=0x240 symbols message startup message activated message trigger message pulse message arrived thing elev linkid=5,mask=0xFFF thing upswitch linkid=5,mask=0xFFF thing downswitch linkid=5,mask=0xFFF surface callswitch0 linkid=5 surface callswitch1 linkid=5 surface callswitch2 linkid=5 surface callswitch3 linkid=5 surface callswitch4 linkid=5 surface callswitch5 linkid=5 surface callswitch6 linkid=5 surface callswitch7 linkid=5 vector floor0 vector floor1 vector floor2 vector floor3 vector floor4 vector floor5 vector floor6 vector floor7 flex startspeed flex rate local flex inc flex maxspeed flex speed local flex vdist local int vdistI local int numfloors=7 int startfloor=0 sound switchit sound startmove sound contimove sound stopmove int ch1=-1 local thing temp=-1 local int frame local int startframe local vector offset0 local vector offset1 local vector looking0 local vector looking1 local int i local int outofcom=0 local end # code startup: sleep(rand()); outofcom=1; AttachThingToThing(upswitch,elev); AttachThingToThing(downswitch,elev); offset0=VectorSub(GetThingPos(upswitch),GetThingPos(elev)); offset1=VectorSub(GetThingPos(downswitch),GetThingPos(elev)); looking0=GetThingLVec(upswitch); looking1=GetThingLVec(downswitch); MoveToFrame(elev,0,100); return; activated: If(GetSenderID()==5) { If(IsMoving(elev)) return; SendTrigger(-1,GetSelfCog(),callswitch0,GetSenderRef(),-1,-1); } if(GetParam(0)==128) { If(IsMoving(elev)) return; SendTrigger(-1,GetSelfCog(),callswitch0,callswitch5,-1,-1); } else if(GetParam(0)==129) { If(IsMoving(elev)) return; SendTrigger(-1,GetSelfCog(),callswitch0,upswitch,-1,-1); } return; trigger: If(GetSourceRef()!=GetSelfCog()) return; if(GetParam(0)!=callswitch0) return; ParseArg(elev,"soundclass=none"); ParseArg(upswitch,"move=none"); ParseArg(downswitch,"move=none"); for(i=0; i<8; i=i+1) SetWallCel(callswitch0[i], 0); if(GetParam(1)==upswitch) { PlaySoundThing(switchit,upswitch,1,-1,-1,0x80); if(GetCurFrame(elev)+1>numfloors) { PlaySoundThing(stopmove,elev,1,-1,100,0x80); return; } PlaySoundThing(startmove,elev,1,-1,100,0x80); ch1=PlaySoundThing(contimove,elev,0,-1,100,0x81); ChangeSoundPitch(ch1,.01,.01); ChangeSoundVol(ch1,1,1); startframe=GetCurFrame(elev); frame=GetCurFrame(elev)+1; } else if(GetParam(1)==downswitch) { PlaySoundThing(switchit,downswitch,1,-1,-1,0x80); if(GetCurFrame(elev)-1<0) { PlaySoundThing(stopmove,elev,1,-1,100,0x80); return; } PlaySoundThing(startmove,elev,1,-1,100,0x80); ch1=PlaySoundThing(contimove,elev,0,-1,100,0x81); ChangeSoundPitch(ch1,.01,.01); ChangeSoundVol(ch1,1,1); startframe=GetCurFrame(elev); frame=GetCurFrame(elev)-1; } else { for(i=0; i<=numfloors; i=i+1) { if(GetParam(1)==callswitch0[i]) { PlaySoundPos(switchit,GetSurfaceCenter(callswitch0[i]),1,-1,-1,0x0); PlaySoundThing(startmove,elev,1,-1,100,0x80); ch1=PlaySoundThing(contimove,elev,0,-1,100,0x81); ChangeSoundPitch(ch1,.01,.01); ChangeSoundVol(ch1,1,1); startframe=GetCurFrame(elev); frame=i; } } } return; pulse: AttachThingToThing(upswitch,elev); AttachThingToThing(downswitch,elev); if(frame==-1) { speed=startspeed; } else { SetWallCel(callswitch0[frame],1); if((speed<maxspeed) && (vdistI==0)) { speed=speed+inc; } else if(speed>=maxspeed) { speed=maxspeed; if(vdistI==0) { vdist=VectorDist(GetThingPos(elev),floor0[startframe]); vdistI=1; } } if((VectorDist(GetThingPos(elev),floor0[frame])<vdist) && (vdistI==1)) { speed=speed-inc; } if(speed<startspeed) { speed=startspeed; frame=-1; } ChangeSoundPitch(ch1,speed/10,0.01); MoveToFrame(elev,frame,speed); } return; arrived: If(GetSenderRef()!=elev) return; If(outofcom==1) { floor0[GetCurFrame(elev)]=GetThingPos(elev); if(GetCurFrame(elev)<numfloors) { MoveToFrame(elev,GetCurFrame(elev)+1,100); } else { outofcom=0; MoveToFrame(elev,startfloor,100); frame=-1; vdistI=0; for(i=0; i<8; i=i+1) SetWallCel(callswitch0[i],0); SetWallCel(callswitch0[startfloor],1); SetPulse(0.02); } } else { StopSound(ch1,1); # StopThing(elev); PlaySoundThing(stopmove,elev,1,-1,100,0x80); vdistI=0; frame=-1; temp=-1; while(temp==-1) temp=FireProjectile(elev,GetThingTemplate(upswitch),-1,-1,VectorSet(VectorX(offset0),VectorY(offset0),VectorZ(offset0)),GetThingLVec(upswitch),0,0,0,0); If(upswitch>1) TeleportThing(upswitch,temp); DestroyThing(temp); temp=-1; while(temp==-1) temp=FireProjectile(elev,GetThingTemplate(downswitch),-1,-1,VectorSet(VectorX(offset1),VectorY(offset1),VectorZ(offset1)),GetThingLVec(downswitch),0,0,0,0); if(downswitch>1) TeleportThing(downswitch,temp); DestroyThing(temp); SetThingLook(upswitch,looking0); SetThingLook(downswitch,looking1); } return; end |
| Page 1 of 1 | |
| SOLVED! (Moderator: Edward) | Previous Topic | Next Topic |