Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- vector OFFSET = <-0.0, 0.0, 4.0>; // Directional offset for moving the door in x,y,z coordinates
- float OPENTIME = 3.5; // Time taken to open door
- float CLOSETIME = 3.5; // Time taken to close door
- // ********************************************************************
- // Variables
- // ********************************************************************
- vector vPosition;
- rotation rRot;
- float omega=0.0;
- vector vTargetPos;
- integer bOpen = FALSE;
- integer bMoving = FALSE;
- // ********************************************************************
- // Functions
- // ********************************************************************
- MoveDoor()
- {
- if(!bOpen)
- { // Initial conditions
- bOpen = TRUE;
- rRot = llGetRot();
- vPosition = llGetPos();
- // Target Position
- omega=OPENTIME/llVecDist(<0,0,0>,OFFSET);
- vTargetPos = vPosition+OFFSET*rRot;
- // Set the timer to cleanup position
- llSetTimerEvent(OPENTIME);
- }else
- {
- bOpen = FALSE;
- // Target Position
- omega=CLOSETIME/llVecDist(<0,0,0>,OFFSET);
- vTargetPos = vPosition;
- // Set the timer to cleanup position
- llSetTimerEvent(CLOSETIME);
- }
- // Set Door Physical and move it
- bMoving = TRUE;
- llSetStatus(STATUS_PHANTOM, TRUE);
- llSetStatus(STATUS_PHYSICS, TRUE);
- llMoveToTarget(vTargetPos,omega);
- }
- default
- {
- state_entry()
- { // Initial conditions
- rRot = llGetRot();
- vPosition = llGetPos();
- }
- touch_start(integer num_detected)
- {
- MoveDoor();
- }
- timer()
- {
- // Clean up Position
- bMoving = FALSE;
- llSetTimerEvent(0.0);
- llSetStatus(STATUS_PHYSICS, FALSE);
- llSetStatus(STATUS_PHANTOM, FALSE);
- llSetPrimitiveParams([ PRIM_POSITION, vTargetPos, PRIM_ROTATION, rRot ]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement