Could also be used for doors etc.
Instructions (Copy to NC or Script)
// V4 // // INSTRUCTIONS FOR USE (there are two scripts that make up the set) // Make your chest of drawers and link the whole set together with the body (any prim that doesn't move) of the chest as the root. // Name every prim used as a part of a drawer (include handles, drawer fronts, bases etc.) "drawer " plus a number. // All the prims of one drawer should now all be named the same. e.g. "drawer 1". // Name every drawer a different number. e.g. "drawer 1", "drawer 2" etc. // With all the parts named correctly, edit the object so that all the drawers are closed. // At this point you might want to take a copy. // Be sure that no prims are named "drawer (something)" unless they are supposed to be (according to the above). // Drop both the scripts (at the same time or "Linkypooz" first) into the root of the object. // You will get further instructions in local chat. Follow them.
Drawer Script
// V4 // // This script needs to be named "Linkypooz". vector open_pos; vector closed_pos; rotation open_rot; rotation closed_rot; integer OPEN; key owner; integer my_response_num; integer my_link_num; Drawer() { if(OPEN) llSetPrimitiveParams([PRIM_POSITION, closed_pos, PRIM_ROTATION, (closed_rot / llGetRootRotation())]); else llSetPrimitiveParams([PRIM_POSITION, open_pos, PRIM_ROTATION, (open_rot / llGetRootRotation())]); OPEN = (!OPEN); } default { state_entry() { owner = llGetOwner(); closed_pos = llGetLocalPos(); closed_rot = llGetLocalRot(); my_link_num = llGetLinkNumber(); my_response_num = ((integer)llGetSubString(llGetLinkName(my_link_num), 7, -1)); } touch_start(integer nd) { if(llDetectedKey(0) == owner) { if(my_link_num != 1) { open_pos = llGetLocalPos(); open_rot = llGetLocalRot(); llSetLocalRot(closed_rot); llSetPos(closed_pos); state normal; } else llRemoveInventory(llGetScriptName()); } } } state normal { state_entry() { llOwnerSay("/me is active!"); } touch_start(integer nd) { llMessageLinked(LINK_SET, my_response_num, "", ""); } link_message(integer sender, integer num, string str, key id) { if(num == my_response_num) Drawer(); } }