User:Cow Taurog/Sky elevator

From Second Life Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

This script makes a simple elevator that will warp between the ground and a certain height.

Sky elevator

Place this script in the main prim after all other objects have been placed inside. <lsl> integer giPlatChan=-6665; // Change both of these to something unique to each other integer giDialog=55234; // vector gvStartPos; vector gvDestPos; key gkOwner; string gsObjName="Sky platform"; list glBaseMenu=["Set height","Move to height","Move to ground","Rez plat","Unrez plat","Unrez all"]; string gsBaseMenuText="Pick an action"; list glPlatMenu=["10x10","20x20","30x30"]; string gsPlatMenu="Pick a size"; key gkDet; list glHeightMenu=["250","500","800","1000","1300","1600","2000"]; integer giListen0;

warpPos(vector destpos){if(destpos!=ZERO_VECTOR){

   integer jumps=(integer)(llVecDist(destpos,llGetPos())/10)+1;
   if(jumps>411){jumps=411;}list rules=[PRIM_POSITION,destpos];integer count=1;
   while((count=count<<1)<jumps){rules=(rules=[])+rules+rules;}
   llSetPrimitiveParams((rules=[])+rules+llList2List(rules,(count-jumps)<<1,count)); 
   if(llVecDist(llGetPos(),destpos)>0.001){while(--jumps){llSetPos(destpos);}}

}} basemenu(){llDialog(gkOwner,gsBaseMenuText,glBaseMenu,giDialog);} heightmenu(){llDialog(gkOwner,"Pick a height",glHeightMenu,giDialog);}

default{

   state_entry(){
       gkOwner=llGetOwner();
       gvStartPos=llGetPos();
       giListen0=llListen(giDialog,"",NULL_KEY,"");
       heightmenu();
       state idle;
   }
   on_rez(integer param){llResetScript();}

} state idle{

   state_entry(){
       gkOwner=llGetOwner();
       gvStartPos=llGetPos();
       giListen0=llListen(giDialog,"",NULL_KEY,"");
   }
   touch_start(integer n){
       basemenu();
   }
   listen(integer chan,string name,key id,string mess){
       if(mess=="Set height"){heightmenu();}
       if(mess=="Move to height"){state up;}
       if(mess=="Move to ground"){state down;}
       if(mess=="Rez plat"){llDialog(gkOwner,gsPlatMenu,glPlatMenu,giDialog);}
       if(mess=="Unrez plat"){llSay(giPlatChan,"unrez plat");}
       if(mess=="Unrez all"){llRegionSay(giPlatChan,"unrez plat");llDie();}
       if(mess=="150"){gvDestPos=<gvStartPos.x,gvStartPos.y,(float)mess>;basemenu();}
       if(mess=="250"){gvDestPos=<gvStartPos.x,gvStartPos.y,(float)mess>;basemenu();}
       if(mess=="500"){gvDestPos=<gvStartPos.x,gvStartPos.y,(float)mess>;basemenu();}
       if(mess=="650"){gvDestPos=<gvStartPos.x,gvStartPos.y,(float)mess>;basemenu();}
       if(mess=="800"){gvDestPos=<gvStartPos.x,gvStartPos.y,(float)mess>;basemenu();}
       if(mess=="1000"){gvDestPos=<gvStartPos.x,gvStartPos.y,(float)mess>;basemenu();}
       if(mess=="1300"){gvDestPos=<gvStartPos.x,gvStartPos.y,(float)mess>;basemenu();}
       if(mess=="1600"){gvDestPos=<gvStartPos.x,gvStartPos.y,(float)mess>;basemenu();}
       if(mess=="2000"){gvDestPos=<gvStartPos.x,gvStartPos.y,(float)mess>;basemenu();}
       if(mess=="10x10"){llRezAtRoot(mess+" platform",llGetPos()+<0,0,-2>,ZERO_VECTOR,llGetRot(),0);}
       if(mess=="20x20"){llRezAtRoot(mess+" platform",llGetPos()+<0,0,-2>,ZERO_VECTOR,llGetRot(),0);}
       if(mess=="30x30"){llRezAtRoot(mess+" platform",llGetPos()+<0,0,-2>,ZERO_VECTOR,llGetRot(),0);}
   }
   on_rez(integer param){llResetScript();}

}

state up{

   state_entry(){
       warpPos(gvDestPos);
       state idle;
   }
   on_rez(integer param){llResetScript();}

} state down{

   state_entry(){
       vector pp=llGetPos();
       vector dd=<pp.x,pp.y,llGround(<0,0,0.2>)>;
       warpPos(dd);
       state idle;
   }
   on_rez(integer param){llResetScript();}

} </lsl>

Platform killer

Place this script into the platform objects that go inside the elevator. They will die when the command is issued to kill them from the elevator. <lsl> integer giChan=-6665; // Match this to the script above default{

   state_entry(){
       llListen(-6665,"",NULL_KEY,"");
   }
   listen(integer chan, string name, key id, string mess){
       if(mess=="unrez plat"){llDie();}
   }

} </lsl>