Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //list options = ["Add","Get","Close","-"];
- integer dialogChannel;
- integer listenHandle;
- string dialogInfo = "\nPlease make a choice.";
- key ToucherID;
- integer pLid;
- integer pLevel;
- integer dir = 1;
- integer level;
- float z;
- menu(key id)
- {
- llListenRemove(listenHandle);
- listenHandle = llListen(dialogChannel,"",ToucherID,"");
- list options = [];
- if(level < 10) options += ["Add"];
- if(level) options += ["Get"];
- options += ["Close"];
- llDialog(id,dialogInfo,options,dialogChannel);
- }
- setPrimNumbers()
- {
- integer i;
- for (i=1;i<=llGetNumberOfPrims();i++)
- {
- if (llGetLinkName(i) == "lid")
- {
- pLid = i;
- }
- else if (llGetLinkName(i) == "level")
- {
- pLevel = i;
- }
- }
- }
- default
- {
- state_entry()
- {
- rotation rot;
- //rotation d90 = llEuler2Rot(<0,0,90>*DEG_TO_RAD);
- vector e90 = <0,0,90>*DEG_TO_RAD;
- rotation d90 = llEuler2Rot(e90);
- dir=1;
- level=0;
- setPrimNumbers();
- vector scale = llGetScale();
- z = scale.z/11;
- dialogChannel = -1 - (integer)("0x" + llGetSubString( (string) llGetKey(), -7, -1) );
- list params = llGetLinkPrimitiveParams(pLid,[PRIM_ROT_LOCAL]);
- rot = llList2Rot(params,0);
- vector vec = llRot2Euler(rot);
- vector vec90 = llRot2Euler(d90);
- rot = llEuler2Rot(<vec.x, vec.y, vec90.z>);
- llSetLinkPrimitiveParamsFast(LINK_SET,[PRIM_LINK_TARGET,pLid,PRIM_ROT_LOCAL,rot,PRIM_LINK_TARGET,pLevel,PRIM_POS_LOCAL,<0,0,-(z*5)>]);
- }
- touch_start(integer num_total)
- {
- if(llDetectedLinkNumber(0) == pLid)
- {
- dir *= -1;
- list params = llGetLinkPrimitiveParams(pLid,[PRIM_ROT_LOCAL]);
- rotation rot = llList2Rot(params,0);
- llSetLinkPrimitiveParamsFast(pLid,[PRIM_ROT_LOCAL,llEuler2Rot(<0, 0, dir * PI_BY_TWO>) * rot]);
- }
- else
- {
- ToucherID = llDetectedKey(0);
- menu(ToucherID);
- }
- }
- listen(integer channel, string name, key id, string message)
- {
- if (message == "Add")
- {
- if (level < 10)
- {
- level +=1;
- list params = llGetLinkPrimitiveParams(pLevel,[PRIM_POS_LOCAL]);
- vector loc = llList2Vector(params,0);
- loc.z += z;
- llSetLinkPrimitiveParams(pLevel,[PRIM_POS_LOCAL,loc]);
- llSay(0,"Your bin is now at "+(string)(level*10)+"%\n");
- }
- else
- {
- llSay(0,"Your bin is full.\n");
- }
- }
- else if (message == "Get")
- {
- if (level > 0)
- {
- level -=1;
- list params = llGetLinkPrimitiveParams(pLevel,[PRIM_POS_LOCAL]);
- vector loc = llList2Vector(params,0);
- loc.z -= z;
- llSetLinkPrimitiveParams(pLevel,[PRIM_POS_LOCAL,loc]);
- llSay(0,"Your bin is now at "+(string)(level*10)+"%\n");
- }
- else
- {
- llSay(0,"Your bin is empty.\n");
- }
- }
- else if (message == "-")
- {
- menu(id);
- return;
- }
- else
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement