Advertisement
Guest User

Untitled

a guest
Apr 21st, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //list options = ["Add","Get","Close","-"];
  2. integer dialogChannel;
  3. integer listenHandle;
  4. string dialogInfo = "\nPlease make a choice.";
  5. key ToucherID;
  6.  
  7. integer pLid;
  8. integer pLevel;
  9.  
  10. integer dir = 1;
  11.  
  12. integer level;
  13.  
  14. float z;
  15.  
  16. menu(key id)
  17. {
  18.     llListenRemove(listenHandle);
  19.     listenHandle = llListen(dialogChannel,"",ToucherID,"");
  20.     list options = [];
  21.     if(level < 10) options += ["Add"];
  22.     if(level) options += ["Get"];
  23.     options += ["Close"];
  24.     llDialog(id,dialogInfo,options,dialogChannel);
  25. }
  26. setPrimNumbers()
  27. {
  28.     integer i;
  29.    
  30.     for (i=1;i<=llGetNumberOfPrims();i++)
  31.     {
  32.         if (llGetLinkName(i) == "lid")
  33.         {
  34.             pLid = i;
  35.         }
  36.         else if (llGetLinkName(i) == "level")
  37.         {
  38.             pLevel = i;
  39.         }
  40.     }
  41. }
  42.  
  43. default
  44. {
  45.     state_entry()
  46.     {
  47.         rotation rot;
  48.         //rotation d90 = llEuler2Rot(<0,0,90>*DEG_TO_RAD);
  49.         vector e90 = <0,0,90>*DEG_TO_RAD;
  50.         rotation d90 = llEuler2Rot(e90);
  51.    
  52.         dir=1;
  53.         level=0;
  54.         setPrimNumbers();
  55.         vector scale = llGetScale();
  56.         z = scale.z/11;
  57.         dialogChannel = -1 - (integer)("0x" + llGetSubString( (string) llGetKey(), -7, -1) );
  58.         list params = llGetLinkPrimitiveParams(pLid,[PRIM_ROT_LOCAL]);
  59.         rot = llList2Rot(params,0);
  60.         vector vec = llRot2Euler(rot);
  61.         vector vec90 = llRot2Euler(d90);
  62.         rot = llEuler2Rot(<vec.x, vec.y, vec90.z>);
  63.         llSetLinkPrimitiveParamsFast(LINK_SET,[PRIM_LINK_TARGET,pLid,PRIM_ROT_LOCAL,rot,PRIM_LINK_TARGET,pLevel,PRIM_POS_LOCAL,<0,0,-(z*5)>]);
  64.     }
  65.  
  66.     touch_start(integer num_total)
  67.     {
  68.         if(llDetectedLinkNumber(0) == pLid)
  69.         {
  70.             dir *= -1;
  71.             list params = llGetLinkPrimitiveParams(pLid,[PRIM_ROT_LOCAL]);
  72.             rotation rot = llList2Rot(params,0);
  73.             llSetLinkPrimitiveParamsFast(pLid,[PRIM_ROT_LOCAL,llEuler2Rot(<0, 0, dir * PI_BY_TWO>) * rot]);
  74.         }
  75.         else
  76.         {
  77.             ToucherID = llDetectedKey(0);
  78.             menu(ToucherID);
  79.         }
  80.     }
  81.    
  82.     listen(integer channel, string name, key id, string message)
  83.     {
  84.         if (message == "Add")
  85.         {
  86.             if (level < 10)
  87.             {
  88.                 level +=1;
  89.                 list params = llGetLinkPrimitiveParams(pLevel,[PRIM_POS_LOCAL]);
  90.                 vector loc = llList2Vector(params,0);
  91.                 loc.z += z;
  92.                 llSetLinkPrimitiveParams(pLevel,[PRIM_POS_LOCAL,loc]);
  93.                 llSay(0,"Your bin is now at "+(string)(level*10)+"%\n");
  94.             }
  95.             else
  96.             {
  97.                 llSay(0,"Your bin is full.\n");
  98.             }
  99.         }
  100.         else if (message == "Get")
  101.         {
  102.             if (level > 0)
  103.             {
  104.                 level -=1;
  105.                 list params = llGetLinkPrimitiveParams(pLevel,[PRIM_POS_LOCAL]);
  106.                 vector loc = llList2Vector(params,0);
  107.                 loc.z -= z;
  108.                 llSetLinkPrimitiveParams(pLevel,[PRIM_POS_LOCAL,loc]);
  109.                 llSay(0,"Your bin is now at "+(string)(level*10)+"%\n");
  110.             }
  111.             else
  112.             {
  113.                 llSay(0,"Your bin is empty.\n");
  114.             }
  115.         }
  116.         else if (message == "-")
  117.         {
  118.             menu(id);
  119.             return;
  120.         }
  121.         else
  122.         {
  123.         }
  124.     }  
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement