Controller.lsl 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // :CATEGORY:Transmogrify
  2. // :NAME:TransmogrifyAvatar
  3. // :AUTHOR:Ferd Frederix
  4. // :KEYWORDS:
  5. // :CREATED:2013-09-08
  6. // :EDITED:2014-09-24
  7. // :ID:921
  8. // :NUM:1323
  9. // :REV:1.1
  10. // :WORLD:Second Life
  11. // :DESCRIPTION:
  12. // FOr the head of the avatar
  13. // :CODE:
  14. // Transmogrifyer script
  15. // License: CC-BY. Please do not remove the copyright or this notice
  16. // Author: Ferd Frederix
  17. // 8-25-2013
  18. // Controller goes in the root prim of the body.
  19. // V 1.1 Edited on 9/22/2014 to fix "in air" bug to be "Flying"
  20. integer type = -1;
  21. integer ownerchannel;
  22. integer person = TRUE;
  23. hide_show( float alpha)
  24. {
  25. integer j = llGetNumberOfPrims();
  26. integer k = 2; // do it twice to get rid of lost packets
  27. while (k--)
  28. {
  29. integer i;
  30. for ( i = 0; i <= j; i++) {
  31. llSetLinkAlpha(i,alpha, ALL_SIDES);
  32. }
  33. }
  34. }
  35. // flop and send a link message for particle effects
  36. switch(string what)
  37. {
  38. if (what == "avatar" && ! person)
  39. {
  40. llMessageLinked(LINK_SET,0,"switch","");
  41. llSay(ownerchannel,"avatar");
  42. person = TRUE;
  43. hide_show(1.0); // invisible
  44. }
  45. else if (what == "pet" && person)
  46. {
  47. llMessageLinked(LINK_SET,0,"switch","");
  48. llSay(ownerchannel,"pet");
  49. person = FALSE;
  50. hide_show(0.0);
  51. }
  52. }
  53. default
  54. {
  55. on_rez(integer p)
  56. {
  57. llResetScript(); // so we can change owner
  58. }
  59. state_entry()
  60. {
  61. // Make this prim an invisiprim.
  62. ownerchannel = (integer)("0xF" + llGetSubString( (string)llGetOwner(), 0, 6 ));
  63. hide_show(1.0);
  64. llSetTimerEvent(0.5);
  65. }
  66. timer()
  67. {
  68. integer flight = llGetAgentInfo(llGetOwner());
  69. if (flight & AGENT_FLYING) // V 1.1
  70. {
  71. switch("pet");
  72. }
  73. else
  74. {
  75. switch("avatar");
  76. }
  77. }
  78. }