Advertisement
Guest User

Untitled

a guest
Jul 16th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //    Builder's Brewery
  2. //    Smooth sliding door
  3. //    One-way sliding, linkable door
  4.  
  5.  
  6. vector MoveOnLocalGrid;
  7. float TimeItTakesForDoorToOpen;
  8.  
  9. integer Direction;
  10.  
  11. init()
  12. {
  13.     MoveOnLocalGrid = <1.0,0.0,0.0>;
  14.     TimeItTakesForDoorToOpen = 2.0;
  15.  
  16.     Direction = 1;//do not change, toggles between +1 and -1
  17. }
  18.  
  19. operateDoor()
  20. {
  21.     vector PositionBeforeMovement = llGetLocalPos();
  22.     vector VectorForDoorMovement = Direction*MoveOnLocalGrid*llGetLocalRot();
  23.  
  24.     float i;
  25.     llResetTime();
  26.  
  27.     do
  28.     {
  29.         i = llGetTime()/TimeItTakesForDoorToOpen;
  30.         llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_POSITION,PositionBeforeMovement + i*VectorForDoorMovement]);
  31.     }
  32.     while (llGetTime() < TimeItTakesForDoorToOpen && i <= 1.0);
  33.  
  34.     llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_POSITION,PositionBeforeMovement + VectorForDoorMovement]);
  35.     Direction *= -1;
  36. }
  37.  
  38. default
  39. {
  40.     on_rez(integer start_param)
  41.     {
  42.         llResetScript();
  43.     }
  44.  
  45.     state_entry()
  46.     {
  47.         init();
  48.     }
  49.  
  50.     touch_start (integer num_detected)
  51.     {
  52.         operateDoor();
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement