Advertisement
bob82604

Light Script

Feb 26th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. float intensity = 0.3;
  2. float radius = 3.0;
  3. float falloff = 1.0;
  4.  
  5. integer off = 0;
  6. integer lightState;
  7.  
  8. float rot;
  9.  
  10. list frames = [];
  11. integer light;
  12.  
  13.  
  14. list menuChoices =["Nickel","Brushed","Oiled"];
  15. integer channel_dialog;
  16. key ToucherID;
  17. string message = "\nPlease select a texture";
  18. integer listen_id;
  19.  
  20. getPrimNumbers()
  21. {
  22. integer i;
  23.  
  24. for (i=1;i<=llGetNumberOfPrims();i++)
  25. {
  26. if (llGetLinkName(i)=="frame")
  27. {
  28. frames += [i];
  29. }
  30. else if (llGetLinkName(i)=="light")
  31. {
  32. light = i;
  33. }
  34. }
  35. }
  36.  
  37.  
  38. setFrameColor(vector color)
  39. {
  40. llSay(0,"Setting frame to color : " + (string)color);
  41.  
  42. llSetLinkPrimitiveParamsFast(2,[PRIM_COLOR,ALL_SIDES,color,1]);
  43. llSetLinkPrimitiveParamsFast(3,[PRIM_COLOR,ALL_SIDES,color,1]);
  44. llSetLinkPrimitiveParamsFast(4,[PRIM_COLOR,ALL_SIDES,color,1]);
  45. llSetLinkPrimitiveParamsFast(5,[PRIM_COLOR,ALL_SIDES,color,1]);
  46. }
  47.  
  48. default
  49. {
  50. state_entry()
  51. {
  52. llSay(0,"\n\nTesting Script\n");
  53.  
  54. getPrimNumbers();
  55.  
  56. llSetLinkPrimitiveParamsFast(1,[PRIM_TEXTURE, ALL_SIDES, "LightSwitch", <1.0,1.0,0.0>, <0.0,0.0,0.0>, 0.0]);
  57. llSetLinkPrimitiveParamsFast(light,
  58. [PRIM_FULLBRIGHT,ALL_SIDES,lightState,
  59. PRIM_POINT_LIGHT,lightState,<1,1,1>,intensity,radius,falloff]);
  60. setFrameColor(<40,33,29>);
  61. }
  62.  
  63. touch_start(integer num_detected)
  64. {
  65.  
  66. integer i;
  67. integer l;
  68. integer primCount = llGetObjectPrimCount(llGetKey());
  69.  
  70. if (llDetectedLinkNumber(0) == 1)
  71. {
  72. lightState = !lightState;
  73.  
  74. rot = (lightState*180)*DEG_TO_RAD;
  75.  
  76. llSetLinkPrimitiveParamsFast(1,[PRIM_TEXTURE,ALL_SIDES,"LightSwitch",<1.0,1.0,0>,<0,0,0>,rot]);
  77. llSetLinkPrimitiveParamsFast(light, [PRIM_FULLBRIGHT,ALL_SIDES,lightState,
  78. PRIM_POINT_LIGHT,lightState,<1,1,1>,intensity,radius,falloff]);
  79. for (i=0;i<llGetListLength(frames);i++)
  80. {
  81. l=llList2Integer(frames,i);
  82. llSetLinkPrimitiveParamsFast(l,[PRIM_FULLBRIGHT,ALL_SIDES,lightState]);
  83. }
  84. }
  85. else
  86. {
  87. channel_dialog = -1 - (integer)("0x" + llGetSubString( (string)llGetKey(), -7, -1) );
  88. ToucherID = llDetectedKey(0);
  89. llDialog(ToucherID, message, menuChoices, channel_dialog);
  90. listen_id = llListen(channel_dialog,"",ToucherID,"");
  91. }
  92. }
  93.  
  94. listen(integer channel, string name, key id, string message)
  95. {
  96. vector frameColor;
  97.  
  98. if (message == "Nickel")
  99. {
  100. frameColor = <171,170,167>;
  101. }
  102. else if (message == "Brushed")
  103. {
  104. frameColor = <211,170,109>;
  105. }
  106. else if (message == "Oiled")
  107. {
  108. frameColor = <40,33,29>;
  109. }
  110. setFrameColor(frameColor);
  111. }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement