prim position child script.lsl 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // :CATEGORY:Blue Whale
  2. // :NAME:BlueWhale
  3. // :AUTHOR:Ferd Frederix
  4. // :CREATED:2013-09-06
  5. // :EDITED:2013-09-18 15:38:49
  6. // :ID:107
  7. // :NUM:143
  8. // :REV:1
  9. // :WORLD:Second Life
  10. // :DESCRIPTION:
  11. // prim position child script
  12. // :CODE:
  13. // Open source, GPL license.
  14. // Do not remove the header, do not sell this script.
  15. // ______ _ ______ _ _
  16. // | ___| | | | ___| | | (_)
  17. // | |_ ___ _ __ __| | | |_ _ __ ___ __| | ___ _ __ ___ __
  18. // | _/ _ \ '__/ _` | | _| '__/ _ \/ _` |/ _ \ '__| \ \/ /
  19. // | || __/ | | (_| | | | | | | __/ (_| | __/ | | |> <
  20. // \_| \___|_| \__,_| \_| |_| \___|\__,_|\___|_| |_/_/\_\
  21. //
  22. // author Ferd Frederix
  23. // Prim positioner child script.
  24. // Put a copy of this script in any prim you wish to move
  25. integer debug = 0;
  26. integer linkchannel = 5001; // for recording purposes
  27. vector vLastpos;
  28. rotation rLastrot;
  29. default
  30. {
  31. on_rez(integer p)
  32. {
  33. llResetScript();
  34. }
  35. // accept messages from the main script
  36. link_message(integer sender_num, integer num, string msg, key id)
  37. {
  38. if (msg == "Set") // SEt records the current prim rot and pos.
  39. {
  40. llSleep(llFrand(3.0));
  41. vector vPos = llGetLocalPos();
  42. rotation rRot = llGetLocalRot();
  43. if (vPos != vLastpos || rRot != rLastrot)
  44. llMessageLinked(LINK_ROOT, linkchannel, (string) vPos + "|" + (string) rRot, "");
  45. vLastpos = vPos;
  46. rLastrot = rRot;
  47. }
  48. else if (msg == "Remove") // deletes the script from the child to help with lag
  49. {
  50. if (debug)
  51. llSetScriptState(llGetScriptName(),FALSE);
  52. else
  53. llRemoveInventory(llGetScriptName());
  54. }
  55. else if (msg == "Reset") // set the coords to some rare value so the prim will have been seen to have moved
  56. {
  57. vLastpos = <0,0,0>;
  58. rLastrot = <0,0,0,1>;
  59. }
  60. else if (msg == "All") // dump the current pos and rot to the server
  61. {
  62. vector vPos = llGetLocalPos();
  63. rotation rRot = llGetLocalRot();
  64. llSleep(llFrand(3.0));
  65. llMessageLinked(LINK_ROOT, linkchannel, (string) vPos + "|" + (string) rRot, "");
  66. }
  67. }
  68. }