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;
- 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();
- 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(pLid,[PRIM_ROT_LOCAL,rot]);
- }
- 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);
- llListenRemove(listenHandle);
- listenHandle = llListen(dialogChannel,"",ToucherID,"");
- llDialog(ToucherID,dialogInfo,options,dialogChannel);
- }
- }
- 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 += 0.1275;
- llSetLinkPrimitiveParams(pLevel,[PRIM_POS_LOCAL,loc]);
- llSay(0,"Your bin is now at "+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 -= 0.1275;
- llSetLinkPrimitiveParams(pLevel,[PRIM_POS_LOCAL,loc]);
- llSay(0,"Your bin is now at "+level*10+"%\n");
- }
- else
- {
- llSay(0,"Your bin is empty.\n");
- }
- }
- else if (message == "-")
- {
- llDialog(ToucherID, dialogInfo, options, dialogChannel);
- return;
- }
- else
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement