new.lsl 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. integer debug = 0;
  2. integer channel = -44443; // listener from other prim
  3. integer listener; // channel handle
  4. string myName; // Name of this prim
  5. vector OFFSET = <0,0,0>; // offset to the other door
  6. rotation ROT = <0,0,0,1>; // rotation when we get there
  7. vector MYOFFSET = <0,0,0>; // offset to the other door
  8. rotation MYROT = <0,0,0,1>; // rotation when we get there
  9. key AvatarKey; // key of who touched the door
  10. //Sets / Updates the sit target moving the avatar on it if necessary.
  11. UpdateSitTarget(vector pos, rotation rot)
  12. {
  13. //Using this while the object is moving may give unpredictable results.
  14. llSitTarget(pos, rot);//Set the sit target
  15. key user = llAvatarOnSitTarget();
  16. if(user)//true if there is a user seated on the sittarget, if so update their position
  17. {
  18. vector size = llGetAgentSize(user);
  19. if(size)//This tests to make sure the user really exists.
  20. {
  21. //We need to make the position and rotation local to the current prim
  22. rotation localrot = ZERO_ROTATION;
  23. vector localpos = ZERO_VECTOR;
  24. if(llGetLinkNumber() > 1)//only need the local rot if it's not the root.
  25. {
  26. localrot = llGetLocalRot();
  27. localpos = llGetLocalPos();
  28. }
  29. pos.z += 0.4;
  30. integer linkNum = llGetNumberOfPrims();
  31. do{
  32. if(user == llGetLinkKey( linkNum ))//just checking to make sure the index is valid.
  33. {
  34. llSetLinkPrimitiveParams(linkNum,
  35. [PRIM_POSITION, ((pos - (llRot2Up(rot) * size.z * 0.02638)) * localrot) + localpos,
  36. PRIM_ROTATION, rot * localrot / llGetRootRotation()]);
  37. jump end;//cheaper but a tad slower then return
  38. }
  39. }while( --linkNum );
  40. }
  41. else
  42. {//It is rare that the sit target will bork but it does happen, this can help to fix it.
  43. llUnSit(user);
  44. }
  45. }
  46. @end;
  47. } //Written by Strife Onizuka, size adjustment provided by Escort DeFarge
  48. default
  49. {
  50. state_entry()
  51. {
  52. myName = llGetObjectName();
  53. listener = llListen(channel,myName,NULL_KEY,"");
  54. llRegionSay(channel,"reset");
  55. llSitTarget( MYOFFSET, MYROT);
  56. }
  57. touch_start(integer total_number)
  58. {
  59. AvatarKey = llDetectedKey(0);
  60. llRequestPermissions(AvatarKey,PERMISSION_TRIGGER_ANIMATION );
  61. }
  62. listen(integer channel,string name, key id, string message)
  63. {
  64. list params = llParseString2List(message,["|"],[""]);
  65. if (debug) llDumpList2String(params,":");
  66. OFFSET = (vector) llList2String(params,0);
  67. ROT = (rotation) llList2String(params,1);
  68. llListenRemove (listener);
  69. }
  70. run_time_permissions(integer perm)
  71. {
  72. if(PERMISSION_TRIGGER_ANIMATION & perm)
  73. {
  74. if (OFFSET == <0,0,0>)
  75. return;
  76. llStartAnimation("nyanya");
  77. llSleep(5);
  78. UpdateSitTarget(OFFSET,ROT);
  79. }
  80. }
  81. }