switch_control.lsl 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. // :SHOW:1
  2. // :CATEGORY:Light
  3. // :NAME:Rene Free Lighting System
  4. // :AUTHOR:Rene10957 Resident
  5. // :KEYWORDS: light,lamp,lighting light
  6. // :CREATED:2015-06-11 14:41:39
  7. // :EDITED:2016-03-30 20:29:28
  8. // :ID:1079
  9. // :NUM:1780
  10. // :REV:1
  11. // :WORLD:Second Life
  12. // :DESCRIPTION:
  13. // Drop in any prim and touch for on/off
  14. // :CODE:
  15. // Each prim in a link set that has a Description of #LS# will become a light. This is the switch
  16. //:LICENSE: CC0 (Public Domain)
  17. // Rene's Free Lighting System - Switch Control
  18. //
  19. // Drop in any prim and touch for on/off
  20. // No switch or light scripts are needed
  21. // License: CC0 (Public Domain).
  22. // To the extent possible under law, Rene10957 has waived all copyright and related or neighboring rights.
  23. // For more information, see http://creativecommons.org/publicdomain/zero/1.0/.
  24. //////////////////////////////////////////
  25. // Please read user manual before using //
  26. //////////////////////////////////////////
  27. string title = "Switch Control"; // title
  28. string version = "1.0"; // version
  29. integer silent = TRUE; // silent startup
  30. // Variables
  31. integer on = FALSE; // on-off switch
  32. // Functions
  33. switchLight()
  34. {
  35. string desc;
  36. list descList;
  37. list configList;
  38. vector color;
  39. vector primColor;
  40. float intensity;
  41. float radius;
  42. float falloff;
  43. float alpha;
  44. float glow;
  45. integer fullbright;
  46. integer i;
  47. integer number = llGetNumberOfPrims();
  48. for (i = number; i >= 0; --i) {
  49. descList = llGetLinkPrimitiveParams(i, [PRIM_DESC]);
  50. desc = llList2String(descList, 0);
  51. if (llGetSubString(desc, 0, 3) == "#LS#") {
  52. configList = llParseStringKeepNulls(desc, [";"], []);
  53. if (on) {
  54. color.x = (float)llList2String(configList, 1);
  55. color.y = (float)llList2String(configList, 2);
  56. color.z = (float)llList2String(configList, 3);
  57. intensity = (float)llList2String(configList, 4);
  58. radius = (float)llList2String(configList, 5);
  59. falloff = (float)llList2String(configList, 6);
  60. alpha = (float)llList2String(configList, 7);
  61. glow = (float)llList2String(configList, 8);
  62. fullbright = (integer)llList2String(configList, 9);
  63. primColor.x = (float)llList2String(configList, 10);
  64. primColor.y = (float)llList2String(configList, 11);
  65. primColor.z = (float)llList2String(configList, 12);
  66. }
  67. else {
  68. color.x = (float)llList2String(configList, 13);
  69. color.y = (float)llList2String(configList, 14);
  70. color.z = (float)llList2String(configList, 15);
  71. alpha = (float)llList2String(configList, 16);
  72. glow = 0.0;
  73. fullbright = FALSE;
  74. primColor = color;
  75. }
  76. llSetLinkPrimitiveParamsFast(i, [
  77. PRIM_POINT_LIGHT, on, color, intensity, radius, falloff,
  78. PRIM_COLOR, ALL_SIDES, primColor, alpha,
  79. PRIM_GLOW, ALL_SIDES, glow,
  80. PRIM_FULLBRIGHT, ALL_SIDES, fullbright]);
  81. }
  82. }
  83. }
  84. default
  85. {
  86. state_entry()
  87. {
  88. switchLight();
  89. if (!silent) llWhisper(0, title + " " + version + " ready");
  90. }
  91. on_rez(integer start_param)
  92. {
  93. llResetScript();
  94. }
  95. touch_start(integer total_number)
  96. {
  97. on = !on;
  98. switchLight();
  99. }
  100. }