////////////////////////////////////////////////////// //KDC EZ Door script, CC-BY-SA // // // //By: Kyrah Abattoir // // // //Purpose: Easy lineup of doors and their frames // // // //This is a free software offered with no warranty. // ////////////////////////////////////////////////////// /* The frame should be a hollowed out cube. (and in order to be the root prim, should be the last prim selected) The door itsef should be the first child prim, with the following settings: type: cube, path cut begin: 0.375, path cut end: 0.875 You can link more prims to the set it shouldn't affect it's function. Most of the code is outside of the main block, so you won't have trouble to build something more complex from this script. */ //sounds, change them if you want string open_sound = "4a23b467-2e4d-d783-3643-6fe1fe4eb179"; float open_volume = 1.0; string close_sound = "1c158e0d-df97-705a-0d06-868060ac3d9d"; float close_volume= 1.0; //How long before the door auto close. float close_delay = 60.0; //------------------no need to change anything beyond this point-------------------// integer is_open; //The rotation values for the open and closed state, these are LOCAL to the link set. rotation closed = <0.00000, 0.00000, 0.00000, 1.00000>; rotation open = <0.70711, 0.00000, 0.00000, 0.70711>; //Resize the door set_door() { list data = llGetPrimitiveParams([PRIM_SIZE,PRIM_TYPE]); vector scale = llList2Vector(data,0); integer type = llList2Integer(data,1); float hollow = llList2Float(data,4); if(type != PRIM_TYPE_BOX) return; float height = scale.x; float width = scale.y; float thickness = scale.z; //this is to avoid a divide by zero that would crash the script. if(hollow > 0.0) { //THat's the math used to calculate the new door's size. vector door_size = ; vector door_pos = <0,-(width*hollow/2) ,0>; llSetLinkPrimitiveParams(2,[PRIM_SIZE,door_size,PRIM_POSITION,door_pos]); } } //Open and close the door toggle() { if(!is_open) { //we start a timer for closing the door. llSetTimerEvent(close_delay); llSetLinkPrimitiveParams(2,[PRIM_ROTATION,open/llGetRootRotation()]); if(open_sound != "") llTriggerSound(open_sound,open_volume); } else { //door is now closed, we kill the timer. llSetTimerEvent(0.0); llSetLinkPrimitiveParams(2,[PRIM_ROTATION,closed/llGetRootRotation()]); if(close_sound != "") llTriggerSound(close_sound,close_volume); } is_open = ! is_open; } default { touch_start(integer a) { toggle(); } changed(integer change) { set_door(); } timer() { if(is_open) toggle(); } }