Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Light Rene Free Lighting System  

Rene Free Lighting System

Drop in any prim and touch for on/off

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

the Zip file

Download all files for Rene Free Lighting System
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. history.txt
Get file # 2. license.txt
Get file # 3. readme.txt
Get file # 4. config_control.lsl
Get file # 5. ext_config_control.lsl
Get file # 6. ext_switch_control.lsl
Get file # 7. light_control.lsl
Get file # 8. link_control.lsl
Get file # 9. link_receiver.lsl
Get file # 10. network_control.lsl
Get file # 11. network_control_region.lsl
Get file # 12. network_receiver.lsl
Get file # 13. network_receiver_region.lsl
Get file # 14. remote_control.lsl
Get file # 15. remote_receiver.lsl
Get file # 16. switch_control.lsl
Get file # 17. particle_bling.lsl
Get file # 18. particle_candle_dirty_wick.lsl
Get file # 19. particle_candle_sensual.lsl
Get file # 20. particle_candle_simple.lsl
Get file # 21. particle_fire.lsl
Get file # 22. particle_halo.lsl
Get file # 23. particle_starbling.lsl
Get file # 24. particle_starburst.lsl
Get file # 25. nightlight.lsl
Get file # 26. proximity.lsl
Get file # 27. [39152 bytes] glow_large.png
Get file # 28. [29581 bytes] glow_medium.png
Get file # 29. [18955 bytes] glow_small.png
Get file # 30. [63245 bytes] pixie_large.png
Get file # 31. [41129 bytes] pixie_medium.png
Get file # 32. [22652 bytes] pixie_small.png
Get file # 33. [78280 bytes] star.png
Get file # 34. color_converter.lsl
Get file # 35. face_picker.lsl
Get file # 36. remove_floating_text.lsl
Get file # 37. Config_default.txt
Get file # 38. light.lsl
Get file # 39. light_region.lsl
Get file # 40. switch.lsl
Get file # 41. switch_region.lsl
1 // :LICENSE: CC0 (Public Domain)
2
3 // Rene's Free Lighting System - Extended Switch Control
4 //
5 // Author: Rene10957 Resident
6 // Date: 21-03-2014
7 //
8 // Drop in any prim and touch for on/off
9 // License: CC0 (Public Domain).
10 // To the extent possible under law, Rene10957 has waived all copyright and related or neighboring rights.
11 // For more information, see http://creativecommons.org/publicdomain/zero/1.0/.
12
13
14 //////////////////////////////////////////
15 // Please read user manual before using //
16 //////////////////////////////////////////
17
18 string title = "Extended Switch Control"; // title
19 string version = "1.0"; // version
20 integer silent = TRUE; // silent startup
21
22 // Constants
23
24 integer switchChannel = -10957; // switch channel
25
26 // Variables
27
28 integer on = FALSE; // on-off switch
29
30 // Functions
31
32 switchLight()
33 {
34 vector color;
35 vector primColor;
36 vector particleColor;
37 float intensity;
38 float radius;
39 float falloff;
40 float alpha;
41 float glow;
42 integer fullbright;
43 integer particleSize;
44 string particleTexture;
45 string desc = llGetObjectDesc();
46
47 if(llGetSubString(desc, 0, 3) == "#LS#") {
48 list configList = llParseStringKeepNulls(desc, [";"], []);
49 if(on) {
50 color.x = (float)llList2String(configList, 1);
51 color.y = (float)llList2String(configList, 2);
52 color.z = (float)llList2String(configList, 3);
53 intensity = (float)llList2String(configList, 4);
54 radius = (float)llList2String(configList, 5);
55 falloff = (float)llList2String(configList, 6);
56 alpha = (float)llList2String(configList, 7);
57 glow = (float)llList2String(configList, 8);
58 fullbright = (integer)llList2String(configList, 9);
59 primColor.x = (float)llList2String(configList, 10);
60 primColor.y = (float)llList2String(configList, 11);
61 primColor.z = (float)llList2String(configList, 12);
62 particleColor.x = (float)llList2String(configList, 13);
63 particleColor.y = (float)llList2String(configList, 14);
64 particleColor.z = (float)llList2String(configList, 15);
65 particleSize = (integer)llList2String(configList, 16);
66 particleTexture = llList2String(configList, 17);
67 }
68 else {
69 color.x = (float)llList2String(configList, 18);
70 color.y = (float)llList2String(configList, 19);
71 color.z = (float)llList2String(configList, 20);
72 alpha = (float)llList2String(configList, 21);
73 glow = 0.0;
74 fullbright = FALSE;
75 primColor = color;
76 }
77
78 list sendList = ["Default", on, color, intensity, radius, falloff, alpha, glow, fullbright,
79 primColor, particleColor, particleSize, 999, particleTexture, on];
80 string sendMsg = llList2CSV(sendList);
81 llMessageLinked(LINK_ALL_OTHERS, switchChannel, sendMsg, "");
82 }
83 }
84
85 default
86 {
88 {
89 switchLight();
90 if(!silent) llWhisper(0, title + " " + version + " ready");
91 }
92
93 on_rez(integer start_param)
94 {
96 }
97
98 touch_start(integer total_number)
99 {
100 on = !on;
101 switchLight();
102 }
103 }

Rene Free Lighting System

Light Control (light without bulbs)

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

1 // :LICENSE: CC0 (Public Domain)
2
3 // Rene's Free Lighting System - Light Control (light without bulbs)
4 //
5 // Author: Rene10957 Resident
6 // Date: 21-03-2014
7 //
8 // Use together with switch and drop in the same prim
9 // No other scripts are needed
10 // License: CC0 (Public Domain).
11 // To the extent possible under law, Rene10957 has waived all copyright and related or neighboring rights.
12 // For more information, see http://creativecommons.org/publicdomain/zero/1.0/.
13
14
15 //////////////////////////////////////////
16 // Please read user manual before using //
17 //////////////////////////////////////////
18
19 string title = "Light Control"; // title
20 string version = "1.1"; // version
21 integer silent = TRUE; // silent startup
22
23 // Constants
24
25 integer switchChannel = -10957; // switch channel
26
27 // Functions
28
29 string getGroup(integer link)
30 {
31 list desc = llGetLinkPrimitiveParams(link, [PRIM_DESC]);
33 if(str == "(no description)" || str == "") str = "default";
34 return str;
35 }
36
37 unpackMessage(string msg)
38 {
39 list msgList = llCSV2List(msg);
40 string group = llToLower(llList2String(msgList, 0));
41 integer on = (integer)llList2String(msgList, 1);
42 vector color = (vector)llList2String(msgList, 2);
43 float intensity = (float)llList2String(msgList, 3);
44 float radius = (float)llList2String(msgList, 4);
45 float falloff = (float)llList2String(msgList, 5);
46 float alpha = (float)llList2String(msgList, 6);
47 float glow = (float)llList2String(msgList, 7);
48 integer fullbright = (integer)llList2String(msgList, 8);
49 vector primColor = (vector)llList2String(msgList, 9);
50
51 integer i;
52 integer number = llGetNumberOfPrims();
53 integer link = llGetLinkNumber();
54
55 for (i = number; i >= 0; --i) {
56 if(group == getGroup(i)) {
57 if(i != link || i < 2) {
58 llSetLinkPrimitiveParamsFast(i, [
59 PRIM_POINT_LIGHT, on, color, intensity, radius, falloff,
60 PRIM_COLOR, ALL_SIDES, primColor, alpha,
61 PRIM_GLOW, ALL_SIDES, glow,
62 PRIM_FULLBRIGHT, ALL_SIDES, fullbright]);
63 }
64 }
65 }
66 }
67
68 default
69 {
71 {
72 if(!silent) llWhisper(0, title + " " + version + " ready");
73 }
74
75 on_rez(integer start_param)
76 {
78 }
79
80 link_message(integer sender_number, integer number, string msg, key id)
81 {
82 if(number == switchChannel) unpackMessage(msg);
83 }
84 }

Rene Free Lighting System

Link control (secondary switch)

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

1 // :LICENSE: CC0 (Public Domain)
2
3 // Link control (secondary switch) for Rene's Free Lighting System
4 //
5 // Author: Rene10957 Resident
6 // Date: 24-01-2014
7 //
8 // Drop this in any prim (within the same linkset) you want to use as an extra on/off/menu switch
9 // Note: only useful if you need multiple switches for the same light group in LINKSET mode
10 // License: CC0 (Public Domain).
11 // To the extent possible under law, Rene10957 has waived all copyright and related or neighboring rights.
12 // For more information, see http://creativecommons.org/publicdomain/zero/1.0/.
13
14
15 string title = "Link Control"; // title
16 string version = "1.2"; // version
17 integer silent = TRUE; // silent startup
18
19 // Constants
20
21 integer msgNumber = -975104; // number part of link message
22 string separator = ";;"; // separator for link messages
23
24 // Functions
25
26 string getGroup()
27 {
29 if(llToLower(str) == "(no description)" || str == "") str = "Default";
30 return str;
31 }
32
33 default
34 {
36 {
37 if(!silent) llWhisper(0, title + " " + version + " ready");
38 }
39
40 on_rez(integer start_param)
41 {
43 }
44
45 touch_start(integer total_number)
46 {
48 }
49
50 touch_end(integer total_number)
51 {
52 key user = llDetectedKey(0);
53 string command;
54
55 if(llGetTime() > 1.0) command = "menu";
56 else command = "switch";
57
58 list msgList = [getGroup(), command, user];
59 string msgData = llDumpList2String(msgList, separator);
60 llMessageLinked(LINK_ALL_OTHERS, msgNumber, msgData, "");
61 }
62 }

Rene Free Lighting System

Link receiver for Rene's Free Lighting System

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

1 // :LICENSE: CC0 (Public Domain)
2
3
4 //
5 // Author: Rene10957 Resident
6 // Date: 24-01-2014
7 //
8 // Drop this into the same prim where the SWITCH is located
9 // Note: only useful if you are also using the link control script
10 // License: CC0 (Public Domain).
11 // To the extent possible under law, Rene10957 has waived all copyright and related or neighboring rights.
12 // For more information, see http://creativecommons.org/publicdomain/zero/1.0/.
13
14
15 string title = "Link Receiver"; // title
16 string version = "1.2"; // version
17 integer silent = TRUE; // silent startup
18
19 // Constants
20
21 integer msgIn = -975104; // number part of incoming link message
22 integer msgOut = 10957; // number part of outgoing link message
23 string separator = ";;"; // separator for link messages
24
25 // Functions
26
27 string getGroup()
28 {
30 if(llToLower(str) == "(no description)" || str == "") str = "Default";
31 return str;
32 }
33
34 default
35 {
37 {
38 if(!silent) llWhisper(0, title + " " + version + " ready");
39 }
40
41 on_rez(integer start_param)
42 {
44 }
45
46 link_message(integer sender_number, integer number, string msg, key id)
47 {
48 if(number != msgIn) return;
49
50 list msgList = llParseString2List(msg, [separator], []);
51 string group = llList2String(msgList, 0);
52 string command = llList2String(msgList, 1);
53 key user = (key)llList2String(msgList, 2);
54
55 if(llToLower(group) == llToLower(getGroup())) llMessageLinked(LINK_THIS, msgOut, command, user);
56 }
57 }

Rene Free Lighting System

Drop this in any prim you want to use as a control panel

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

1 // :LICENSE: CC0 (Public Domain)
2 // Network control for Rene's Free Lighting System
3 //
4 // Author: Rene10957 Resident
5 // Date: 05-10-2014
6 //
7 // Drop this in any prim you want to use as a control panel
8 // License: CC0 (Public Domain).
9 // To the extent possible under law, Rene10957 has waived all copyright and related or neighboring rights.
10 // For more information, see http://creativecommons.org/publicdomain/zero/1.0/.
11
12
13 string title = "Network Control"; // title
14 string version = "2.3.2"; // version
15 integer linkSet = TRUE; // LINKSET mode
16 integer silent = TRUE; // silent startup
17
18 // Constants
19
20 float cDialogTime = 120.0; // dialog timeout = 2 minutes
21 float cReplyTime = 1.0; // reply timeout = 1 second
22 integer remoteChannel = -975103; // remote channel (send)
23 integer replyChannel = -975105; // reply channel (receive)
24 string separator = ";;"; // separator for link or region messages
25
26 // Variables
27
28 float time; // timer interval for multiple timers
29 float vReplyTime; // variable timeout for node discovery, ranging from 1 to 2 sec.
30 integer dialogChannel; // dialog channel
31 integer dialogHandle; // handle for dialog listener
32 integer replyHandle; // handle for reply listener
33 key owner; // object owner
34 key user; // key of last avatar to touch object
35 list networkNodes; // strided list of network nodes (object key, object name)
36 list menuButtons; // menu buttons (object names)
37
38 // Functions
39
40 list orderButtons(list buttons)
41 {
42 return llList2List(buttons, -3, -1) + llList2List(buttons, -6, -4) + llList2List(buttons, -9, -7);
43 }
44
45 float setTimer(float sec)
46 {
47 llSetTimerEvent(0.0);
48 llSetTimerEvent(sec);
49 return sec;
50 }
51
52 discoverNodes(key id)
53 {
54 llWhisper(0, "Discovering network nodes...");
55 networkNodes = [];
56 llListenRemove(replyHandle);
57 replyHandle = llListen(replyChannel, "", "", "");
58 float pctlag = 100.0 * (1.0 - llGetRegionTimeDilation()); // try to work around time dilation
59 vReplyTime = cReplyTime + cReplyTime / 100.0 * pctlag; // (more lag = longer timeout)
60 time = setTimer(vReplyTime);
61 if(linkSet) llMessageLinked(LINK_ALL_OTHERS, remoteChannel, "PING", llGetKey());
62 else llRegionSay(remoteChannel, "PING");
63 }
64
65 menuDialog (key id)
66 {
67 dialogChannel = (integer)(llFrand(-1000000000.0) - 1000000000.0);
68 llListenRemove(dialogHandle);
69 dialogHandle = llListen(dialogChannel, "", "", "");
70 time = setTimer(cDialogTime);
71 llDialog(id, title + " " + version, menuButtons, dialogChannel);
72 }
73
74 default
75 {
77 {
78 owner = llGetOwner();
79 if(linkSet) version += "-LINKSET";
80 else version += "-REGION";
81 if(!silent) llWhisper(0, title + " " + version + " ready");
82 }
83
84 on_rez(integer start_param)
85 {
87 }
88
89 touch_start(integer total_number)
90 {
91 user = llDetectedKey(0);
92 if(llGetListLength(networkNodes) == 0) discoverNodes(user);
93 else menuDialog(user);
94 }
95
96 listen(integer channel, string name, key id, string msg)
97 {
98 integer length = llGetListLength(networkNodes) / 2;
99
100 if(channel == replyChannel) {
101 if(llGetOwnerKey(id) != owner) return;
102 if(length > 8) return;
103 string shortName = llGetSubString(msg, 0, 23);
104 networkNodes += [id, shortName];
105 }
106 else if(channel == dialogChannel) {
108 llListenRemove(dialogHandle);
109 integer i;
110 integer index;
111 key target;
112 list msgList;
113 string msgData;
114 if(msg == "On") {
115 for (i = 0; i < length; ++i) {
116 target = llList2Key(networkNodes, i * 2);
117 msgList = [target, "on", id]; // id = user who opened the dialog
118 msgData = llDumpList2String(msgList, separator);
119 if(linkSet) llMessageLinked(LINK_ALL_OTHERS, remoteChannel, msgData, "");
120 else llRegionSayTo(target, remoteChannel, msgData);
121 }
122 menuDialog(id);
123 }
124 else if(msg == "Off") {
125 for (i = 0; i < length; ++i) {
126 target = llList2Key(networkNodes, i * 2);
127 msgList = [target, "off", id]; // id = user who opened the dialog
128 msgData = llDumpList2String(msgList, separator);
129 if(linkSet) llMessageLinked(LINK_ALL_OTHERS, remoteChannel, msgData, "");
130 else llRegionSayTo(target, remoteChannel, msgData);
131 }
132 menuDialog(id);
133 }
134 else if(msg == "Discover") {
135 discoverNodes(id);
136 }
137 else {
138 index = llListFindList(networkNodes, [msg]);
139 if(index > -1) {
140 target = llList2Key(networkNodes, index - 1);
141 msgList = [target, "menu", id]; // id = user who opened the dialog
142 msgData = llDumpList2String(msgList, separator);
143 if(linkSet) llMessageLinked(LINK_ALL_OTHERS, remoteChannel, msgData, "");
144 else llRegionSayTo(target, remoteChannel, msgData);
145 }
146 else {
147 llInstantMessage(id, "Unexpected error during object key lookup");
148 menuDialog(id);
149 }
150 }
151 }
152 }
153
154 timer()
155 {
157 if(time == cDialogTime) { // dialog timeout
158 llListenRemove(dialogHandle);
159 }
160 else if(time == vReplyTime) { // remote timeout (variable!)
161 integer length = llGetListLength(networkNodes) / 2;
162 if(length == 1) llWhisper(0, "Node discovery completed (" + (string)length + " node)");
163 else llWhisper(0, "Node discovery completed (" + (string)length + " nodes)");
164 llListenRemove(replyHandle);
165 if(length > 0) {
166 menuButtons = llList2ListStrided(networkNodes, 1, -1, 2);
167 menuButtons = llListSort(menuButtons, 1, TRUE); // sort ascending
168 menuButtons = orderButtons(menuButtons); // reverse row order
169 menuButtons = ["On", "Off", "Discover"] + menuButtons;
170 if(user) menuDialog(user);
171 }
172 }
173 }
174 }

Rene Free Lighting System

Drop this in any prim you want to use as a control panel

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

1 // :LICENSE: CC0 (Public Domain)
2 // Network control for Rene's Free Lighting System
3 //
4 // Author: Rene10957 Resident
5 // Date: 05-10-2014
6 //
7 // Drop this in any prim you want to use as a control panel
8 // License: CC0 (Public Domain).
9 // To the extent possible under law, Rene10957 has waived all copyright and related or neighboring rights.
10 // For more information, see http://creativecommons.org/publicdomain/zero/1.0/.
11
12
13 string title = "Network Control"; // title
14 string version = "2.3.2"; // version
15 integer linkSet = FALSE; // REGION mode
16 integer silent = TRUE; // silent startup
17
18 // Constants
19
20 float cDialogTime = 120.0; // dialog timeout = 2 minutes
21 float cReplyTime = 1.0; // reply timeout = 1 second
22 integer remoteChannel = -975103; // remote channel (send)
23 integer replyChannel = -975105; // reply channel (receive)
24 string separator = ";;"; // separator for link or region messages
25
26 // Variables
27
28 float time; // timer interval for multiple timers
29 float vReplyTime; // variable timeout for node discovery, ranging from 1 to 2 sec.
30 integer dialogChannel; // dialog channel
31 integer dialogHandle; // handle for dialog listener
32 integer replyHandle; // handle for reply listener
33 key owner; // object owner
34 key user; // key of last avatar to touch object
35 list networkNodes; // strided list of network nodes (object key, object name)
36 list menuButtons; // menu buttons (object names)
37
38 // Functions
39
40 list orderButtons(list buttons)
41 {
42 return llList2List(buttons, -3, -1) + llList2List(buttons, -6, -4) + llList2List(buttons, -9, -7);
43 }
44
45 float setTimer(float sec)
46 {
47 llSetTimerEvent(0.0);
48 llSetTimerEvent(sec);
49 return sec;
50 }
51
52 discoverNodes(key id)
53 {
54 llWhisper(0, "Discovering network nodes...");
55 networkNodes = [];
56 llListenRemove(replyHandle);
57 replyHandle = llListen(replyChannel, "", "", "");
58 float pctlag = 100.0 * (1.0 - llGetRegionTimeDilation()); // try to work around time dilation
59 vReplyTime = cReplyTime + cReplyTime / 100.0 * pctlag; // (more lag = longer timeout)
60 time = setTimer(vReplyTime);
61 if(linkSet) llMessageLinked(LINK_ALL_OTHERS, remoteChannel, "PING", llGetKey());
62 else llRegionSay(remoteChannel, "PING");
63 }
64
65 menuDialog (key id)
66 {
67 dialogChannel = (integer)(llFrand(-1000000000.0) - 1000000000.0);
68 llListenRemove(dialogHandle);
69 dialogHandle = llListen(dialogChannel, "", "", "");
70 time = setTimer(cDialogTime);
71 llDialog(id, title + " " + version, menuButtons, dialogChannel);
72 }
73
74 default
75 {
77 {
78 owner = llGetOwner();
79 if(linkSet) version += "-LINKSET";
80 else version += "-REGION";
81 if(!silent) llWhisper(0, title + " " + version + " ready");
82 }
83
84 on_rez(integer start_param)
85 {
87 }
88
89 touch_start(integer total_number)
90 {
91 user = llDetectedKey(0);
92 if(llGetListLength(networkNodes) == 0) discoverNodes(user);
93 else menuDialog(user);
94 }
95
96 listen(integer channel, string name, key id, string msg)
97 {
98 integer length = llGetListLength(networkNodes) / 2;
99
100 if(channel == replyChannel) {
101 if(llGetOwnerKey(id) != owner) return;
102 if(length > 8) return;
103 string shortName = llGetSubString(msg, 0, 23);
104 networkNodes += [id, shortName];
105 }
106 else if(channel == dialogChannel) {
108 llListenRemove(dialogHandle);
109 integer i;
110 integer index;
111 key target;
112 list msgList;
113 string msgData;
114 if(msg == "On") {
115 for (i = 0; i < length; ++i) {
116 target = llList2Key(networkNodes, i * 2);
117 msgList = [target, "on", id]; // id = user who opened the dialog
118 msgData = llDumpList2String(msgList, separator);
119 if(linkSet) llMessageLinked(LINK_ALL_OTHERS, remoteChannel, msgData, "");
120 else llRegionSayTo(target, remoteChannel, msgData);
121 }
122 menuDialog(id);
123 }
124 else if(msg == "Off") {
125 for (i = 0; i < length; ++i) {
126 target = llList2Key(networkNodes, i * 2);
127 msgList = [target, "off", id]; // id = user who opened the dialog
128 msgData = llDumpList2String(msgList, separator);
129 if(linkSet) llMessageLinked(LINK_ALL_OTHERS, remoteChannel, msgData, "");
130 else llRegionSayTo(target, remoteChannel, msgData);
131 }
132 menuDialog(id);
133 }
134 else if(msg == "Discover") {
135 discoverNodes(id);
136 }
137 else {
138 index = llListFindList(networkNodes, [msg]);
139 if(index > -1) {
140 target = llList2Key(networkNodes, index - 1);
141 msgList = [target, "menu", id]; // id = user who opened the dialog
142 msgData = llDumpList2String(msgList, separator);
143 if(linkSet) llMessageLinked(LINK_ALL_OTHERS, remoteChannel, msgData, "");
144 else llRegionSayTo(target, remoteChannel, msgData);
145 }
146 else {
147 llInstantMessage(id, "Unexpected error during object key lookup");
148 menuDialog(id);
149 }
150 }
151 }
152 }
153
154 timer()
155 {
157 if(time == cDialogTime) { // dialog timeout
158 llListenRemove(dialogHandle);
159 }
160 else if(time == vReplyTime) { // remote timeout (variable!)
161 integer length = llGetListLength(networkNodes) / 2;
162 if(length == 1) llWhisper(0, "Node discovery completed (" + (string)length + " node)");
163 else llWhisper(0, "Node discovery completed (" + (string)length + " nodes)");
164 llListenRemove(replyHandle);
165 if(length > 0) {
166 menuButtons = llList2ListStrided(networkNodes, 1, -1, 2);
167 menuButtons = llListSort(menuButtons, 1, TRUE); // sort ascending
168 menuButtons = orderButtons(menuButtons); // reverse row order
169 menuButtons = ["On", "Off", "Discover"] + menuButtons;
170 if(user) menuDialog(user);
171 }
172 }
173 }
174 }

Rene Free Lighting System

Drop this into the same prim where the SWITCH is located

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

1 // :LICENSE: CC0 (Public Domain)
2 // Network receiver for Rene's Free Lighting System
3 //
4 // Author: Rene10957 Resident
5 // Date: 05-10-2014
6 //
7 // Drop this into the same prim where the SWITCH is located
8 // Note: only useful if you are also using the network control script
9 // License: CC0 (Public Domain).
10 // To the extent possible under law, Rene10957 has waived all copyright and related or neighboring rights.
11 // For more information, see http://creativecommons.org/publicdomain/zero/1.0/.
12
13
14 string title = "Network Receiver"; // title
15 string version = "2.2.1"; // version
16 integer linkSet = TRUE; // LINKSET mode
17 integer silent = TRUE; // silent startup
18
19 // Constants
20
21 integer remoteChannel = -975103; // remote channel
22 integer replyChannel = -975105; // reply channel
23 integer msgNumber = 10957; // number part of link message
24 string separator = ";;"; // separator for link or region messages
25
26 // Variables
27
28 key owner; // object owner
29
30 // Functions
31
32 string getGroup()
33 {
35 if(llToLower(str) == "(no description)" || str == "") str = "Default";
36 return str;
37 }
38
39 default
40 {
42 {
43 owner = llGetOwner();
44 if(linkSet) {
45 version += "-LINKSET";
46 }
47 else {
48 version += "-REGION";
49 llListen(remoteChannel, "", "", "");
50 }
51 if(!silent) llWhisper(0, title + " " + version + " ready");
52 }
53
54 on_rez(integer start_param)
55 {
57 }
58
59 link_message(integer sender_number, integer number, string msg, key id)
60 {
61 if(number != remoteChannel) return;
62 if(msg == "PING") {
63 llRegionSayTo(id, replyChannel, getGroup());
64 return;
65 }
66 list msgList = llParseString2List(msg, [separator], []);
67 key target = (key)llList2String(msgList, 0);
68 string command = llList2String(msgList, 1);
69 key user = (key)llList2String(msgList, 2);
70 if(target == llGetKey()) llMessageLinked(LINK_THIS, msgNumber, command, user);
71 }
72
73 listen(integer channel, string name, key id, string msg)
74 {
75 if(channel != remoteChannel) return;
76 if(llGetOwnerKey(id) != owner) return;
77 if(msg == "PING") {
78 llRegionSayTo(id, replyChannel, getGroup());
79 return;
80 }
81 list msgList = llParseString2List(msg, [separator], []);
82 string command = llList2String(msgList, 1);
83 key user = (key)llList2String(msgList, 2);
84 llMessageLinked(LINK_THIS, msgNumber, command, user);
85 }
86 }

Rene Free Lighting System

Drop this into the same prim where the SWITCH is located

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

1 // :LICENSE: CC0 (Public Domain)
2
3 // Network receiver for Rene's Free Lighting System
4 //
5 // Author: Rene10957 Resident
6 // Date: 05-10-2014
7 //
8 // Drop this into the same prim where the SWITCH is located
9 // Note: only useful if you are also using the network control script
10 // License: CC0 (Public Domain).
11 // To the extent possible under law, Rene10957 has waived all copyright and related or neighboring rights.
12 // For more information, see http://creativecommons.org/publicdomain/zero/1.0/.
13
14
15 string title = "Network Receiver"; // title
16 string version = "2.2.1"; // version
17 integer linkSet = FALSE; // REGION mode
18 integer silent = TRUE; // silent startup
19
20 // Constants
21
22 integer remoteChannel = -975103; // remote channel
23 integer replyChannel = -975105; // reply channel
24 integer msgNumber = 10957; // number part of link message
25 string separator = ";;"; // separator for link or region messages
26
27 // Variables
28
29 key owner; // object owner
30
31 // Functions
32
33 string getGroup()
34 {
36 if(llToLower(str) == "(no description)" || str == "") str = "Default";
37 return str;
38 }
39
40 default
41 {
43 {
44 owner = llGetOwner();
45 if(linkSet) {
46 version += "-LINKSET";
47 }
48 else {
49 version += "-REGION";
50 llListen(remoteChannel, "", "", "");
51 }
52 if(!silent) llWhisper(0, title + " " + version + " ready");
53 }
54
55 on_rez(integer start_param)
56 {
58 }
59
60 link_message(integer sender_number, integer number, string msg, key id)
61 {
62 if(number != remoteChannel) return;
63 if(msg == "PING") {
64 llRegionSayTo(id, replyChannel, getGroup());
65 return;
66 }
67 list msgList = llParseString2List(msg, [separator], []);
68 key target = (key)llList2String(msgList, 0);
69 string command = llList2String(msgList, 1);
70 key user = (key)llList2String(msgList, 2);
71 if(target == llGetKey()) llMessageLinked(LINK_THIS, msgNumber, command, user);
72 }
73
74 listen(integer channel, string name, key id, string msg)
75 {
76 if(channel != remoteChannel) return;
77 if(llGetOwnerKey(id) != owner) return;
78 if(msg == "PING") {
79 llRegionSayTo(id, replyChannel, getGroup());
80 return;
81 }
82 list msgList = llParseString2List(msg, [separator], []);
83 string command = llList2String(msgList, 1);
84 key user = (key)llList2String(msgList, 2);
85 llMessageLinked(LINK_THIS, msgNumber, command, user);
86 }
87 }

Rene Free Lighting System

Drop this in an external prim you want to use as an extra on/off/menu switch

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

1 // :LICENSE: CC0 (Public Domain)
2 // Remote control (secondary switch) for Rene's Free Lighting System
3 //
4 // Author: Rene10957 Resident
5 // Date: 24-01-2014
6 //
7 // Drop this in an external prim you want to use as an extra on/off/menu switch
8 // Note: only useful if you need multiple switches for the same light group in REGION mode
9 // License: CC0 (Public Domain).
10 // To the extent possible under law, Rene10957 has waived all copyright and related or neighboring rights.
11 // For more information, see http://creativecommons.org/publicdomain/zero/1.0/.
12
13
14 string title = "Remote Control"; // title
15 string version = "1.1"; // version
16 integer silent = TRUE; // silent startup
17
18 // Constants
19
20 integer remoteChannel = -975104; // remote channel
21 string separator = ";;"; // separator for region messages
22
23 // Functions
24
25 string getGroup()
26 {
28 if(llToLower(str) == "(no description)" || str == "") str = "Default";
29 return str;
30 }
31
32 default
33 {
35 {
36 if(!silent) llWhisper(0, title + " " + version + " ready");
37 }
38
39 on_rez(integer start_param)
40 {
42 }
43
44 touch_start(integer total_number)
45 {
47 }
48
49 touch_end(integer total_number)
50 {
51 key user = llDetectedKey(0);
52 string command;
53
54 if(llGetTime() > 1.0) command = "menu";
55 else command = "switch";
56
57 list msgList = [getGroup(), command, user];
58 string msgData = llDumpList2String(msgList, separator);
59 llRegionSay(remoteChannel, msgData);
60 }
61 }

Rene Free Lighting System

Drop this into the same prim where the SWITCH is located

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

1 // :LICENSE: CC0 (Public Domain)
2 // Remote receiver for Rene's Free Lighting System
3 //
4 // Author: Rene10957 Resident
5 // Date: 24-01-2014
6 //
7 // Drop this into the same prim where the SWITCH is located
8 // Note: only useful if you are also using the remote control script
9 // License: CC0 (Public Domain).
10 // To the extent possible under law, Rene10957 has waived all copyright and related or neighboring rights.
11 // For more information, see http://creativecommons.org/publicdomain/zero/1.0/.
12
13
14 string title = "Remote Receiver"; // title
15 string version = "1.1"; // version
16 integer silent = TRUE; // silent startup
17
18 // Constants
19
20 integer remoteChannel = -975104; // remote channel
21 integer msgNumber = 10957; // number part of link message
22 string separator = ";;"; // separator for region messages
23
24 // Functions
25
26 string getGroup()
27 {
29 if(llToLower(str) == "(no description)" || str == "") str = "Default";
30 return str;
31 }
32
33 default
34 {
36 {
37 llListen(remoteChannel, "", "", "");
38 if(!silent) llWhisper(0, title + " " + version + " ready");
39 }
40
41 on_rez(integer start_param)
42 {
44 }
45
46 listen(integer channel, string name, key id, string msg)
47 {
48 if(channel != remoteChannel) return;
49
50 list msgList = llParseString2List(msg, [separator], []);
51 string group = llList2String(msgList, 0);
52 string command = llList2String(msgList, 1);
53 key user = (key)llList2String(msgList, 2);
54
55 if(llToLower(group) == llToLower(getGroup())) llMessageLinked(LINK_THIS, msgNumber, command, user);
56 }
57 }

Rene Free Lighting System

Drop in any prim and touch for on/off

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

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

Rene Free Lighting System

Configuration notecard for Lighting System

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

1
2 // :LICENSE: CC0 (Public Domain)
3
4 // License: CC0 (Public Domain).
5 // To the extent possible under law, Rene10957 has waived all copyright and related or neighboring rights.
6 // For more information, see http://creativecommons.org/publicdomain/zero/1.0/.
7
8
9 # Configuration notecard for Lighting System
10 #
11 # Date: 31-05-2015
12 # Version: 2.1
13
14 verbose = YES # show more/less info during startup
15 switchAccess = PUBLIC # access level for switch (PUBLIC, GROUP, OWNER, GROUP+OWNER)
16 menuAccess = PUBLIC # access level for menu (PUBLIC, GROUP, OWNER, GROUP+OWNER)
17 menuPercent = 10 # increase/decrease percentage for +/- buttons
18 changePrimColor = YES # YES = prim color changes with light color
19 changeParticleColor = YES # YES = particle color changes with light color
20 particleTexture = # texture UUID for particle effect
21 particleMenu = NO # YES = "On/Off" replaced by "Particles" (particle menu)
22 notecardMenu = NO # YES = "On/Off" replaced by "Presets" (notecard menu)
23 lightGroups = NO # YES = use prim description for light groups, NO = ignore prim description
24 faces = -1 # color/glow/fullbright on all faces (-1), one face or comma-separated list
25 baseIntensity = 100 # base percentage for light intensity
26
27 # Menu defaults
28
29 colorOn = < 100, 100, 100 > # color percentage (red, green, blue) when ON
30 colorOff = < 100, 100, 100 > # color percentage (red, green, blue) when OFF
31 alphaOn = 100 # alpha percentage when ON
32 alphaOff = 100 # alpha percentage when OFF
33 intensity = 100 # light intensity percentage
34 radius = 50 # light radius percentage
35 falloff = 40 # light falloff percentage
36 glow = 0 # glow percentage
37 fullbright = YES # fullbright when ON (YES or NO)
38 particleSize = 20 # size percentage for particle effect
39
40 # Link messages: in
41
42 msgNumber = 10957 # number part of incoming link messages
43 msgSwitch = switch # string part of incoming link message: switch (on/off)
44 msgOn = on # string part of incoming link message: switch on
45 msgOff = off # string part of incoming link message: switch off
46 msgMenu = menu # string part of incoming link message: show menu
47
48 # Link messages: out
49
50 extButton = # "On/Off" replaced by button text (sends link message)
51 extNumber = 10958 # number part of outgoing link message

Rene Free Lighting System

Light Bulb for Menu-controlled lighting system with many features

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

1 // :LICENSE: CC0 (Public Domain)
2
3 // Rene's Free Lighting System - Light Bulb
4 //
5 // Author: Rene10957 Resident
6 // Date: 31-05-2015
7
8 // License: CC0 (Public Domain).
9 // To the extent possible under law, Rene10957 has waived all copyright and related or neighboring rights.
10 // For more information, see http://creativecommons.org/publicdomain/zero/1.0/.
11
12 string title = "Light Bulb"; // title
13 string version = "2.0"; // version
14 integer linkSet = TRUE; // LINKSET mode
15 integer silent = TRUE; // silent startup
16
17 // Constants
18
19 integer switchChannel = -10957; // switch channel
20 integer particleChannel = -75901; // particle channel
21 integer feedbackChannel = -57910; // feedback channel
22
23 // Variables
24
25 key owner; // object owner
26 string particleMsg; // message for particle plugin (on/off, color, size)
27
28 // Functions
29
30 string getGroup()
31 {
33 if(llToLower(str) == "(no description)" || str == "") str = "Default";
34 return str;
35 }
36
37 unpackMessage(string msg)
38 {
39 list msgList = llCSV2List(msg);
40 integer lightGroups = (integer)llList2String(msgList, 16);
41
42 if(lightGroups && llToLower(llList2String(msgList, 0)) != llToLower(getGroup())) return;
43
44 integer on = (integer)llList2String(msgList, 1);
45 vector color = (vector)llList2String(msgList, 2);
46 float intensity = (float)llList2String(msgList, 3);
47 float radius = (float)llList2String(msgList, 4);
48 float falloff = (float)llList2String(msgList, 5);
49 float alpha = (float)llList2String(msgList, 6);
50 float glow = (float)llList2String(msgList, 7);
51 integer fullbright = (integer)llList2String(msgList, 8);
52 vector primColor = (vector)llList2String(msgList, 9);
53 vector particleColor = (vector)llList2String(msgList, 10);
54 float particleSize = (float)llList2String(msgList, 11);
55 float particleInc = (float)llList2String(msgList, 12);
56 string particleTexture = llList2String(msgList, 13);
57 integer particlesOn = (integer)llList2String(msgList, 14);
58 string faces = llList2String(msgList, 15);
59 // Placeholder for 16 (see above)
60
61 // Forward 10 (particleColor), 11 (particleSize), 12 (particleInc), 13 (particleTexture) and 14 (particlesOn)
62 // to particle script (same prim)
63
64 if(particleMsg == "") particleInc = 999; // first message after script reset: set particle size to default
65 list pList = [particlesOn, particleColor, particleSize, particleInc, particleTexture];
66 particleMsg = llList2CSV(pList); // global variable
67 llMessageLinked(LINK_THIS, particleChannel, particleMsg, "");
68
69 // Set light and prim properties
70
71 list faceList = llParseString2List(faces, ["<", ",", " ", ">"], []);
72 integer length = llGetListLength(faceList);
73 integer face;
74 integer i;
75
76 llSetLinkPrimitiveParamsFast(LINK_THIS, [
77 PRIM_POINT_LIGHT, on, color, intensity, radius, falloff]);
78
79 for (i = 0; i < length; ++i) {
80 face = (integer)llList2String(faceList, i);
81 llSetLinkPrimitiveParamsFast(LINK_THIS, [
82 PRIM_COLOR, face, primColor, alpha,
83 PRIM_GLOW, face, glow,
84 PRIM_FULLBRIGHT, face, fullbright]);
85 }
86 }
87
88 resetParticleSize(string msg)
89 {
90 list msgList = llCSV2List(msg);
91 list pList = llListReplaceList(msgList, [999], 3, 3);
92 particleMsg = llList2CSV(pList); // global variable
93 llMessageLinked(LINK_THIS, particleChannel, particleMsg, "");
94 }
95
96 default
97 {
99 {
100 owner = llGetOwner();
101 if(linkSet) state sLinkSet;
102 else state sRegion;
103 }
104 }
105
106 state sLinkSet
107 {
109 {
110 if(!silent) llWhisper(0, title + " " + version + "-LINKSET ready");
111 }
112
113 on_rez(integer start_param)
114 {
116 }
117
118 link_message(integer sender_number, integer number, string msg, key id)
119 {
120 if(number == switchChannel) {
121 unpackMessage(msg);
122 }
123 else if(number == feedbackChannel) {
124 if(msg == "READY") {
125 llSleep(0.2); // give new particle script time to reset
126 if(particleMsg) resetParticleSize(particleMsg); // start particles with default size
127 }
128 }
129 }
130
131 changed(integer change)
132 {
133 if(change & CHANGED_INVENTORY) {
134 llParticleSystem([]); // stop particles in case particle script was removed
135 if(particleMsg) llMessageLinked(LINK_THIS, particleChannel, particleMsg, ""); // start particles
136 }
137 }
138 }
139
140 state sRegion
141 {
143 {
144 llListen(switchChannel, "", "", "");
145 if(!silent) llWhisper(0, title + " " + version + "-REGION ready");
146 }
147
148 on_rez(integer start_param)
149 {
151 }
152
153 listen(integer channel, string name, key id, string msg)
154 {
155 if(channel == switchChannel) if(llGetOwnerKey(id) == owner) unpackMessage(msg);
156 }
157
158 link_message(integer sender_number, integer number, string msg, key id)
159 {
160 if(number != feedbackChannel) return;
161
162 if(msg == "READY") {
163 llSleep(0.2); // give new particle script time to reset
164 if(particleMsg) resetParticleSize(particleMsg); // start particles with default size
165 }
166 }
167
168 changed(integer change)
169 {
170 if(change & CHANGED_INVENTORY) {
171 llParticleSystem([]); // stop particles in case particle script was removed
172 if(particleMsg) llMessageLinked(LINK_THIS, particleChannel, particleMsg, ""); // start particles
173 }
174 }
175 }

Rene Free Lighting System

Light Bulb for Menu-controlled lighting system with many features

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

1 // :LICENSE: CC0 (Public Domain)
2
3 // Author: Rene10957 Resident
4 // Date: 31-05-2015
5
6 // License: CC0 (Public Domain).
7 // To the extent possible under law, Rene10957 has waived all copyright and related or neighboring rights.
8 // For more information, see http://creativecommons.org/publicdomain/zero/1.0/.
9
10 string title = "Light Bulb"; // title
11 string version = "2.0"; // version
12 integer linkSet = FALSE; // REGION mode
13 integer silent = TRUE; // silent startup
14
15 // Constants
16
17 integer switchChannel = -10957; // switch channel
18 integer particleChannel = -75901; // particle channel
19 integer feedbackChannel = -57910; // feedback channel
20
21 // Variables
22
23 key owner; // object owner
24 string particleMsg; // message for particle plugin (on/off, color, size)
25
26 // Functions
27
28 string getGroup()
29 {
31 if(llToLower(str) == "(no description)" || str == "") str = "Default";
32 return str;
33 }
34
35 unpackMessage(string msg)
36 {
37 list msgList = llCSV2List(msg);
38 integer lightGroups = (integer)llList2String(msgList, 16);
39
40 if(lightGroups && llToLower(llList2String(msgList, 0)) != llToLower(getGroup())) return;
41
42 integer on = (integer)llList2String(msgList, 1);
43 vector color = (vector)llList2String(msgList, 2);
44 float intensity = (float)llList2String(msgList, 3);
45 float radius = (float)llList2String(msgList, 4);
46 float falloff = (float)llList2String(msgList, 5);
47 float alpha = (float)llList2String(msgList, 6);
48 float glow = (float)llList2String(msgList, 7);
49 integer fullbright = (integer)llList2String(msgList, 8);
50 vector primColor = (vector)llList2String(msgList, 9);
51 vector particleColor = (vector)llList2String(msgList, 10);
52 float particleSize = (float)llList2String(msgList, 11);
53 float particleInc = (float)llList2String(msgList, 12);
54 string particleTexture = llList2String(msgList, 13);
55 integer particlesOn = (integer)llList2String(msgList, 14);
56 string faces = llList2String(msgList, 15);
57 // Placeholder for 16 (see above)
58
59 // Forward 10 (particleColor), 11 (particleSize), 12 (particleInc), 13 (particleTexture) and 14 (particlesOn)
60 // to particle script (same prim)
61
62 if(particleMsg == "") particleInc = 999; // first message after script reset: set particle size to default
63 list pList = [particlesOn, particleColor, particleSize, particleInc, particleTexture];
64 particleMsg = llList2CSV(pList); // global variable
65 llMessageLinked(LINK_THIS, particleChannel, particleMsg, "");
66
67 // Set light and prim properties
68
69 list faceList = llParseString2List(faces, ["<", ",", " ", ">"], []);
70 integer length = llGetListLength(faceList);
71 integer face;
72 integer i;
73
74 llSetLinkPrimitiveParamsFast(LINK_THIS, [
75 PRIM_POINT_LIGHT, on, color, intensity, radius, falloff]);
76
77 for (i = 0; i < length; ++i) {
78 face = (integer)llList2String(faceList, i);
79 llSetLinkPrimitiveParamsFast(LINK_THIS, [
80 PRIM_COLOR, face, primColor, alpha,
81 PRIM_GLOW, face, glow,
82 PRIM_FULLBRIGHT, face, fullbright]);
83 }
84 }
85
86 resetParticleSize(string msg)
87 {
88 list msgList = llCSV2List(msg);
89 list pList = llListReplaceList(msgList, [999], 3, 3);
90 particleMsg = llList2CSV(pList); // global variable
91 llMessageLinked(LINK_THIS, particleChannel, particleMsg, "");
92 }
93
94 default
95 {
97 {
98 owner = llGetOwner();
99 if(linkSet) state sLinkSet;
100 else state sRegion;
101 }
102 }
103
104 state sLinkSet
105 {
107 {
108 if(!silent) llWhisper(0, title + " " + version + "-LINKSET ready");
109 }
110
111 on_rez(integer start_param)
112 {
114 }
115
116 link_message(integer sender_number, integer number, string msg, key id)
117 {
118 if(number == switchChannel) {
119 unpackMessage(msg);
120 }
121 else if(number == feedbackChannel) {
122 if(msg == "READY") {
123 llSleep(0.2); // give new particle script time to reset
124 if(particleMsg) resetParticleSize(particleMsg); // start particles with default size
125 }
126 }
127 }
128
129 changed(integer change)
130 {
131 if(change & CHANGED_INVENTORY) {
132 llParticleSystem([]); // stop particles in case particle script was removed
133 if(particleMsg) llMessageLinked(LINK_THIS, particleChannel, particleMsg, ""); // start particles
134 }
135 }
136 }
137
138 state sRegion
139 {
141 {
142 llListen(switchChannel, "", "", "");
143 if(!silent) llWhisper(0, title + " " + version + "-REGION ready");
144 }
145
146 on_rez(integer start_param)
147 {
149 }
150
151 listen(integer channel, string name, key id, string msg)
152 {
153 if(channel == switchChannel) if(llGetOwnerKey(id) == owner) unpackMessage(msg);
154 }
155
156 link_message(integer sender_number, integer number, string msg, key id)
157 {
158 if(number != feedbackChannel) return;
159
160 if(msg == "READY") {
161 llSleep(0.2); // give new particle script time to reset
162 if(particleMsg) resetParticleSize(particleMsg); // start particles with default size
163 }
164 }
165
166 changed(integer change)
167 {
168 if(change & CHANGED_INVENTORY) {
169 llParticleSystem([]); // stop particles in case particle script was removed
170 if(particleMsg) llMessageLinked(LINK_THIS, particleChannel, particleMsg, ""); // start particles
171 }
172 }
173 }

Rene Free Lighting System

Light Switch

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

1 // :LICENSE: CC0 (Public Domain)
2
3 // Rene's Free Lighting System - Light Switch
4 //
5 // Author: Rene10957 Resident
6 // Date: 31-05-2015
7
8 // License: CC0 (Public Domain).
9 // To the extent possible under law, Rene10957 has waived all copyright and related or neighboring rights.
10 // For more information, see http://creativecommons.org/publicdomain/zero/1.0/.
11
12 string title = "Light Switch"; // title
13 string version = "2.1"; // version
14 integer linkSet = TRUE; // LINKSET mode
15
16 // Constants
17
18 integer _PUBLIC_ = 1; // public access bit
19 integer _GROUP_ = 2; // group access bit
20 integer _OWNER_ = 4; // owner access bit
21 integer _GRPOWN_ = 6; // group + owner
22 integer switchChannel = -10957; // switch channel
23 float maxRed = 1.0; // max. red
24 float maxGreen = 1.0; // max. green
25 float maxBlue = 1.0; // max. blue
26 float maxRadius = 20.0; // max. light radius
27 float maxFalloff = 2.0; // max. light falloff
28 float maxGlow = 1.0; // max. prim glow
29 float maxAlpha = 1.0; // max. prim alpha
30 string configPrefix = "config"; // prefix for configuration notecards
31 string configSeparator = ":"; // separator between prefix and name
32 string defNotecard = "Default"; // default notecard
33
34 // Notecard variables
35
36 integer verbose = FALSE; // show more/less info during startup
37 integer switchAccess; // access level for switch
38 integer menuAccess; // access level for menu
39 integer msgNumber; // number part of incoming link messages
40 string msgSwitch; // string part of incoming link message: switch (on/off)
41 string msgOn; // string part of incoming link message: switch on
42 string msgOff; // string part of incoming link message: switch off
43 string msgMenu; // string part of incoming link message: show menu
44 integer percent; // increase/decrease percentage for +/- buttons
45 integer changePrimColor = FALSE; // TRUE = prim color changes with light color, FALSE = white
46 integer changeParticleColor = FALSE; // TRUE = particle color changes with light color, FALSE = white
47 integer particleInc; // increase/decrease percentage for particle effect (menu)
48 string particleTexture; // texture UUID for particle effect
49 integer particleMenu = FALSE; // TRUE = "On/Off" replaced by "Particles" (particle menu)
50 integer notecardMenu = FALSE; // TRUE = "On/Off" replaced by "Presets" (notecard menu)
51 string extButton; // "On/Off" replaced by button text (sends link message)
52 integer extNumber; // number part of outgoing link message
53 integer lightGroups = FALSE; // TRUE = use prim description for light groups, FALSE = ignore prim description
54 string faces; // color/glow/fullbright on all faces (ALL_SIDES = -1), one face or CSV list
55 integer baseIntensity; // base for light intensity
56
57 // Notecard variables: menu defaults
58
59 vector defColor; // default color (R,G,B)
60 vector defColorOff; // default color (R,G,B) when OFF
61 integer defAlpha; // default prim alpha
62 integer defAlphaOff; // default prim alpha when OFF
63 integer defIntensity; // default light intensity
64 integer defRadius; // default light radius
65 integer defFalloff; // default light falloff
66 integer defGlow; // default prim glow
67 integer defFullbright = FALSE; // default fullbright
68 integer defParticleSize; // default particle size
69
70 // Variables
71
72 key owner; // object owner
73 key user; // key of last avatar to touch object
74 list notecardButtons; // list of notecards in inventory
75 string notecard; // notecard name
76 integer line; // notecard line
77 integer loading = FALSE; // notecard loading
78 integer menuChannel; // main menu channel
79 integer colorChannel; // color menu channel
80 integer particleChannel; // particle menu channel
81 integer notecardChannel; // notecard menu channel
82 integer menuHandle; // handle for main menu listener
83 integer colorHandle; // handle for color menu listener
84 integer particleHandle; // handle for particle menu listener
85 integer notecardHandle; // handle for notecard menu listener
86 integer on = FALSE; // on-off switch
87 integer particles = TRUE; // particles on/off
88 integer perRed; // percent red
89 integer perGreen; // percent green
90 integer perBlue; // percent blue
91 integer perAlpha; // percent prim alpha
92 integer perRedOff; // percent red when OFF
93 integer perGreenOff; // percent green when OFF
94 integer perBlueOff; // percent blue when OFF
95 integer perAlphaOff; // percent prim alpha when OFF
96 integer perIntensity; // percent light intensity
97 integer perRadius; // percent light radius
98 integer perFalloff; // percent light falloff
99 integer perGlow; // percent prim glow
100 integer fullbright = TRUE; // fullbright
101
102 // Functions
103
104 list orderButtons(list buttons)
105 {
106 return llList2List(buttons, -3, -1) + llList2List(buttons, -6, -4) + llList2List(buttons, -9, -7) +
107 llList2List(buttons, -12, -10);
108 }
109
110 discoverNotecards()
111 {
112 llSetText("Discovering notecards...", <1,1,1>, 1.0);
113
114 notecardButtons = [];
115 integer i;
116 integer pos;
118 string name;
119 string prefix;
120 string suffix;
121
122 for (i = 0; i < number; ++i) {
124 pos = llSubStringIndex(name, configSeparator);
125 if(pos > -1) {
126 prefix = llGetSubString(name, 0, pos - 1);
127 suffix = llGetSubString(name, pos + 1, -1);
128 if(prefix == configPrefix && suffix != defNotecard && llGetListLength(notecardButtons) < 10)
129 notecardButtons += suffix;
130 }
131 }
132
133 notecardButtons = llListSort(notecardButtons, 1, TRUE); // sort ascending
134 if(llGetInventoryType(configPrefix + configSeparator + defNotecard) == INVENTORY_NOTECARD)
135 notecardButtons += defNotecard;
136
137 if(llGetListLength(notecardButtons) > 0) {
138 notecardButtons += "Main menu";
139 notecardButtons = orderButtons(notecardButtons); // reverse row order
140 }
141
142 llSetText("", ZERO_VECTOR, 0.0);
143 }
144
145 integer accessGranted(key user, integer access)
146 {
147 integer bitmask = _PUBLIC_;
148 if(user == owner) bitmask += _OWNER_;
149 if(llSameGroup(user)) bitmask += _GROUP_;
150 return (bitmask & access);
151 }
152
153 integer checkAccess(string par, string val)
154 {
155 if(llToLower(val) == "public") return _PUBLIC_;
156 if(llToLower(val) == "group") return _GROUP_;
157 if(llToLower(val) == "owner") return _OWNER_;
158 if(llToLower(val) == "group+owner") return _GRPOWN_;
159 llWhisper(0, "[Notecard] " + par + " out of range, corrected to PUBLIC");
160 return _PUBLIC_;
161 }
162
163 integer checkInt(string par, integer val, integer min, integer max)
164 {
165 if(val < min || val > max) {
166 if(val < min) val = min;
167 else if(val > max) val = max;
168 llWhisper(0, "[Notecard] " + par + " out of range, corrected to " + (string)val);
169 }
170 return val;
171 }
172
173 vector checkVector(string par, vector val)
174 {
175 if(val == ZERO_VECTOR) {
176 val = <100,100,100>;
177 llWhisper(0, "[Notecard] " + par + " out of range, corrected to " + (string)val);
178 }
179 return val;
180 }
181
182 integer checkYesNo(string par, string val)
183 {
184 if(llToLower(val) == "yes") return TRUE;
185 if(llToLower(val) == "no") return FALSE;
186 llWhisper(0, "[Notecard] " + par + " out of range, corrected to NO");
187 return FALSE;
188 }
189
190 string checkKey(string par, string val)
191 {
192 if((key)val) return val;
193 if(val == "") return val;
194 llWhisper(0, "[Notecard] " + par + " out of range (not a valid key)");
195 return "";
196 }
197
198 string truncMenuButton(string par, string val)
199 {
201 if(val != trunc) llWhisper(0, "[Notecard] " + par + " will be truncated to 24 bytes");
202 return trunc;
203 }
204
205 loadNotecard()
206 {
207 verbose = TRUE;
208 switchAccess = _PUBLIC_;
209 menuAccess = _PUBLIC_;
210 msgNumber = 10957;
211 msgSwitch = "switch";
212 msgOn = "on";
213 msgOff = "off";
214 msgMenu = "menu";
215 percent = 10;
216 changePrimColor = TRUE;
217 changeParticleColor = TRUE;
218 particleTexture = "";
219 particleMenu = FALSE;
220 notecardMenu = FALSE;
221 extButton = "";
222 extNumber = 10958;
223 lightGroups = FALSE;
224 faces = "-1";
225 baseIntensity = 100;
226 defColor = <100,100,100>;
227 defColorOff = <100,100,100>;
228 defAlpha = 100;
229 defAlphaOff = 100;
230 defIntensity = 100;
231 defRadius = 50;
232 defFalloff = 40;
233 defGlow = 0;
234 defFullbright = TRUE;
235 defParticleSize = 20;
236 line = 0;
237
239 loading = TRUE;
240 llSetText("Loading notecard...", <1,1,1>, 1.0);
241 llGetNotecardLine(notecard, line);
242 }
243 else {
244 reset();
245 particleInc = 999; // reset particle size in plugin script
246 sendMessage(getGroup());
247 if(verbose) {
248 llWhisper(0, "Notecard \"" + notecard + "\" not found or empty, using defaults");
249 llWhisper(0, "Touch to turn light on or off");
250 llWhisper(0, "Long touch to show menu");
251 if(linkSet) llWhisper(0, title + " " + version + "-LINKSET ready");
252 else llWhisper(0, title + " " + version + "-REGION ready");
253 }
254 }
255 }
256
257 readNotecard (string ncLine)
258 {
259 string ncData = llStringTrim(ncLine, STRING_TRIM);
260
261 if(llStringLength(ncData) > 0 && llGetSubString(ncData, 0, 0) != "#") {
262 list ncList = llParseString2List(ncData, ["=","#"], []); // split into parameter, value, comment
265 string lcpar = llToLower(par);
266 if(lcpar == "verbose") verbose = checkYesNo(par, val);
267 else if(lcpar == "switchaccess") switchAccess = checkAccess(par, val);
268 else if(lcpar == "menuaccess") menuAccess = checkAccess(par, val);
269 else if(lcpar == "msgnumber") msgNumber = (integer)val;
270 else if(lcpar == "msgswitch") msgSwitch = truncMenuButton(par, val);
271 else if(lcpar == "msgon") msgOn = truncMenuButton(par, val);
272 else if(lcpar == "msgoff") msgOff = truncMenuButton(par, val);
273 else if(lcpar == "msgmenu") msgMenu = truncMenuButton(par, val);
274 else if(lcpar == "menupercent") percent = checkInt(par, (integer)val, 1, 100);
275 else if(lcpar == "changeprimcolor") changePrimColor = checkYesNo(par, val);
276 else if(lcpar == "changeparticlecolor") changeParticleColor = checkYesNo(par, val);
277 else if(lcpar == "particletexture") particleTexture = checkKey(par, val);
278 else if(lcpar == "particlemenu") particleMenu = checkYesNo(par, val);
279 else if(lcpar == "notecardmenu") notecardMenu = checkYesNo(par, val);
280 else if(lcpar == "extbutton") extButton = truncMenuButton(par, val);
281 else if(lcpar == "extnumber") extNumber = (integer)val;
282 else if(lcpar == "lightgroups") lightGroups = checkYesNo(par, val);
283 else if(lcpar == "faces") faces = truncMenuButton(par, val);
284 else if(lcpar == "baseintensity") baseIntensity = checkInt(par, (integer)val, 1, 100);
285 else if(lcpar == "coloron") defColor = checkVector(par, (vector)val);
286 else if(lcpar == "coloroff") defColorOff = checkVector(par, (vector)val);
287 else if(lcpar == "alphaon") defAlpha = checkInt(par, (integer)val, 0, 100);
288 else if(lcpar == "alphaoff") defAlphaOff = checkInt(par, (integer)val, 0, 100);
289 else if(lcpar == "intensity") defIntensity = checkInt(par, (integer)val, 0, 100);
290 else if(lcpar == "radius") defRadius = checkInt(par, (integer)val, 0, 100);
291 else if(lcpar == "falloff") defFalloff = checkInt(par, (integer)val, 0, 100);
292 else if(lcpar == "glow") defGlow = checkInt(par, (integer)val, 0, 100);
293 else if(lcpar == "fullbright") defFullbright = checkYesNo(par, val);
294 else if(lcpar == "particlesize") defParticleSize = checkInt(par, (integer)val, 1, 100);
295 else llWhisper(0, "Unknown parameter in notecard line " + (string)(line + 1) + ": " + par);
296 }
297
298 line++;
299 llGetNotecardLine(notecard, line);
300 }
301
302 menuDialog (key id)
303 {
304 string strOn = "OFF"; if(on) strOn = "ON";
305 string strLinkSet = "REGION"; if(linkSet) strLinkSet = "LINKSET";
306 string strFullbright = "NO"; if(fullbright) strFullbright = "YES";
307 string strButton = "On/Off"; if(particleMenu) strButton = "Particles";
308 else if(notecardMenu) strButton = "Presets";
309 else if(extButton) strButton = extButton;
310 menuChannel = (integer)(llFrand(-1000000000.0) - 1000000000.0);
311 llListenRemove(menuHandle);
312 menuHandle = llListen(menuChannel, "", "", "");
314 llSetTimerEvent(300);
315 llDialog(id, title + " " + version +
316 "\n\nIntensity: " + (string)perIntensity + "%\t\tState: " + strOn +
317 "\nRadius: " + (string)perRadius + "%\t\tFullbright: " + strFullbright +
318 "\nFalloff: " + (string)perFalloff + "%\t\tMode: " + strLinkSet +
319 "\nGlow: " + (string)perGlow + "%\t\tGroup: " + getGroup(), [
320 "-Glow", "+Glow", strButton,
321 "-Falloff", "+Falloff", "Reset",
322 "-Radius", "+Radius", "Fullbright",
323 "-Intensity", "+Intensity", "Color" ],
324 menuChannel);
325 }
326
327 colorDialog (key id)
328 {
329 colorChannel = (integer)(llFrand(-1000000000.0) - 1000000000.0);
330 llListenRemove(colorHandle);
331 colorHandle = llListen(colorChannel, "", "", "");
333 llSetTimerEvent(300);
334 if(on) {
335 llDialog(id, "Color & Alpha when ON" +
336 "\n\nRed: " + (string)perRed + "%" +
337 "\nGreen: " + (string)perGreen + "%" +
338 "\nBlue: " + (string)perBlue + "%" +
339 "\nAlpha: " + (string)perAlpha + "%", [
340 "-Alpha", "+Alpha", "Main menu",
341 "-Blue", "+Blue", "B min/max",
342 "-Green", "+Green", "G min/max",
343 "-Red", "+Red", "R min/max" ],
344 colorChannel);
345 }
346 else {
347 llDialog(id, "Color & Alpha when OFF" +
348 "\n\nRed: " + (string)perRedOff + "%" +
349 "\nGreen: " + (string)perGreenOff + "%" +
350 "\nBlue: " + (string)perBlueOff + "%" +
351 "\nAlpha: " + (string)perAlphaOff + "%", [
352 "-Alpha", "+Alpha", "Main menu",
353 "-Blue", "+Blue", "B min/max",
354 "-Green", "+Green", "G min/max",
355 "-Red", "+Red", "R min/max" ],
356 colorChannel);
357 }
358 }
359
360 particleDialog (key id)
361 {
362 string strLightOn = "OFF"; if(on) strLightOn = "ON";
363 string strParticlesOn = "OFF"; if(particles) strParticlesOn = "ON";
364 particleChannel = (integer)(llFrand(-1000000000.0) - 1000000000.0);
365 llListenRemove(particleHandle);
366 particleHandle = llListen(particleChannel, "", "", "");
368 llSetTimerEvent(300);
369 llDialog(id, "Particle effect" +
370 "\n\nLight: " + strLightOn +
371 "\nParticles: " + strParticlesOn, [
372 "Min", "Max", "Main menu",
373 "-10%", "+10%", "Reset",
374 "-5%", "+5%", "Part. on/off",
375 "-1%", "+1%", "Light on/off" ],
376 particleChannel);
377 }
378
379 notecardDialog (key id)
380 {
381 string name = llGetSubString(notecard, llStringLength(configPrefix) + llStringLength(configSeparator), -1);
382 notecardChannel = (integer)(llFrand(-1000000000.0) - 1000000000.0);
383 llListenRemove(notecardHandle);
384 notecardHandle = llListen(notecardChannel, "", "", "");
386 llSetTimerEvent(300);
387 llDialog(id, "Configuration notecards\n\nLoaded notecard: " + name, notecardButtons, notecardChannel);
388 }
389
390 string getGroup()
391 {
392 if(!lightGroups) return "None";
394 if(llToLower(str) == "(no description)" || str == "") str = "Default";
395 return str;
396 }
397
398 float percentage (integer per, float num)
399 {
400 return num / 100.0 * (float)per;
401 }
402
403 integer min (integer x, integer y)
404 {
405 if(x < y) return x; else return y;
406 }
407
408 integer max (integer x, integer y)
409 {
410 if(x > y) return x; else return y;
411 }
412
413 reset()
414 {
415 perRed = (integer)defColor.x;
416 perGreen = (integer)defColor.y;
417 perBlue = (integer)defColor.z;
418 perRedOff = (integer)defColorOff.x;
419 perGreenOff = (integer)defColorOff.y;
420 perBlueOff = (integer)defColorOff.z;
421 perAlpha = defAlpha;
422 perAlphaOff = defAlphaOff;
423 perIntensity = defIntensity;
424 perRadius = defRadius;
425 perFalloff = defFalloff;
426 perGlow = defGlow;
427 fullbright = defFullbright;
428 }
429
430 sendMessage(string group)
431 {
432 vector color;
433 vector colorOn;
434 vector colorOff;
435 float intensity;
436 float radius;
437 float falloff;
438 float alpha;
439 float glow;
440 integer fullbr;
441 vector primColor;
442 vector particleColor;
443 integer particlesOn;
444
445 colorOn.x = percentage(perRed, maxRed);
446 colorOn.y = percentage(perGreen, maxGreen);
447 colorOn.z = percentage(perBlue, maxBlue);
448 colorOff.x = percentage(perRedOff, maxRed);
449 colorOff.y = percentage(perGreenOff, maxGreen);
450 colorOff.z = percentage(perBlueOff, maxBlue);
451
452 if(on) {
453 color = colorOn;
454 intensity = percentage(perIntensity, (float)baseIntensity / 100.0);
455 radius = percentage(perRadius, maxRadius);
456 falloff = percentage(perFalloff, maxFalloff);
457 alpha = percentage(perAlpha, maxAlpha);
458 glow = percentage(perGlow, maxGlow);
459 fullbr = fullbright;
460 if(changePrimColor) primColor = color;
461 else primColor = colorOff;
462 if(changeParticleColor) particleColor = color;
463 else particleColor = colorOff;
464 particlesOn = particles;
465 }
466 else {
467 color = colorOff;
468 alpha = percentage(perAlphaOff, maxAlpha);
469 glow = 0.0;
470 fullbr = FALSE;
471 primColor = color;
472 particlesOn = FALSE;
473 }
474
475 list msgList = [group, on, color, intensity, radius, falloff, alpha, glow, fullbr,
476 primColor, particleColor, defParticleSize, particleInc, particleTexture, particlesOn,
477 "<" + faces + ">", lightGroups];
478 string msg = llList2CSV(msgList);
479 particleInc = 0;
480
481 if(linkSet) llMessageLinked(LINK_SET, switchChannel, msg, "");
482 else llRegionSay(switchChannel, msg);
483 }
484
485 default
486 {
488 {
489 owner = llGetOwner();
490 notecard = configPrefix + configSeparator + defNotecard;
491 discoverNotecards();
492 loadNotecard();
493 }
494
495 on_rez(integer start_param)
496 {
498 }
499
500 touch_start(integer total_number)
501 {
503 }
504
505 touch_end(integer total_number)
506 {
507 if(loading) {
508 llWhisper(0, "Notecard is still loading");
509 return;
510 }
511
512 user = llDetectedKey(0);
513
514 if(llGetTime() > 1.0) {
515 if(accessGranted(user, menuAccess)) menuDialog(user);
516 else llInstantMessage(user, "[Menu] Access denied");
517 }
518 else {
519 if(accessGranted(user, switchAccess)) {
520 on = !on;
521 sendMessage(getGroup());
522 }
523 else llInstantMessage(user, "[Switch] Access denied");
524 }
525 }
526
527 listen(integer channel, string name, key id, string msg)
528 {
530
531 if(channel == menuChannel) {
532 llListenRemove(menuHandle);
533 if(msg == "-Intensity") perIntensity = max(perIntensity - percent, 0);
534 else if(msg == "-Radius") perRadius = max(perRadius - percent, 0);
535 else if(msg == "-Falloff") perFalloff = max(perFalloff - percent, 0);
536 else if(msg == "-Glow") perGlow = max(perGlow - percent, 0);
537 else if(msg == "+Intensity") perIntensity = min(perIntensity + percent, 100);
538 else if(msg == "+Radius") perRadius = min(perRadius + percent, 100);
539 else if(msg == "+Falloff") perFalloff = min(perFalloff + percent, 100);
540 else if(msg == "+Glow") perGlow = min(perGlow + percent, 100);
541 else if(msg == "Color") colorDialog(id);
542 else if(msg == "Fullbright") fullbright = !fullbright;
543 else if(msg == "Reset") reset();
544 else if(msg == "On/Off") on = !on;
545 else if(msg == "Particles") particleDialog(id);
546 else if(msg == "Presets") {
547 if(llGetListLength(notecardButtons) > 0) notecardDialog(id);
548 else llWhisper(0, "No configuration notecards found");
549 }
550 else if(msg == extButton) llMessageLinked(LINK_SET, extNumber, msg, id);
551 if(msg != "Color" && msg != "Particles" && msg != "Presets" && msg != extButton) {
552 sendMessage(getGroup());
553 menuDialog(id);
554 }
555 }
556 else if(channel == colorChannel) {
557 llListenRemove(colorHandle);
558 if(on) {
559 if(msg == "-Red") perRed = max(perRed - percent, 0);
560 else if(msg == "-Green") perGreen = max(perGreen - percent, 0);
561 else if(msg == "-Blue") perBlue = max(perBlue - percent, 0);
562 else if(msg == "-Alpha") perAlpha = max(perAlpha - percent, 0);
563 else if(msg == "+Red") perRed = min(perRed + percent, 100);
564 else if(msg == "+Green") perGreen = min(perGreen + percent, 100);
565 else if(msg == "+Blue") perBlue = min(perBlue + percent, 100);
566 else if(msg == "+Alpha") perAlpha = min(perAlpha + percent, 100);
567 else if(msg == "R min/max") { if(perRed) perRed = 0; else perRed = 100; }
568 else if(msg == "G min/max") { if(perGreen) perGreen = 0; else perGreen = 100; }
569 else if(msg == "B min/max") { if(perBlue) perBlue = 0; else perBlue = 100; }
570 else if(msg == "Main menu") menuDialog(id);
571 }
572 else {
573 if(msg == "-Red") perRedOff = max(perRedOff - percent, 0);
574 else if(msg == "-Green") perGreenOff = max(perGreenOff - percent, 0);
575 else if(msg == "-Blue") perBlueOff = max(perBlueOff - percent, 0);
576 else if(msg == "-Alpha") perAlphaOff = max(perAlphaOff - percent, 0);
577 else if(msg == "+Red") perRedOff = min(perRedOff + percent, 100);
578 else if(msg == "+Green") perGreenOff = min(perGreenOff + percent, 100);
579 else if(msg == "+Blue") perBlueOff = min(perBlueOff + percent, 100);
580 else if(msg == "+Alpha") perAlphaOff = min(perAlphaOff + percent, 100);
581 else if(msg == "R min/max") { if(perRedOff) perRedOff = 0; else perRedOff = 100; }
582 else if(msg == "G min/max") { if(perGreenOff) perGreenOff = 0; else perGreenOff = 100; }
583 else if(msg == "B min/max") { if(perBlueOff) perBlueOff = 0; else perBlueOff = 100; }
584 else if(msg == "Main menu") menuDialog(id);
585 }
586 if(msg != "Main menu") {
587 sendMessage(getGroup());
588 colorDialog(id);
589 }
590 }
591 else if(channel == particleChannel) {
592 llListenRemove(particleHandle);
593 if(msg == "-1%") particleInc = -1;
594 else if(msg == "+1%") particleInc = 1;
595 else if(msg == "-5%") particleInc = -5;
596 else if(msg == "+5%") particleInc = 5;
597 else if(msg == "-10%") particleInc = -10;
598 else if(msg == "+10%") particleInc = 10;
599 else if(msg == "Min") particleInc = -100;
600 else if(msg == "Max") particleInc = 100;
601 else if(msg == "Light on/off") on = !on;
602 else if(msg == "Part. on/off") particles = !particles;
603 else if(msg == "Reset") particleInc = 999; // reset particle size
604 else if(msg == "Main menu") menuDialog(id);
605 if(msg != "Main menu") {
606 sendMessage(getGroup());
607 particleDialog(id);
608 }
609 }
610 else if(channel == notecardChannel) {
611 llListenRemove(notecardHandle);
612 if(msg == "Main menu") menuDialog(id);
613 else {
614 notecard = configPrefix + configSeparator + msg;
615 loadNotecard();
616 }
617 }
618 }
619
620 link_message(integer sender_number, integer number, string msg, key id)
621 {
622 if(number != msgNumber) return;
623
624 if(loading) {
625 llWhisper(0, "Notecard is still loading");
626 return;
627 }
628
629 if(id) user = id;
630 else {
631 llWhisper(0, "A valid avatar key must be provided in the link message");
632 return;
633 }
634
635 if(msg == msgSwitch) {
636 if(accessGranted(id, switchAccess)) {
637 on = !on;
638 sendMessage(getGroup());
639 }
640 else llInstantMessage(id, "[Switch] Access denied");
641 }
642 else if(msg == msgOn) {
643 if(accessGranted(id, switchAccess)) {
644 if(!on) {
645 on = TRUE;
646 sendMessage(getGroup());
647 }
648 }
649 else llInstantMessage(id, "[Switch] Access denied");
650 }
651 else if(msg == msgOff) {
652 if(accessGranted(id, switchAccess)) {
653 if(on) {
654 on = FALSE;
655 sendMessage(getGroup());
656 }
657 }
658 else llInstantMessage(id, "[Switch] Access denied");
659 }
660 else if(msg == msgMenu) {
661 if(accessGranted(id, menuAccess)) menuDialog(id);
662 else llInstantMessage(id, "[Menu] Access denied");
663 }
664 }
665
666 dataserver(key req, string data)
667 {
668 if(data == EOF) {
669 defColor.x = checkInt("ColorOn (RED)", (integer)defColor.x, 0, 100);
670 defColor.y = checkInt("ColorOn (GREEN)", (integer)defColor.y, 0, 100);
671 defColor.z = checkInt("ColorOn (BLUE)", (integer)defColor.z, 0, 100);
672 defColorOff.x = checkInt("ColorOff (RED)", (integer)defColorOff.x, 0, 100);
673 defColorOff.y = checkInt("ColorOff (GREEN)", (integer)defColorOff.y, 0, 100);
674 defColorOff.z = checkInt("ColorOff (BLUE)", (integer)defColorOff.z, 0, 100);
675 reset();
676 particleInc = 999; // reset particle size in plugin script
677 sendMessage(getGroup());
678 if(verbose) if(user) {} else {
679 llWhisper(0, "Touch to turn light on or off");
680 llWhisper(0, "Long touch to show menu");
681 if(linkSet) llWhisper(0, title + " " + version + "-LINKSET ready");
682 else llWhisper(0, title + " " + version + "-REGION ready");
683 }
684 loading = FALSE;
685 llSetText("", ZERO_VECTOR, 0.0);
686 if(user) notecardDialog(user);
687 }
688 else {
689 readNotecard(data);
690 }
691 }
692
693 changed(integer change)
694 {
695 if(change & CHANGED_INVENTORY) {
696 user = "";
697 discoverNotecards();
698 loadNotecard();
699 }
700 }
701
702 timer()
703 {
705 llListenRemove(menuHandle);
706 llListenRemove(colorHandle);
707 llListenRemove(particleHandle);
708 llListenRemove(notecardHandle);
709 }
710 }

Rene Free Lighting System


Light Switch for region

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

1 // :LICENSE: CC0 (Public Domain)
2 // Rene's Free Lighting System - Light Switch
3 //
4 // Author: Rene10957 Resident
5 // Date: 31-05-2015
6
7 string title = "Light Switch"; // title
8 string version = "2.1"; // version
9 integer linkSet = FALSE; // REGION mode
10
11 // Constants
12
13 integer _PUBLIC_ = 1; // public access bit
14 integer _GROUP_ = 2; // group access bit
15 integer _OWNER_ = 4; // owner access bit
16 integer _GRPOWN_ = 6; // group + owner
17 integer switchChannel = -10957; // switch channel
18 float maxRed = 1.0; // max. red
19 float maxGreen = 1.0; // max. green
20 float maxBlue = 1.0; // max. blue
21 float maxRadius = 20.0; // max. light radius
22 float maxFalloff = 2.0; // max. light falloff
23 float maxGlow = 1.0; // max. prim glow
24 float maxAlpha = 1.0; // max. prim alpha
25 string configPrefix = "config"; // prefix for configuration notecards
26 string configSeparator = ":"; // separator between prefix and name
27 string defNotecard = "Default"; // default notecard
28
29 // Notecard variables
30
31 integer verbose = FALSE; // show more/less info during startup
32 integer switchAccess; // access level for switch
33 integer menuAccess; // access level for menu
34 integer msgNumber; // number part of incoming link messages
35 string msgSwitch; // string part of incoming link message: switch (on/off)
36 string msgOn; // string part of incoming link message: switch on
37 string msgOff; // string part of incoming link message: switch off
38 string msgMenu; // string part of incoming link message: show menu
39 integer percent; // increase/decrease percentage for +/- buttons
40 integer changePrimColor = FALSE; // TRUE = prim color changes with light color, FALSE = white
41 integer changeParticleColor = FALSE; // TRUE = particle color changes with light color, FALSE = white
42 integer particleInc; // increase/decrease percentage for particle effect (menu)
43 string particleTexture; // texture UUID for particle effect
44 integer particleMenu = FALSE; // TRUE = "On/Off" replaced by "Particles" (particle menu)
45 integer notecardMenu = FALSE; // TRUE = "On/Off" replaced by "Presets" (notecard menu)
46 string extButton; // "On/Off" replaced by button text (sends link message)
47 integer extNumber; // number part of outgoing link message
48 integer lightGroups = FALSE; // TRUE = use prim description for light groups, FALSE = ignore prim description
49 string faces; // color/glow/fullbright on all faces (ALL_SIDES = -1), one face or CSV list
50 integer baseIntensity; // base for light intensity
51
52 // Notecard variables: menu defaults
53
54 vector defColor; // default color (R,G,B)
55 vector defColorOff; // default color (R,G,B) when OFF
56 integer defAlpha; // default prim alpha
57 integer defAlphaOff; // default prim alpha when OFF
58 integer defIntensity; // default light intensity
59 integer defRadius; // default light radius
60 integer defFalloff; // default light falloff
61 integer defGlow; // default prim glow
62 integer defFullbright = FALSE; // default fullbright
63 integer defParticleSize; // default particle size
64
65 // Variables
66
67 key owner; // object owner
68 key user; // key of last avatar to touch object
69 list notecardButtons; // list of notecards in inventory
70 string notecard; // notecard name
71 integer line; // notecard line
72 integer loading = FALSE; // notecard loading
73 integer menuChannel; // main menu channel
74 integer colorChannel; // color menu channel
75 integer particleChannel; // particle menu channel
76 integer notecardChannel; // notecard menu channel
77 integer menuHandle; // handle for main menu listener
78 integer colorHandle; // handle for color menu listener
79 integer particleHandle; // handle for particle menu listener
80 integer notecardHandle; // handle for notecard menu listener
81 integer on = FALSE; // on-off switch
82 integer particles = TRUE; // particles on/off
83 integer perRed; // percent red
84 integer perGreen; // percent green
85 integer perBlue; // percent blue
86 integer perAlpha; // percent prim alpha
87 integer perRedOff; // percent red when OFF
88 integer perGreenOff; // percent green when OFF
89 integer perBlueOff; // percent blue when OFF
90 integer perAlphaOff; // percent prim alpha when OFF
91 integer perIntensity; // percent light intensity
92 integer perRadius; // percent light radius
93 integer perFalloff; // percent light falloff
94 integer perGlow; // percent prim glow
95 integer fullbright = TRUE; // fullbright
96
97 // Functions
98
99 list orderButtons(list buttons)
100 {
101 return llList2List(buttons, -3, -1) + llList2List(buttons, -6, -4) + llList2List(buttons, -9, -7) +
102 llList2List(buttons, -12, -10);
103 }
104
105 discoverNotecards()
106 {
107 llSetText("Discovering notecards...", <1,1,1>, 1.0);
108
109 notecardButtons = [];
110 integer i;
111 integer pos;
113 string name;
114 string prefix;
115 string suffix;
116
117 for (i = 0; i < number; ++i) {
119 pos = llSubStringIndex(name, configSeparator);
120 if(pos > -1) {
121 prefix = llGetSubString(name, 0, pos - 1);
122 suffix = llGetSubString(name, pos + 1, -1);
123 if(prefix == configPrefix && suffix != defNotecard && llGetListLength(notecardButtons) < 10)
124 notecardButtons += suffix;
125 }
126 }
127
128 notecardButtons = llListSort(notecardButtons, 1, TRUE); // sort ascending
129 if(llGetInventoryType(configPrefix + configSeparator + defNotecard) == INVENTORY_NOTECARD)
130 notecardButtons += defNotecard;
131
132 if(llGetListLength(notecardButtons) > 0) {
133 notecardButtons += "Main menu";
134 notecardButtons = orderButtons(notecardButtons); // reverse row order
135 }
136
137 llSetText("", ZERO_VECTOR, 0.0);
138 }
139
140 integer accessGranted(key user, integer access)
141 {
142 integer bitmask = _PUBLIC_;
143 if(user == owner) bitmask += _OWNER_;
144 if(llSameGroup(user)) bitmask += _GROUP_;
145 return (bitmask & access);
146 }
147
148 integer checkAccess(string par, string val)
149 {
150 if(llToLower(val) == "public") return _PUBLIC_;
151 if(llToLower(val) == "group") return _GROUP_;
152 if(llToLower(val) == "owner") return _OWNER_;
153 if(llToLower(val) == "group+owner") return _GRPOWN_;
154 llWhisper(0, "[Notecard] " + par + " out of range, corrected to PUBLIC");
155 return _PUBLIC_;
156 }
157
158 integer checkInt(string par, integer val, integer min, integer max)
159 {
160 if(val < min || val > max) {
161 if(val < min) val = min;
162 else if(val > max) val = max;
163 llWhisper(0, "[Notecard] " + par + " out of range, corrected to " + (string)val);
164 }
165 return val;
166 }
167
168 vector checkVector(string par, vector val)
169 {
170 if(val == ZERO_VECTOR) {
171 val = <100,100,100>;
172 llWhisper(0, "[Notecard] " + par + " out of range, corrected to " + (string)val);
173 }
174 return val;
175 }
176
177 integer checkYesNo(string par, string val)
178 {
179 if(llToLower(val) == "yes") return TRUE;
180 if(llToLower(val) == "no") return FALSE;
181 llWhisper(0, "[Notecard] " + par + " out of range, corrected to NO");
182 return FALSE;
183 }
184
185 string checkKey(string par, string val)
186 {
187 if((key)val) return val;
188 if(val == "") return val;
189 llWhisper(0, "[Notecard] " + par + " out of range (not a valid key)");
190 return "";
191 }
192
193 string truncMenuButton(string par, string val)
194 {
196 if(val != trunc) llWhisper(0, "[Notecard] " + par + " will be truncated to 24 bytes");
197 return trunc;
198 }
199
200 loadNotecard()
201 {
202 verbose = TRUE;
203 switchAccess = _PUBLIC_;
204 menuAccess = _PUBLIC_;
205 msgNumber = 10957;
206 msgSwitch = "switch";
207 msgOn = "on";
208 msgOff = "off";
209 msgMenu = "menu";
210 percent = 10;
211 changePrimColor = TRUE;
212 changeParticleColor = TRUE;
213 particleTexture = "";
214 particleMenu = FALSE;
215 notecardMenu = FALSE;
216 extButton = "";
217 extNumber = 10958;
218 lightGroups = FALSE;
219 faces = "-1";
220 baseIntensity = 100;
221 defColor = <100,100,100>;
222 defColorOff = <100,100,100>;
223 defAlpha = 100;
224 defAlphaOff = 100;
225 defIntensity = 100;
226 defRadius = 50;
227 defFalloff = 40;
228 defGlow = 0;
229 defFullbright = TRUE;
230 defParticleSize = 20;
231 line = 0;
232
234 loading = TRUE;
235 llSetText("Loading notecard...", <1,1,1>, 1.0);
236 llGetNotecardLine(notecard, line);
237 }
238 else {
239 reset();
240 particleInc = 999; // reset particle size in plugin script
241 sendMessage(getGroup());
242 if(verbose) {
243 llWhisper(0, "Notecard \"" + notecard + "\" not found or empty, using defaults");
244 llWhisper(0, "Touch to turn light on or off");
245 llWhisper(0, "Long touch to show menu");
246 if(linkSet) llWhisper(0, title + " " + version + "-LINKSET ready");
247 else llWhisper(0, title + " " + version + "-REGION ready");
248 }
249 }
250 }
251
252 readNotecard (string ncLine)
253 {
254 string ncData = llStringTrim(ncLine, STRING_TRIM);
255
256 if(llStringLength(ncData) > 0 && llGetSubString(ncData, 0, 0) != "#") {
257 list ncList = llParseString2List(ncData, ["=","#"], []); // split into parameter, value, comment
260 string lcpar = llToLower(par);
261 if(lcpar == "verbose") verbose = checkYesNo(par, val);
262 else if(lcpar == "switchaccess") switchAccess = checkAccess(par, val);
263 else if(lcpar == "menuaccess") menuAccess = checkAccess(par, val);
264 else if(lcpar == "msgnumber") msgNumber = (integer)val;
265 else if(lcpar == "msgswitch") msgSwitch = truncMenuButton(par, val);
266 else if(lcpar == "msgon") msgOn = truncMenuButton(par, val);
267 else if(lcpar == "msgoff") msgOff = truncMenuButton(par, val);
268 else if(lcpar == "msgmenu") msgMenu = truncMenuButton(par, val);
269 else if(lcpar == "menupercent") percent = checkInt(par, (integer)val, 1, 100);
270 else if(lcpar == "changeprimcolor") changePrimColor = checkYesNo(par, val);
271 else if(lcpar == "changeparticlecolor") changeParticleColor = checkYesNo(par, val);
272 else if(lcpar == "particletexture") particleTexture = checkKey(par, val);
273 else if(lcpar == "particlemenu") particleMenu = checkYesNo(par, val);
274 else if(lcpar == "notecardmenu") notecardMenu = checkYesNo(par, val);
275 else if(lcpar == "extbutton") extButton = truncMenuButton(par, val);
276 else if(lcpar == "extnumber") extNumber = (integer)val;
277 else if(lcpar == "lightgroups") lightGroups = checkYesNo(par, val);
278 else if(lcpar == "faces") faces = truncMenuButton(par, val);
279 else if(lcpar == "baseintensity") baseIntensity = checkInt(par, (integer)val, 1, 100);
280 else if(lcpar == "coloron") defColor = checkVector(par, (vector)val);
281 else if(lcpar == "coloroff") defColorOff = checkVector(par, (vector)val);
282 else if(lcpar == "alphaon") defAlpha = checkInt(par, (integer)val, 0, 100);
283 else if(lcpar == "alphaoff") defAlphaOff = checkInt(par, (integer)val, 0, 100);
284 else if(lcpar == "intensity") defIntensity = checkInt(par, (integer)val, 0, 100);
285 else if(lcpar == "radius") defRadius = checkInt(par, (integer)val, 0, 100);
286 else if(lcpar == "falloff") defFalloff = checkInt(par, (integer)val, 0, 100);
287 else if(lcpar == "glow") defGlow = checkInt(par, (integer)val, 0, 100);
288 else if(lcpar == "fullbright") defFullbright = checkYesNo(par, val);
289 else if(lcpar == "particlesize") defParticleSize = checkInt(par, (integer)val, 1, 100);
290 else llWhisper(0, "Unknown parameter in notecard line " + (string)(line + 1) + ": " + par);
291 }
292
293 line++;
294 llGetNotecardLine(notecard, line);
295 }
296
297 menuDialog (key id)
298 {
299 string strOn = "OFF"; if(on) strOn = "ON";
300 string strLinkSet = "REGION"; if(linkSet) strLinkSet = "LINKSET";
301 string strFullbright = "NO"; if(fullbright) strFullbright = "YES";
302 string strButton = "On/Off"; if(particleMenu) strButton = "Particles";
303 else if(notecardMenu) strButton = "Presets";
304 else if(extButton) strButton = extButton;
305 menuChannel = (integer)(llFrand(-1000000000.0) - 1000000000.0);
306 llListenRemove(menuHandle);
307 menuHandle = llListen(menuChannel, "", "", "");
309 llSetTimerEvent(300);
310 llDialog(id, title + " " + version +
311 "\n\nIntensity: " + (string)perIntensity + "%\t\tState: " + strOn +
312 "\nRadius: " + (string)perRadius + "%\t\tFullbright: " + strFullbright +
313 "\nFalloff: " + (string)perFalloff + "%\t\tMode: " + strLinkSet +
314 "\nGlow: " + (string)perGlow + "%\t\tGroup: " + getGroup(), [
315 "-Glow", "+Glow", strButton,
316 "-Falloff", "+Falloff", "Reset",
317 "-Radius", "+Radius", "Fullbright",
318 "-Intensity", "+Intensity", "Color" ],
319 menuChannel);
320 }
321
322 colorDialog (key id)
323 {
324 colorChannel = (integer)(llFrand(-1000000000.0) - 1000000000.0);
325 llListenRemove(colorHandle);
326 colorHandle = llListen(colorChannel, "", "", "");
328 llSetTimerEvent(300);
329 if(on) {
330 llDialog(id, "Color & Alpha when ON" +
331 "\n\nRed: " + (string)perRed + "%" +
332 "\nGreen: " + (string)perGreen + "%" +
333 "\nBlue: " + (string)perBlue + "%" +
334 "\nAlpha: " + (string)perAlpha + "%", [
335 "-Alpha", "+Alpha", "Main menu",
336 "-Blue", "+Blue", "B min/max",
337 "-Green", "+Green", "G min/max",
338 "-Red", "+Red", "R min/max" ],
339 colorChannel);
340 }
341 else {
342 llDialog(id, "Color & Alpha when OFF" +
343 "\n\nRed: " + (string)perRedOff + "%" +
344 "\nGreen: " + (string)perGreenOff + "%" +
345 "\nBlue: " + (string)perBlueOff + "%" +
346 "\nAlpha: " + (string)perAlphaOff + "%", [
347 "-Alpha", "+Alpha", "Main menu",
348 "-Blue", "+Blue", "B min/max",
349 "-Green", "+Green", "G min/max",
350 "-Red", "+Red", "R min/max" ],
351 colorChannel);
352 }
353 }
354
355 particleDialog (key id)
356 {
357 string strLightOn = "OFF"; if(on) strLightOn = "ON";
358 string strParticlesOn = "OFF"; if(particles) strParticlesOn = "ON";
359 particleChannel = (integer)(llFrand(-1000000000.0) - 1000000000.0);
360 llListenRemove(particleHandle);
361 particleHandle = llListen(particleChannel, "", "", "");
363 llSetTimerEvent(300);
364 llDialog(id, "Particle effect" +
365 "\n\nLight: " + strLightOn +
366 "\nParticles: " + strParticlesOn, [
367 "Min", "Max", "Main menu",
368 "-10%", "+10%", "Reset",
369 "-5%", "+5%", "Part. on/off",
370 "-1%", "+1%", "Light on/off" ],
371 particleChannel);
372 }
373
374 notecardDialog (key id)
375 {
376 string name = llGetSubString(notecard, llStringLength(configPrefix) + llStringLength(configSeparator), -1);
377 notecardChannel = (integer)(llFrand(-1000000000.0) - 1000000000.0);
378 llListenRemove(notecardHandle);
379 notecardHandle = llListen(notecardChannel, "", "", "");
381 llSetTimerEvent(300);
382 llDialog(id, "Configuration notecards\n\nLoaded notecard: " + name, notecardButtons, notecardChannel);
383 }
384
385 string getGroup()
386 {
387 if(!lightGroups) return "None";
389 if(llToLower(str) == "(no description)" || str == "") str = "Default";
390 return str;
391 }
392
393 float percentage (integer per, float num)
394 {
395 return num / 100.0 * (float)per;
396 }
397
398 integer min (integer x, integer y)
399 {
400 if(x < y) return x; else return y;
401 }
402
403 integer max (integer x, integer y)
404 {
405 if(x > y) return x; else return y;
406 }
407
408 reset()
409 {
410 perRed = (integer)defColor.x;
411 perGreen = (integer)defColor.y;
412 perBlue = (integer)defColor.z;
413 perRedOff = (integer)defColorOff.x;
414 perGreenOff = (integer)defColorOff.y;
415 perBlueOff = (integer)defColorOff.z;
416 perAlpha = defAlpha;
417 perAlphaOff = defAlphaOff;
418 perIntensity = defIntensity;
419 perRadius = defRadius;
420 perFalloff = defFalloff;
421 perGlow = defGlow;
422 fullbright = defFullbright;
423 }
424
425 sendMessage(string group)
426 {
427 vector color;
428 vector colorOn;
429 vector colorOff;
430 float intensity;
431 float radius;
432 float falloff;
433 float alpha;
434 float glow;
435 integer fullbr;
436 vector primColor;
437 vector particleColor;
438 integer particlesOn;
439
440 colorOn.x = percentage(perRed, maxRed);
441 colorOn.y = percentage(perGreen, maxGreen);
442 colorOn.z = percentage(perBlue, maxBlue);
443 colorOff.x = percentage(perRedOff, maxRed);
444 colorOff.y = percentage(perGreenOff, maxGreen);
445 colorOff.z = percentage(perBlueOff, maxBlue);
446
447 if(on) {
448 color = colorOn;
449 intensity = percentage(perIntensity, (float)baseIntensity / 100.0);
450 radius = percentage(perRadius, maxRadius);
451 falloff = percentage(perFalloff, maxFalloff);
452 alpha = percentage(perAlpha, maxAlpha);
453 glow = percentage(perGlow, maxGlow);
454 fullbr = fullbright;
455 if(changePrimColor) primColor = color;
456 else primColor = colorOff;
457 if(changeParticleColor) particleColor = color;
458 else particleColor = colorOff;
459 particlesOn = particles;
460 }
461 else {
462 color = colorOff;
463 alpha = percentage(perAlphaOff, maxAlpha);
464 glow = 0.0;
465 fullbr = FALSE;
466 primColor = color;
467 particlesOn = FALSE;
468 }
469
470 list msgList = [group, on, color, intensity, radius, falloff, alpha, glow, fullbr,
471 primColor, particleColor, defParticleSize, particleInc, particleTexture, particlesOn,
472 "<" + faces + ">", lightGroups];
473 string msg = llList2CSV(msgList);
474 particleInc = 0;
475
476 if(linkSet) llMessageLinked(LINK_SET, switchChannel, msg, "");
477 else llRegionSay(switchChannel, msg);
478 }
479
480 default
481 {
483 {
484 owner = llGetOwner();
485 notecard = configPrefix + configSeparator + defNotecard;
486 discoverNotecards();
487 loadNotecard();
488 }
489
490 on_rez(integer start_param)
491 {
493 }
494
495 touch_start(integer total_number)
496 {
498 }
499
500 touch_end(integer total_number)
501 {
502 if(loading) {
503 llWhisper(0, "Notecard is still loading");
504 return;
505 }
506
507 user = llDetectedKey(0);
508
509 if(llGetTime() > 1.0) {
510 if(accessGranted(user, menuAccess)) menuDialog(user);
511 else llInstantMessage(user, "[Menu] Access denied");
512 }
513 else {
514 if(accessGranted(user, switchAccess)) {
515 on = !on;
516 sendMessage(getGroup());
517 }
518 else llInstantMessage(user, "[Switch] Access denied");
519 }
520 }
521
522 listen(integer channel, string name, key id, string msg)
523 {
525
526 if(channel == menuChannel) {
527 llListenRemove(menuHandle);
528 if(msg == "-Intensity") perIntensity = max(perIntensity - percent, 0);
529 else if(msg == "-Radius") perRadius = max(perRadius - percent, 0);
530 else if(msg == "-Falloff") perFalloff = max(perFalloff - percent, 0);
531 else if(msg == "-Glow") perGlow = max(perGlow - percent, 0);
532 else if(msg == "+Intensity") perIntensity = min(perIntensity + percent, 100);
533 else if(msg == "+Radius") perRadius = min(perRadius + percent, 100);
534 else if(msg == "+Falloff") perFalloff = min(perFalloff + percent, 100);
535 else if(msg == "+Glow") perGlow = min(perGlow + percent, 100);
536 else if(msg == "Color") colorDialog(id);
537 else if(msg == "Fullbright") fullbright = !fullbright;
538 else if(msg == "Reset") reset();
539 else if(msg == "On/Off") on = !on;
540 else if(msg == "Particles") particleDialog(id);
541 else if(msg == "Presets") {
542 if(llGetListLength(notecardButtons) > 0) notecardDialog(id);
543 else llWhisper(0, "No configuration notecards found");
544 }
545 else if(msg == extButton) llMessageLinked(LINK_SET, extNumber, msg, id);
546 if(msg != "Color" && msg != "Particles" && msg != "Presets" && msg != extButton) {
547 sendMessage(getGroup());
548 menuDialog(id);
549 }
550 }
551 else if(channel == colorChannel) {
552 llListenRemove(colorHandle);
553 if(on) {
554 if(msg == "-Red") perRed = max(perRed - percent, 0);
555 else if(msg == "-Green") perGreen = max(perGreen - percent, 0);
556 else if(msg == "-Blue") perBlue = max(perBlue - percent, 0);
557 else if(msg == "-Alpha") perAlpha = max(perAlpha - percent, 0);
558 else if(msg == "+Red") perRed = min(perRed + percent, 100);
559 else if(msg == "+Green") perGreen = min(perGreen + percent, 100);
560 else if(msg == "+Blue") perBlue = min(perBlue + percent, 100);
561 else if(msg == "+Alpha") perAlpha = min(perAlpha + percent, 100);
562 else if(msg == "R min/max") { if(perRed) perRed = 0; else perRed = 100; }
563 else if(msg == "G min/max") { if(perGreen) perGreen = 0; else perGreen = 100; }
564 else if(msg == "B min/max") { if(perBlue) perBlue = 0; else perBlue = 100; }
565 else if(msg == "Main menu") menuDialog(id);
566 }
567 else {
568 if(msg == "-Red") perRedOff = max(perRedOff - percent, 0);
569 else if(msg == "-Green") perGreenOff = max(perGreenOff - percent, 0);
570 else if(msg == "-Blue") perBlueOff = max(perBlueOff - percent, 0);
571 else if(msg == "-Alpha") perAlphaOff = max(perAlphaOff - percent, 0);
572 else if(msg == "+Red") perRedOff = min(perRedOff + percent, 100);
573 else if(msg == "+Green") perGreenOff = min(perGreenOff + percent, 100);
574 else if(msg == "+Blue") perBlueOff = min(perBlueOff + percent, 100);
575 else if(msg == "+Alpha") perAlphaOff = min(perAlphaOff + percent, 100);
576 else if(msg == "R min/max") { if(perRedOff) perRedOff = 0; else perRedOff = 100; }
577 else if(msg == "G min/max") { if(perGreenOff) perGreenOff = 0; else perGreenOff = 100; }
578 else if(msg == "B min/max") { if(perBlueOff) perBlueOff = 0; else perBlueOff = 100; }
579 else if(msg == "Main menu") menuDialog(id);
580 }
581 if(msg != "Main menu") {
582 sendMessage(getGroup());
583 colorDialog(id);
584 }
585 }
586 else if(channel == particleChannel) {
587 llListenRemove(particleHandle);
588 if(msg == "-1%") particleInc = -1;
589 else if(msg == "+1%") particleInc = 1;
590 else if(msg == "-5%") particleInc = -5;
591 else if(msg == "+5%") particleInc = 5;
592 else if(msg == "-10%") particleInc = -10;
593 else if(msg == "+10%") particleInc = 10;
594 else if(msg == "Min") particleInc = -100;
595 else if(msg == "Max") particleInc = 100;
596 else if(msg == "Light on/off") on = !on;
597 else if(msg == "Part. on/off") particles = !particles;
598 else if(msg == "Reset") particleInc = 999; // reset particle size
599 else if(msg == "Main menu") menuDialog(id);
600 if(msg != "Main menu") {
601 sendMessage(getGroup());
602 particleDialog(id);
603 }
604 }
605 else if(channel == notecardChannel) {
606 llListenRemove(notecardHandle);
607 if(msg == "Main menu") menuDialog(id);
608 else {
609 notecard = configPrefix + configSeparator + msg;
610 loadNotecard();
611 }
612 }
613 }
614
615 link_message(integer sender_number, integer number, string msg, key id)
616 {
617 if(number != msgNumber) return;
618
619 if(loading) {
620 llWhisper(0, "Notecard is still loading");
621 return;
622 }
623
624 if(id) user = id;
625 else {
626 llWhisper(0, "A valid avatar key must be provided in the link message");
627 return;
628 }
629
630 if(msg == msgSwitch) {
631 if(accessGranted(id, switchAccess)) {
632 on = !on;
633 sendMessage(getGroup());
634 }
635 else llInstantMessage(id, "[Switch] Access denied");
636 }
637 else if(msg == msgOn) {
638 if(accessGranted(id, switchAccess)) {
639 if(!on) {
640 on = TRUE;
641 sendMessage(getGroup());
642 }
643 }
644 else llInstantMessage(id, "[Switch] Access denied");
645 }
646 else if(msg == msgOff) {
647 if(accessGranted(id, switchAccess)) {
648 if(on) {
649 on = FALSE;
650 sendMessage(getGroup());
651 }
652 }
653 else llInstantMessage(id, "[Switch] Access denied");
654 }
655 else if(msg == msgMenu) {
656 if(accessGranted(id, menuAccess)) menuDialog(id);
657 else llInstantMessage(id, "[Menu] Access denied");
658 }
659 }
660
661 dataserver(key req, string data)
662 {
663 if(data == EOF) {
664 defColor.x = checkInt("ColorOn (RED)", (integer)defColor.x, 0, 100);
665 defColor.y = checkInt("ColorOn (GREEN)", (integer)defColor.y, 0, 100);
666 defColor.z = checkInt("ColorOn (BLUE)", (integer)defColor.z, 0, 100);
667 defColorOff.x = checkInt("ColorOff (RED)", (integer)defColorOff.x, 0, 100);
668 defColorOff.y = checkInt("ColorOff (GREEN)", (integer)defColorOff.y, 0, 100);
669 defColorOff.z = checkInt("ColorOff (BLUE)", (integer)defColorOff.z, 0, 100);
670 reset();
671 particleInc = 999; // reset particle size in plugin script
672 sendMessage(getGroup());
673 if(verbose) if(user) {} else {
674 llWhisper(0, "Touch to turn light on or off");
675 llWhisper(0, "Long touch to show menu");
676 if(linkSet) llWhisper(0, title + " " + version + "-LINKSET ready");
677 else llWhisper(0, title + " " + version + "-REGION ready");
678 }
679 loading = FALSE;
680 llSetText("", ZERO_VECTOR, 0.0);
681 if(user) notecardDialog(user);
682 }
683 else {
684 readNotecard(data);
685 }
686 }
687
688 changed(integer change)
689 {
690 if(change & CHANGED_INVENTORY) {
691 user = "";
692 discoverNotecards();
693 loadNotecard();
694 }
695 }
696
697 timer()
698 {
700 llListenRemove(menuHandle);
701 llListenRemove(colorHandle);
702 llListenRemove(particleHandle);
703 llListenRemove(notecardHandle);
704 }
705 }

Rene Free Lighting System

RGB to LSL color conversion

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

1 // :LICENSE: CC0 (Public Domain)
2
3 // Rene's Free Lighting System - RGB to LSL color conversion
4 //
5 // Author: Rene10957 Resident
6 // Date: 12-01-2014
7 //
8 // Rez a cube, drop the script in it and touch it
9 // Enter the resulting color vector into the notecard next to "colorOn" or "colorOff"
10
11 string title = "Color converter"; // title
12 string version = "1.0"; // version
13
14 // Variables
15
16 integer boxChannel; // text box channel
17 integer boxHandle; // handle for text box listener
18
19 default
20 {
22 {
23 llWhisper(0, title + " " + version + " ready");
24 }
25
26 on_rez(integer start_param)
27 {
29 }
30
31 touch_start(integer total_number)
32 {
33 boxChannel = (integer)(llFrand(-1000000000.0) - 1000000000.0);
34 llListenRemove(boxHandle);
35 boxHandle = llListen(boxChannel, "", "", "");
37 llSetTimerEvent(120);
38 llTextBox(llDetectedKey(0), "\nEnter RGB color as <R,G,B>\ne.g. <255,0,0> for red", boxChannel);
39 }
40
41 listen(integer channel, string name, key id, string msg)
42 {
43 if(channel != boxChannel) return;
45 llListenRemove(boxHandle);
46
47 vector rgb = (vector)msg;
48 vector lsl = rgb / 255.0;
49 vector per = lsl * 100.0;
50 per.x = (float)llRound(per.x);
51 per.y = (float)llRound(per.y);
52 per.z = (float)llRound(per.z);
53
54 llOwnerSay("RGB color = " + "< " + (string)((integer)rgb.x) + ", " +
55 (string)((integer)rgb.y) + ", " + (string)((integer)rgb.z) + " >");
56 llOwnerSay("LSL color = " + "< " + (string)lsl.x + ", " +
57 (string)lsl.y + ", " + (string)lsl.z + " >");
58 llOwnerSay("Notecard color = " + "< " + (string)((integer)per.x) + ", " +
59 (string)((integer)per.y) + ", " + (string)((integer)per.z) + " >");
60 }
61
62 timer()
63 {
65 llListenRemove(boxHandle);
66 llOwnerSay("Text box timeout");
67 }
68 }

Rene Free Lighting System

Face picker: identify face numbers by touch

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

1 // :LICENSE: CC0 (Public Domain)
2
3 // Face picker: identify face numbers by touch
4
5 default
6 {
7 touch_start(integer total_number)
8 {
10 if(face == TOUCH_INVALID_FACE) llOwnerSay("Viewer does not support touched faces");
11 else llOwnerSay("Face " + (string)face);
12 }
13 }

Rene Free Lighting System

Removes floating text and then removes itself

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

1 // :LICENSE: CC0 (Public Domain)
2
3 // Removes floating text and then removes itself
4
5 default
6 {
8 {
9 llSetLinkPrimitiveParamsFast(LINK_SET, [PRIM_TEXT, "", ZERO_VECTOR, 0.0]);
11 }
12 }

Rene Free Lighting System

Nightlight switch: drop this script into the same prim where the SWITCH is located

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

1 // :LICENSE: CC0 (Public Domain)
2
3 // Night light plugin for Rene's Free Lighting System
4 // A simple example script for creating your own plugin
5 //
6 // Automatically switches on at sunset and off at sunrise
7
8 /////////////////////////////////////////////////////////////////////////////////
9 // HOW TO USE: drop this script into the same prim where the SWITCH is located //
10 /////////////////////////////////////////////////////////////////////////////////
11
12 key owner; // object owner
13 integer number = 10957; // number part of link message
14
15 default
16 {
18 {
19 owner = llGetOwner();
20 llSetTimerEvent(300);
21 }
22
23 on_rez(integer start_param)
24 {
26 }
27
28 timer()
29 {
31 if(sun.z < 0) llMessageLinked(LINK_THIS, number, "on", owner);
32 else llMessageLinked(LINK_THIS, number, "off", owner);
33 }
34 }

Rene Free Lighting System

Proximity Switch: drop this script into the same prim where the SWITCH is located

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

1 // :LICENSE: CC0 (Public Domain)
2 // Proximity light plugin for Rene's Free Lighting System
3 // A simple example script for creating your own plugin
4 //
5 // Automatically switches on when an avatar comes within 10 meters
6 // Automatically switches off after one minute when no avatars are in range
7
8 /////////////////////////////////////////////////////////////////////////////////
9 // HOW TO USE: drop this script into the same prim where the SWITCH is located //
10 /////////////////////////////////////////////////////////////////////////////////
11
12 key owner; // object owner
13 integer number = 10957; // number part of link message
14 float range = 10.0; // scan range in meters
15 float rate = 10.0; // scan rate in seconds
16
17 default
18 {
20 {
21 owner = llGetOwner();
22 llSensorRepeat("", "", AGENT_BY_USERNAME, range, PI, rate);
23 }
24
25 on_rez(integer start_param)
26 {
28 }
29
30 sensor(integer total_number)
31 {
32 rate = 60.0;
33 llMessageLinked(LINK_THIS, number, "on", owner);
35 llSensorRepeat("", "", AGENT_BY_USERNAME, range, PI, rate);
36 }
37
38 no_sensor()
39 {
40 rate = 10.0;
41 llMessageLinked(LINK_THIS, number, "off", owner);
43 llSensorRepeat("", "", AGENT_BY_USERNAME, range, PI, rate);
44 }
45 }

Rene Free Lighting System

Particle Plugin "Bling"

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

1 // :LICENSE: CC0 (Public Domain)
2
3 // Rene's Free Lighting System - Particle Plugin "Bling"
4 //
5 // Author: Rene10957 Resident
6 // Date: 21-03-2014
7
8 ////////////////////////////////////////////////////////////////////////////////
9 // HOW TO USE: drop this script into the same prim where the LIGHT is located //
10 ////////////////////////////////////////////////////////////////////////////////
11
12 string title = "Particle Plugin"; // title
13 string name = "Bling"; // name
14 string version = "1.4"; // version
15 integer silent = TRUE; // silent startup
16
17 // Constants
18
19 // Note: the official upper limit for particles is 4.0 meters but for more delicate particle effects
20 // it can be useful to set maxScale to a lower value, in order to achieve more fine-grained control.
21
22 integer particleChannel = -75901; // particle channel
23 integer feedbackChannel = -57910; // feedback channel
24 float minScale = 0.03125; // min. startScale or endScale
25 float maxScale = 2.0; // max. startScale or endScale
26
27 // Particle parameters
28
29 // Note: startScale and endScale are not actual sizes, but more like aspect ratios.
30 // The real size is determined by particleSize in the notecard, a percentage of maxScale.
31
32 float age = 0.3; // particle lifetime
33 float rate = 5.0; // particle burst rate
34 integer count = 1; // particle count
35 vector startScale = <0.2, 0.04, 0.0>; // particle start size
36 vector endScale = <0.0, 0.2, 0.0>; // particle end size
37 float minSpeed = 0.1; // particle min. burst speed
38 float maxSpeed = 0.1; // particle max. burst speed
39 float burstRadius = 0.0; // particle burst radius
40 vector partAccel = <0.0, 0.0, 0.5>; // particle accelleration
41
42 // Variables
43
44 float particleSize; // particle size (percentage)
45 float defParticleSize; // default particle size (percentage)
46 float minParticleSize; // minimum particle size (percentage)
47
48 // Functions
49
50 startParticles(vector color, vector start, vector end, float min, float max, float radius, vector push, string txtr)
51 {
66 PSYS_SRC_ACCEL, push,
67 PSYS_SRC_TEXTURE, txtr,
69 0 |
76 }
77
78 /////////////////////////////////////////////////////////////////
79 // From this point onwards, every particle script is identical //
80 /////////////////////////////////////////////////////////////////
81
82 // Particle size = largest dimension across both scale vectors
83
84 float getParticleSize (vector start, vector end)
85 {
86 float max = 0.0;
87 if(start.x > max) max = start.x;
88 if(start.y > max) max = start.y;
89 if(end.x > max) max = end.x;
90 if(end.y > max) max = end.y;
91 return max / (maxScale / 100.0);
92 }
93
94 // Particle size is too small if both start.x and end.x < minScale (0.03125), or...
95 // both start.y and end.y < minScale (0.03125)
96
97 float getMinSize (vector start, vector end, float size)
98 {
99 float maxX = 0.0;
100 float maxY = 0.0;
101 float minXY = 0.0;
102
103 if(start.x < minScale && end.x < minScale) {
104 if(start.x > end.x) maxX = start.x;
105 else maxX = end.x;
106 }
107
108 if(start.y < minScale && end.y < minScale) {
109 if(start.y > end.y) maxY = start.y;
110 else maxY = end.y;
111 }
112
113 if(maxX == 0.0 && maxY == 0.0) return size;
114
115 if(maxX == 0.0) minXY = maxY;
116 else if(maxY == 0.0) minXY = maxX;
117 else if(maxX < maxY) minXY = maxX;
118 else minXY = maxY;
119
120 return (float)llCeil((minScale / minXY) * size);
121 }
122
123 unpackMessage(string msg)
124 {
125 list msgList = llCSV2List(msg);
126
127 integer on = (integer)llList2String(msgList, 0); // particles on/off
128 vector color = (vector)llList2String(msgList, 1); // particle color
129 float size = (float)llList2String(msgList, 2); // particle size (%) from notecard
130 float inc = (float)llList2String(msgList, 3); // particle increase/decrease (%) from menu
131 string texture = llList2String(msgList, 4); // particle texture from notecard
132
133 if(inc == 999) particleSize = size; // reset particle size
134 else particleSize += inc; // increase/decrease particle size
135 if(particleSize < 1) particleSize = 1; // correct if size < 1%
136 else if(particleSize > 100) particleSize = 100; // correct if size > 100%
137 if(particleSize < minParticleSize) particleSize = minParticleSize; // correct undersized particles
138
139 if(on) {
140 vector start = startScale / defParticleSize * particleSize; // start scale
141 vector end = endScale / defParticleSize * particleSize; // end scale
142 float min = minSpeed / defParticleSize * particleSize; // equally resize min. burst speed
143 float max = maxSpeed / defParticleSize * particleSize; // equally resize max. burst speed
144 float radius = burstRadius / defParticleSize * particleSize; // equally resize burst radius
145 vector push = partAccel / defParticleSize * particleSize; // equally resize accelleration
146 startParticles(color, start, end, min, max, radius, push, texture);
147 }
148 else {
150 }
151 }
152
153 default
154 {
156 {
157 defParticleSize = getParticleSize(startScale, endScale); // default particle size (percentage)
158 vector start = startScale / defParticleSize; // start scale = 1%
159 vector end = endScale / defParticleSize; // end scale = 1%
160 minParticleSize = getMinSize(start, end, 1.0); // minimum particle size (percentage)
161 if(!silent) llWhisper(0, title + " \"" + name + "\" " + version + " ready");
162 llMessageLinked(LINK_THIS, feedbackChannel, "READY", ""); // request particle info from light script
163 }
164
165 on_rez(integer start_param)
166 {
168 }
169
170 link_message(integer sender_number, integer number, string msg, key id)
171 {
172 if(number == particleChannel) unpackMessage(msg);
173 }
174 }

Rene Free Lighting System

Particle Plugin "Candle flame dirty wick"

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

1 // :LICENSE: CC0 (Public Domain)
2 // Rene's Free Lighting System - Particle Plugin "Candle flame dirty wick"
3 //
4 // Author: Rene10957 Resident
5 // Date: 21-03-2014
6
7 ////////////////////////////////////////////////////////////////////////////////
8 // HOW TO USE: drop this script into the same prim where the LIGHT is located //
9 ////////////////////////////////////////////////////////////////////////////////
10
11 string title = "Particle Plugin"; // title
12 string name = "Candle flame dirty wick"; // name
13 string version = "1.4"; // version
14 integer silent = TRUE; // silent startup
15
16 // Constants
17
18 // Note: the official upper limit for particles is 4.0 meters but for more delicate particle effects
19 // it can be useful to set maxScale to a lower value, in order to achieve more fine-grained control.
20
21 integer particleChannel = -75901; // particle channel
22 integer feedbackChannel = -57910; // feedback channel
23 float minScale = 0.03125; // min. startScale or endScale
24 float maxScale = 0.4; // max. startScale or endScale
25
26 // Particle parameters
27
28 // Note: startScale and endScale are not actual sizes, but more like aspect ratios.
29 // The real size is determined by particleSize in the notecard, a percentage of maxScale.
30
31 float age = 1.0; // particle lifetime
32 float rate = 0.01; // particle burst rate
33 integer count = 1; // particle count
34 vector startScale = <0.05, 0.1, 0.0>; // particle start size
35 vector endScale = <0.0, 0.0, 0.0>; // particle end size
36 float minSpeed = 0.02; // particle min. burst speed
37 float maxSpeed = 0.25; // particle max. burst speed
38 float burstRadius = 0.0; // particle burst radius
39 vector partAccel = <0.0, 0.0, 0.0>; // particle accelleration
40
41 // Variables
42
43 float particleSize; // particle size (percentage)
44 float defParticleSize; // default particle size (percentage)
45 float minParticleSize; // minimum particle size (percentage)
46
47 // Functions
48
49 startParticles(vector color, vector start, vector end, float min, float max, float radius, vector push, string txtr)
50 {
54 PSYS_PART_END_COLOR, <1.0, 0.25, 0.0>,
65 PSYS_SRC_ACCEL, push,
66 PSYS_SRC_OMEGA, <0.02, 0.02, 2.0>,
67 PSYS_SRC_TEXTURE, txtr,
69 0 |
75 }
76
77 /////////////////////////////////////////////////////////////////
78 // From this point onwards, every particle script is identical //
79 /////////////////////////////////////////////////////////////////
80
81 // Particle size = largest dimension across both scale vectors
82
83 float getParticleSize (vector start, vector end)
84 {
85 float max = 0.0;
86 if(start.x > max) max = start.x;
87 if(start.y > max) max = start.y;
88 if(end.x > max) max = end.x;
89 if(end.y > max) max = end.y;
90 return max / (maxScale / 100.0);
91 }
92
93 // Particle size is too small if both start.x and end.x < minScale (0.03125), or...
94 // both start.y and end.y < minScale (0.03125)
95
96 float getMinSize (vector start, vector end, float size)
97 {
98 float maxX = 0.0;
99 float maxY = 0.0;
100 float minXY = 0.0;
101
102 if(start.x < minScale && end.x < minScale) {
103 if(start.x > end.x) maxX = start.x;
104 else maxX = end.x;
105 }
106
107 if(start.y < minScale && end.y < minScale) {
108 if(start.y > end.y) maxY = start.y;
109 else maxY = end.y;
110 }
111
112 if(maxX == 0.0 && maxY == 0.0) return size;
113
114 if(maxX == 0.0) minXY = maxY;
115 else if(maxY == 0.0) minXY = maxX;
116 else if(maxX < maxY) minXY = maxX;
117 else minXY = maxY;
118
119 return (float)llCeil((minScale / minXY) * size);
120 }
121
122 unpackMessage(string msg)
123 {
124 list msgList = llCSV2List(msg);
125
126 integer on = (integer)llList2String(msgList, 0); // particles on/off
127 vector color = (vector)llList2String(msgList, 1); // particle color
128 float size = (float)llList2String(msgList, 2); // particle size (%) from notecard
129 float inc = (float)llList2String(msgList, 3); // particle increase/decrease (%) from menu
130 string texture = llList2String(msgList, 4); // particle texture from notecard
131
132 if(inc == 999) particleSize = size; // reset particle size
133 else particleSize += inc; // increase/decrease particle size
134 if(particleSize < 1) particleSize = 1; // correct if size < 1%
135 else if(particleSize > 100) particleSize = 100; // correct if size > 100%
136 if(particleSize < minParticleSize) particleSize = minParticleSize; // correct undersized particles
137
138 if(on) {
139 vector start = startScale / defParticleSize * particleSize; // start scale
140 vector end = endScale / defParticleSize * particleSize; // end scale
141 float min = minSpeed / defParticleSize * particleSize; // equally resize min. burst speed
142 float max = maxSpeed / defParticleSize * particleSize; // equally resize max. burst speed
143 float radius = burstRadius / defParticleSize * particleSize; // equally resize burst radius
144 vector push = partAccel / defParticleSize * particleSize; // equally resize accelleration
145 startParticles(color, start, end, min, max, radius, push, texture);
146 }
147 else {
149 }
150 }
151
152 default
153 {
155 {
156 defParticleSize = getParticleSize(startScale, endScale); // default particle size (percentage)
157 vector start = startScale / defParticleSize; // start scale = 1%
158 vector end = endScale / defParticleSize; // end scale = 1%
159 minParticleSize = getMinSize(start, end, 1.0); // minimum particle size (percentage)
160 if(!silent) llWhisper(0, title + " \"" + name + "\" " + version + " ready");
161 llMessageLinked(LINK_THIS, feedbackChannel, "READY", ""); // request particle info from light script
162 }
163
164 on_rez(integer start_param)
165 {
167 }
168
169 link_message(integer sender_number, integer number, string msg, key id)
170 {
171 if(number == particleChannel) unpackMessage(msg);
172 }
173 }

Rene Free Lighting System

- Particle Plugin "Candle flame sensual"

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

1 // :LICENSE: CC0 (Public Domain)
2 // Rene's Free Lighting System - Particle Plugin "Candle flame sensual"
3 //
4 // Author: Rene10957 Resident
5 // Date: 21-03-2014
6
7 ////////////////////////////////////////////////////////////////////////////////
8 // HOW TO USE: drop this script into the same prim where the LIGHT is located //
9 ////////////////////////////////////////////////////////////////////////////////
10
11 string title = "Particle Plugin"; // title
12 string name = "Candle flame sensual"; // name
13 string version = "1.4"; // version
14 integer silent = TRUE; // silent startup
15
16 // Constants
17
18 // Note: the official upper limit for particles is 4.0 meters but for more delicate particle effects
19 // it can be useful to set maxScale to a lower value, in order to achieve more fine-grained control.
20
21 integer particleChannel = -75901; // particle channel
22 integer feedbackChannel = -57910; // feedback channel
23 float minScale = 0.03125; // min. startScale or endScale
24 float maxScale = 0.4; // max. startScale or endScale
25
26 // Particle parameters
27
28 // Note: startScale and endScale are not actual sizes, but more like aspect ratios.
29 // The real size is determined by particleSize in the notecard, a percentage of maxScale.
30
31 float age = 1.0; // particle lifetime
32 float rate = 0.01; // particle burst rate
33 integer count = 1; // particle count
34 vector startScale = <0.05, 0.1, 0.0>; // particle start size
35 vector endScale = <0.0, 0.0, 0.0>; // particle end size
36 float minSpeed = 0.1; // particle min. burst speed
37 float maxSpeed = 0.1; // particle max. burst speed
38 float burstRadius = 0.0; // particle burst radius
39 vector partAccel = <0.0, 0.0, 0.0>; // particle accelleration
40
41 // Variables
42
43 float particleSize; // particle size (percentage)
44 float defParticleSize; // default particle size (percentage)
45 float minParticleSize; // minimum particle size (percentage)
46
47 // Functions
48
49 startParticles(vector color, vector start, vector end, float min, float max, float radius, vector push, string txtr)
50 {
54 PSYS_PART_END_COLOR, <1.0, 0.25, 0.0>,
65 PSYS_SRC_ACCEL, push,
66 PSYS_SRC_OMEGA, <0.02, 0.02, 0.4>,
67 PSYS_SRC_TEXTURE, txtr,
69 0 |
75 }
76
77 /////////////////////////////////////////////////////////////////
78 // From this point onwards, every particle script is identical //
79 /////////////////////////////////////////////////////////////////
80
81 // Particle size = largest dimension across both scale vectors
82
83 float getParticleSize (vector start, vector end)
84 {
85 float max = 0.0;
86 if(start.x > max) max = start.x;
87 if(start.y > max) max = start.y;
88 if(end.x > max) max = end.x;
89 if(end.y > max) max = end.y;
90 return max / (maxScale / 100.0);
91 }
92
93 // Particle size is too small if both start.x and end.x < minScale (0.03125), or...
94 // both start.y and end.y < minScale (0.03125)
95
96 float getMinSize (vector start, vector end, float size)
97 {
98 float maxX = 0.0;
99 float maxY = 0.0;
100 float minXY = 0.0;
101
102 if(start.x < minScale && end.x < minScale) {
103 if(start.x > end.x) maxX = start.x;
104 else maxX = end.x;
105 }
106
107 if(start.y < minScale && end.y < minScale) {
108 if(start.y > end.y) maxY = start.y;
109 else maxY = end.y;
110 }
111
112 if(maxX == 0.0 && maxY == 0.0) return size;
113
114 if(maxX == 0.0) minXY = maxY;
115 else if(maxY == 0.0) minXY = maxX;
116 else if(maxX < maxY) minXY = maxX;
117 else minXY = maxY;
118
119 return (float)llCeil((minScale / minXY) * size);
120 }
121
122 unpackMessage(string msg)
123 {
124 list msgList = llCSV2List(msg);
125
126 integer on = (integer)llList2String(msgList, 0); // particles on/off
127 vector color = (vector)llList2String(msgList, 1); // particle color
128 float size = (float)llList2String(msgList, 2); // particle size (%) from notecard
129 float inc = (float)llList2String(msgList, 3); // particle increase/decrease (%) from menu
130 string texture = llList2String(msgList, 4); // particle texture from notecard
131
132 if(inc == 999) particleSize = size; // reset particle size
133 else particleSize += inc; // increase/decrease particle size
134 if(particleSize < 1) particleSize = 1; // correct if size < 1%
135 else if(particleSize > 100) particleSize = 100; // correct if size > 100%
136 if(particleSize < minParticleSize) particleSize = minParticleSize; // correct undersized particles
137
138 if(on) {
139 vector start = startScale / defParticleSize * particleSize; // start scale
140 vector end = endScale / defParticleSize * particleSize; // end scale
141 float min = minSpeed / defParticleSize * particleSize; // equally resize min. burst speed
142 float max = maxSpeed / defParticleSize * particleSize; // equally resize max. burst speed
143 float radius = burstRadius / defParticleSize * particleSize; // equally resize burst radius
144 vector push = partAccel / defParticleSize * particleSize; // equally resize accelleration
145 startParticles(color, start, end, min, max, radius, push, texture);
146 }
147 else {
149 }
150 }
151
152 default
153 {
155 {
156 defParticleSize = getParticleSize(startScale, endScale); // default particle size (percentage)
157 vector start = startScale / defParticleSize; // start scale = 1%
158 vector end = endScale / defParticleSize; // end scale = 1%
159 minParticleSize = getMinSize(start, end, 1.0); // minimum particle size (percentage)
160 if(!silent) llWhisper(0, title + " \"" + name + "\" " + version + " ready");
161 llMessageLinked(LINK_THIS, feedbackChannel, "READY", ""); // request particle info from light script
162 }
163
164 on_rez(integer start_param)
165 {
167 }
168
169 link_message(integer sender_number, integer number, string msg, key id)
170 {
171 if(number == particleChannel) unpackMessage(msg);
172 }
173 }

Rene Free Lighting System

- Particle Plugin "Candle flame simple"

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

1 // :LICENSE: CC0 (Public Domain)
2
3 // Rene's Free Lighting System - Particle Plugin "Candle flame simple"
4 //
5 // Author: Rene10957 Resident
6 // Date: 21-03-2014
7
8 ////////////////////////////////////////////////////////////////////////////////
9 // HOW TO USE: drop this script into the same prim where the LIGHT is located //
10 ////////////////////////////////////////////////////////////////////////////////
11
12 string title = "Particle Plugin"; // title
13 string name = "Candle flame simple"; // name
14 string version = "1.4"; // version
15 integer silent = TRUE; // silent startup
16
17 // Constants
18
19 // Note: the official upper limit for particles is 4.0 meters but for more delicate particle effects
20 // it can be useful to set maxScale to a lower value, in order to achieve more fine-grained control.
21
22 integer particleChannel = -75901; // particle channel
23 integer feedbackChannel = -57910; // feedback channel
24 float minScale = 0.03125; // min. startScale or endScale
25 float maxScale = 0.4; // max. startScale or endScale
26
27 // Particle parameters
28
29 // Note: startScale and endScale are not actual sizes, but more like aspect ratios.
30 // The real size is determined by particleSize in the notecard, a percentage of maxScale.
31
32 float age = 1.0; // particle lifetime
33 float rate = 0.01; // particle burst rate
34 integer count = 1; // particle count
35 vector startScale = <0.05, 0.1, 0.0>; // particle start size
36 vector endScale = <0.0, 0.0, 0.0>; // particle end size
37 float minSpeed = 0.1; // particle min. burst speed
38 float maxSpeed = 0.1; // particle max. burst speed
39 float burstRadius = 0.0; // particle burst radius
40 vector partAccel = <0.0, 0.0, 0.0>; // particle accelleration
41
42 // Variables
43
44 float particleSize; // particle size (percentage)
45 float defParticleSize; // default particle size (percentage)
46 float minParticleSize; // minimum particle size (percentage)
47
48 // Functions
49
50 startParticles(vector color, vector start, vector end, float min, float max, float radius, vector push, string txtr)
51 {
55 PSYS_PART_END_COLOR, <1.0, 0.25, 0.0>,
66 PSYS_SRC_ACCEL, push,
67 PSYS_SRC_OMEGA, <0.01, 0.01, 0.2>,
68 PSYS_SRC_TEXTURE, txtr,
70 0 |
76 }
77
78 /////////////////////////////////////////////////////////////////
79 // From this point onwards, every particle script is identical //
80 /////////////////////////////////////////////////////////////////
81
82 // Particle size = largest dimension across both scale vectors
83
84 float getParticleSize (vector start, vector end)
85 {
86 float max = 0.0;
87 if(start.x > max) max = start.x;
88 if(start.y > max) max = start.y;
89 if(end.x > max) max = end.x;
90 if(end.y > max) max = end.y;
91 return max / (maxScale / 100.0);
92 }
93
94 // Particle size is too small if both start.x and end.x < minScale (0.03125), or...
95 // both start.y and end.y < minScale (0.03125)
96
97 float getMinSize (vector start, vector end, float size)
98 {
99 float maxX = 0.0;
100 float maxY = 0.0;
101 float minXY = 0.0;
102
103 if(start.x < minScale && end.x < minScale) {
104 if(start.x > end.x) maxX = start.x;
105 else maxX = end.x;
106 }
107
108 if(start.y < minScale && end.y < minScale) {
109 if(start.y > end.y) maxY = start.y;
110 else maxY = end.y;
111 }
112
113 if(maxX == 0.0 && maxY == 0.0) return size;
114
115 if(maxX == 0.0) minXY = maxY;
116 else if(maxY == 0.0) minXY = maxX;
117 else if(maxX < maxY) minXY = maxX;
118 else minXY = maxY;
119
120 return (float)llCeil((minScale / minXY) * size);
121 }
122
123 unpackMessage(string msg)
124 {
125 list msgList = llCSV2List(msg);
126
127 integer on = (integer)llList2String(msgList, 0); // particles on/off
128 vector color = (vector)llList2String(msgList, 1); // particle color
129 float size = (float)llList2String(msgList, 2); // particle size (%) from notecard
130 float inc = (float)llList2String(msgList, 3); // particle increase/decrease (%) from menu
131 string texture = llList2String(msgList, 4); // particle texture from notecard
132
133 if(inc == 999) particleSize = size; // reset particle size
134 else particleSize += inc; // increase/decrease particle size
135 if(particleSize < 1) particleSize = 1; // correct if size < 1%
136 else if(particleSize > 100) particleSize = 100; // correct if size > 100%
137 if(particleSize < minParticleSize) particleSize = minParticleSize; // correct undersized particles
138
139 if(on) {
140 vector start = startScale / defParticleSize * particleSize; // start scale
141 vector end = endScale / defParticleSize * particleSize; // end scale
142 float min = minSpeed / defParticleSize * particleSize; // equally resize min. burst speed
143 float max = maxSpeed / defParticleSize * particleSize; // equally resize max. burst speed
144 float radius = burstRadius / defParticleSize * particleSize; // equally resize burst radius
145 vector push = partAccel / defParticleSize * particleSize; // equally resize accelleration
146 startParticles(color, start, end, min, max, radius, push, texture);
147 }
148 else {
150 }
151 }
152
153 default
154 {
156 {
157 defParticleSize = getParticleSize(startScale, endScale); // default particle size (percentage)
158 vector start = startScale / defParticleSize; // start scale = 1%
159 vector end = endScale / defParticleSize; // end scale = 1%
160 minParticleSize = getMinSize(start, end, 1.0); // minimum particle size (percentage)
161 if(!silent) llWhisper(0, title + " \"" + name + "\" " + version + " ready");
162 llMessageLinked(LINK_THIS, feedbackChannel, "READY", ""); // request particle info from light script
163 }
164
165 on_rez(integer start_param)
166 {
168 }
169
170 link_message(integer sender_number, integer number, string msg, key id)
171 {
172 if(number == particleChannel) unpackMessage(msg);
173 }
174 }

Rene Free Lighting System

- Particle Plugin "Fire"

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

1 // :LICENSE: CC0 (Public Domain)
2 // Rene's Free Lighting System - Particle Plugin "Fire"
3 //
4 // Author: Rene10957 Resident
5 // Date: 21-03-2014
6
7 ////////////////////////////////////////////////////////////////////////////////
8 // HOW TO USE: drop this script into the same prim where the LIGHT is located //
9 ////////////////////////////////////////////////////////////////////////////////
10
11 string title = "Particle Plugin"; // title
12 string name = "Fire"; // name
13 string version = "1.4"; // version
14 integer silent = TRUE; // silent startup
15
16 // Constants
17
18 // Note: the official upper limit for particles is 4.0 meters but for more delicate particle effects
19 // it can be useful to set maxScale to a lower value, in order to achieve more fine-grained control.
20
21 integer particleChannel = -75901; // particle channel
22 integer feedbackChannel = -57910; // feedback channel
23 float minScale = 0.03125; // min. startScale or endScale
24 float maxScale = 1.0; // max. startScale or endScale
25
26 // Particle parameters
27
28 // Note: startScale and endScale are not actual sizes, but more like aspect ratios.
29 // The real size is determined by particleSize in the notecard, a percentage of maxScale.
30
31 float age = 1.0; // particle lifetime
32 float rate = 0.1; // particle burst rate
33 integer count = 10; // particle count
34 vector startScale = <0.1, 0.5, 0.0>; // particle start size
35 vector endScale = <0.1, 0.5, 0.0>; // particle end size
36 float minSpeed = 0.0; // particle min. burst speed
37 float maxSpeed = 0.01; // particle max. burst speed
38 float burstRadius = 0.1; // particle burst radius
39 vector partAccel = <0.0, 0.0, 2.5>; // particle accelleration
40
41 // Variables
42
43 float particleSize; // particle size (percentage)
44 float defParticleSize; // default particle size (percentage)
45 float minParticleSize; // minimum particle size (percentage)
46
47 // Functions
48
49 startParticles(vector color, vector start, vector end, float min, float max, float radius, vector push, string txtr)
50 {
54 PSYS_PART_END_COLOR, <1.0, 0.0, 0.0>,
65 PSYS_SRC_ACCEL, push,
66 PSYS_SRC_TEXTURE, txtr,
68 0 |
72 }
73
74 /////////////////////////////////////////////////////////////////
75 // From this point onwards, every particle script is identical //
76 /////////////////////////////////////////////////////////////////
77
78 // Particle size = largest dimension across both scale vectors
79
80 float getParticleSize (vector start, vector end)
81 {
82 float max = 0.0;
83 if(start.x > max) max = start.x;
84 if(start.y > max) max = start.y;
85 if(end.x > max) max = end.x;
86 if(end.y > max) max = end.y;
87 return max / (maxScale / 100.0);
88 }
89
90 // Particle size is too small if both start.x and end.x < minScale (0.03125), or...
91 // both start.y and end.y < minScale (0.03125)
92
93 float getMinSize (vector start, vector end, float size)
94 {
95 float maxX = 0.0;
96 float maxY = 0.0;
97 float minXY = 0.0;
98
99 if(start.x < minScale && end.x < minScale) {
100 if(start.x > end.x) maxX = start.x;
101 else maxX = end.x;
102 }
103
104 if(start.y < minScale && end.y < minScale) {
105 if(start.y > end.y) maxY = start.y;
106 else maxY = end.y;
107 }
108
109 if(maxX == 0.0 && maxY == 0.0) return size;
110
111 if(maxX == 0.0) minXY = maxY;
112 else if(maxY == 0.0) minXY = maxX;
113 else if(maxX < maxY) minXY = maxX;
114 else minXY = maxY;
115
116 return (float)llCeil((minScale / minXY) * size);
117 }
118
119 unpackMessage(string msg)
120 {
121 list msgList = llCSV2List(msg);
122
123 integer on = (integer)llList2String(msgList, 0); // particles on/off
124 vector color = (vector)llList2String(msgList, 1); // particle color
125 float size = (float)llList2String(msgList, 2); // particle size (%) from notecard
126 float inc = (float)llList2String(msgList, 3); // particle increase/decrease (%) from menu
127 string texture = llList2String(msgList, 4); // particle texture from notecard
128
129 if(inc == 999) particleSize = size; // reset particle size
130 else particleSize += inc; // increase/decrease particle size
131 if(particleSize < 1) particleSize = 1; // correct if size < 1%
132 else if(particleSize > 100) particleSize = 100; // correct if size > 100%
133 if(particleSize < minParticleSize) particleSize = minParticleSize; // correct undersized particles
134
135 if(on) {
136 vector start = startScale / defParticleSize * particleSize; // start scale
137 vector end = endScale / defParticleSize * particleSize; // end scale
138 float min = minSpeed / defParticleSize * particleSize; // equally resize min. burst speed
139 float max = maxSpeed / defParticleSize * particleSize; // equally resize max. burst speed
140 float radius = burstRadius / defParticleSize * particleSize; // equally resize burst radius
141 vector push = partAccel / defParticleSize * particleSize; // equally resize accelleration
142 startParticles(color, start, end, min, max, radius, push, texture);
143 }
144 else {
146 }
147 }
148
149 default
150 {
152 {
153 defParticleSize = getParticleSize(startScale, endScale); // default particle size (percentage)
154 vector start = startScale / defParticleSize; // start scale = 1%
155 vector end = endScale / defParticleSize; // end scale = 1%
156 minParticleSize = getMinSize(start, end, 1.0); // minimum particle size (percentage)
157 if(!silent) llWhisper(0, title + " \"" + name + "\" " + version + " ready");
158 llMessageLinked(LINK_THIS, feedbackChannel, "READY", ""); // request particle info from light script
159 }
160
161 on_rez(integer start_param)
162 {
164 }
165
166 link_message(integer sender_number, integer number, string msg, key id)
167 {
168 if(number == particleChannel) unpackMessage(msg);
169 }
170 }

Rene Free Lighting System

- Particle Plugin "Halo"

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

1 // :LICENSE: CC0 (Public Domain)
2
3 // Rene's Free Lighting System - Particle Plugin "Halo"
4 //
5 // Author: Rene10957 Resident
6 // Date: 21-03-2014
7
8 ////////////////////////////////////////////////////////////////////////////////
9 // HOW TO USE: drop this script into the same prim where the LIGHT is located //
10 ////////////////////////////////////////////////////////////////////////////////
11
12 string title = "Particle Plugin"; // title
13 string name = "Halo"; // name
14 string version = "1.4"; // version
15 integer silent = TRUE; // silent startup
16
17 // Constants
18
19 // Note: the official upper limit for particles is 4.0 meters but for more delicate particle effects
20 // it can be useful to set maxScale to a lower value, in order to achieve more fine-grained control.
21
22 integer particleChannel = -75901; // particle channel
23 integer feedbackChannel = -57910; // feedback channel
24 float minScale = 0.03125; // min. startScale or endScale
25 float maxScale = 4.0; // max. startScale or endScale
26
27 // Particle parameters
28
29 // Note: startScale and endScale are not actual sizes, but more like aspect ratios.
30 // The real size is determined by particleSize in the notecard, a percentage of maxScale.
31
32 float age = 1.5; // particle lifetime
33 float rate = 0.05; // particle burst rate
34 integer count = 1; // particle count
35 vector startScale = <0.0, 0.0, 0.0>; // particle start size
36 vector endScale = <2.0, 2.0, 0.0>; // particle end size
37 float minSpeed = 0.0; // particle min. burst speed
38 float maxSpeed = 0.0; // particle max. burst speed
39 float burstRadius = 0.0; // particle burst radius
40 vector partAccel = <0.0, 0.0, 0.0>; // particle accelleration
41
42 // Variables
43
44 float particleSize; // particle size (percentage)
45 float defParticleSize; // default particle size (percentage)
46 float minParticleSize; // minimum particle size (percentage)
47
48 // Functions
49
50 startParticles(vector color, vector start, vector end, float min, float max, float radius, vector push, string txtr)
51 {
66 PSYS_SRC_ACCEL, push,
67 PSYS_SRC_TEXTURE, txtr,
69 0 |
74 }
75
76 /////////////////////////////////////////////////////////////////
77 // From this point onwards, every particle script is identical //
78 /////////////////////////////////////////////////////////////////
79
80 // Particle size = largest dimension across both scale vectors
81
82 float getParticleSize (vector start, vector end)
83 {
84 float max = 0.0;
85 if(start.x > max) max = start.x;
86 if(start.y > max) max = start.y;
87 if(end.x > max) max = end.x;
88 if(end.y > max) max = end.y;
89 return max / (maxScale / 100.0);
90 }
91
92 // Particle size is too small if both start.x and end.x < minScale (0.03125), or...
93 // both start.y and end.y < minScale (0.03125)
94
95 float getMinSize (vector start, vector end, float size)
96 {
97 float maxX = 0.0;
98 float maxY = 0.0;
99 float minXY = 0.0;
100
101 if(start.x < minScale && end.x < minScale) {
102 if(start.x > end.x) maxX = start.x;
103 else maxX = end.x;
104 }
105
106 if(start.y < minScale && end.y < minScale) {
107 if(start.y > end.y) maxY = start.y;
108 else maxY = end.y;
109 }
110
111 if(maxX == 0.0 && maxY == 0.0) return size;
112
113 if(maxX == 0.0) minXY = maxY;
114 else if(maxY == 0.0) minXY = maxX;
115 else if(maxX < maxY) minXY = maxX;
116 else minXY = maxY;
117
118 return (float)llCeil((minScale / minXY) * size);
119 }
120
121 unpackMessage(string msg)
122 {
123 list msgList = llCSV2List(msg);
124
125 integer on = (integer)llList2String(msgList, 0); // particles on/off
126 vector color = (vector)llList2String(msgList, 1); // particle color
127 float size = (float)llList2String(msgList, 2); // particle size (%) from notecard
128 float inc = (float)llList2String(msgList, 3); // particle increase/decrease (%) from menu
129 string texture = llList2String(msgList, 4); // particle texture from notecard
130
131 if(inc == 999) particleSize = size; // reset particle size
132 else particleSize += inc; // increase/decrease particle size
133 if(particleSize < 1) particleSize = 1; // correct if size < 1%
134 else if(particleSize > 100) particleSize = 100; // correct if size > 100%
135 if(particleSize < minParticleSize) particleSize = minParticleSize; // correct undersized particles
136
137 if(on) {
138 vector start = startScale / defParticleSize * particleSize; // start scale
139 vector end = endScale / defParticleSize * particleSize; // end scale
140 float min = minSpeed / defParticleSize * particleSize; // equally resize min. burst speed
141 float max = maxSpeed / defParticleSize * particleSize; // equally resize max. burst speed
142 float radius = burstRadius / defParticleSize * particleSize; // equally resize burst radius
143 vector push = partAccel / defParticleSize * particleSize; // equally resize accelleration
144 startParticles(color, start, end, min, max, radius, push, texture);
145 }
146 else {
148 }
149 }
150
151 default
152 {
154 {
155 defParticleSize = getParticleSize(startScale, endScale); // default particle size (percentage)
156 vector start = startScale / defParticleSize; // start scale = 1%
157 vector end = endScale / defParticleSize; // end scale = 1%
158 minParticleSize = getMinSize(start, end, 1.0); // minimum particle size (percentage)
159 if(!silent) llWhisper(0, title + " \"" + name + "\" " + version + " ready");
160 llMessageLinked(LINK_THIS, feedbackChannel, "READY", ""); // request particle info from light script
161 }
162
163 on_rez(integer start_param)
164 {
166 }
167
168 link_message(integer sender_number, integer number, string msg, key id)
169 {
170 if(number == particleChannel) unpackMessage(msg);
171 }
172 }

Rene Free Lighting System

- Particle Plugin "Starbling"

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

1 // :LICENSE: CC0 (Public Domain)
2
3 // Rene's Free Lighting System - Particle Plugin "Starbling"
4 //
5 // Author: Rene10957 Resident
6 // Date: 21-03-2014
7
8 ////////////////////////////////////////////////////////////////////////////////
9 // HOW TO USE: drop this script into the same prim where the LIGHT is located //
10 ////////////////////////////////////////////////////////////////////////////////
11
12 string title = "Particle Plugin"; // title
13 string name = "Starbling"; // name
14 string version = "1.4"; // version
15 integer silent = TRUE; // silent startup
16
17 // Constants
18
19 // Note: the official upper limit for particles is 4.0 meters but for more delicate particle effects
20 // it can be useful to set maxScale to a lower value, in order to achieve more fine-grained control.
21
22 integer particleChannel = -75901; // particle channel
23 integer feedbackChannel = -57910; // feedback channel
24 float minScale = 0.03125; // min. startScale or endScale
25 float maxScale = 4.0; // max. startScale or endScale
26
27 // Particle parameters
28
29 // Note: startScale and endScale are not actual sizes, but more like aspect ratios.
30 // The real size is determined by particleSize in the notecard, a percentage of maxScale.
31
32 float age = 1.0; // particle lifetime
33 float rate = 5.0; // particle burst rate
34 integer count = 25; // particle count
35 vector startScale = <0.1, 1.0, 0.0>; // particle start size
36 vector endScale = <0.1, 1.0, 0.0>; // particle end size
37 float minSpeed = 0.1; // particle min. burst speed
38 float maxSpeed = 0.1; // particle max. burst speed
39 float burstRadius = 0.0; // particle burst radius
40 vector partAccel = <0.0, 0.0, 0.0>; // particle accelleration
41
42 // Variables
43
44 float particleSize; // particle size (percentage)
45 float defParticleSize; // default particle size (percentage)
46 float minParticleSize; // minimum particle size (percentage)
47
48 // Functions
49
50 startParticles(vector color, vector start, vector end, float min, float max, float radius, vector push, string txtr)
51 {
66 PSYS_SRC_ACCEL, push,
67 PSYS_SRC_TEXTURE, txtr,
69 0 |
75 }
76
77 /////////////////////////////////////////////////////////////////
78 // From this point onwards, every particle script is identical //
79 /////////////////////////////////////////////////////////////////
80
81 // Particle size = largest dimension across both scale vectors
82
83 float getParticleSize (vector start, vector end)
84 {
85 float max = 0.0;
86 if(start.x > max) max = start.x;
87 if(start.y > max) max = start.y;
88 if(end.x > max) max = end.x;
89 if(end.y > max) max = end.y;
90 return max / (maxScale / 100.0);
91 }
92
93 // Particle size is too small if both start.x and end.x < minScale (0.03125), or...
94 // both start.y and end.y < minScale (0.03125)
95
96 float getMinSize (vector start, vector end, float size)
97 {
98 float maxX = 0.0;
99 float maxY = 0.0;
100 float minXY = 0.0;
101
102 if(start.x < minScale && end.x < minScale) {
103 if(start.x > end.x) maxX = start.x;
104 else maxX = end.x;
105 }
106
107 if(start.y < minScale && end.y < minScale) {
108 if(start.y > end.y) maxY = start.y;
109 else maxY = end.y;
110 }
111
112 if(maxX == 0.0 && maxY == 0.0) return size;
113
114 if(maxX == 0.0) minXY = maxY;
115 else if(maxY == 0.0) minXY = maxX;
116 else if(maxX < maxY) minXY = maxX;
117 else minXY = maxY;
118
119 return (float)llCeil((minScale / minXY) * size);
120 }
121
122 unpackMessage(string msg)
123 {
124 list msgList = llCSV2List(msg);
125
126 integer on = (integer)llList2String(msgList, 0); // particles on/off
127 vector color = (vector)llList2String(msgList, 1); // particle color
128 float size = (float)llList2String(msgList, 2); // particle size (%) from notecard
129 float inc = (float)llList2String(msgList, 3); // particle increase/decrease (%) from menu
130 string texture = llList2String(msgList, 4); // particle texture from notecard
131
132 if(inc == 999) particleSize = size; // reset particle size
133 else particleSize += inc; // increase/decrease particle size
134 if(particleSize < 1) particleSize = 1; // correct if size < 1%
135 else if(particleSize > 100) particleSize = 100; // correct if size > 100%
136 if(particleSize < minParticleSize) particleSize = minParticleSize; // correct undersized particles
137
138 if(on) {
139 vector start = startScale / defParticleSize * particleSize; // start scale
140 vector end = endScale / defParticleSize * particleSize; // end scale
141 float min = minSpeed / defParticleSize * particleSize; // equally resize min. burst speed
142 float max = maxSpeed / defParticleSize * particleSize; // equally resize max. burst speed
143 float radius = burstRadius / defParticleSize * particleSize; // equally resize burst radius
144 vector push = partAccel / defParticleSize * particleSize; // equally resize accelleration
145 startParticles(color, start, end, min, max, radius, push, texture);
146 }
147 else {
149 }
150 }
151
152 default
153 {
155 {
156 defParticleSize = getParticleSize(startScale, endScale); // default particle size (percentage)
157 vector start = startScale / defParticleSize; // start scale = 1%
158 vector end = endScale / defParticleSize; // end scale = 1%
159 minParticleSize = getMinSize(start, end, 1.0); // minimum particle size (percentage)
160 if(!silent) llWhisper(0, title + " \"" + name + "\" " + version + " ready");
161 llMessageLinked(LINK_THIS, feedbackChannel, "READY", ""); // request particle info from light script
162 }
163
164 on_rez(integer start_param)
165 {
167 }
168
169 link_message(integer sender_number, integer number, string msg, key id)
170 {
171 if(number == particleChannel) unpackMessage(msg);
172 }
173 }

Rene Free Lighting System

Particle Plugin "Starburst"

Category: Light
By : Rene10957 Resident
Created: 2015-06-11 Edited: 2016-03-29
Worlds: Second Life

1 // :LICENSE: CC0 (Public Domain)
2
3 // Rene's Free Lighting System - Particle Plugin "Starburst"
4 //
5 // Author: Rene10957 Resident
6 // Date: 21-03-2014
7
8 ////////////////////////////////////////////////////////////////////////////////
9 // HOW TO USE: drop this script into the same prim where the LIGHT is located //
10 ////////////////////////////////////////////////////////////////////////////////
11
12 string title = "Particle Plugin"; // title
13 string name = "Starburst"; // name
14 string version = "1.4"; // version
15 integer silent = TRUE; // silent startup
16
17 // Constants
18
19 // Note: the official upper limit for particles is 4.0 meters but for more delicate particle effects
20 // it can be useful to set maxScale to a lower value, in order to achieve more fine-grained control.
21
22 integer particleChannel = -75901; // particle channel
23 integer feedbackChannel = -57910; // feedback channel
24 float minScale = 0.03125; // min. startScale or endScale
25 float maxScale = 4.0; // max. startScale or endScale
26
27 // Particle parameters
28
29 // Note: startScale and endScale are not actual sizes, but more like aspect ratios.
30 // The real size is determined by particleSize in the notecard, a percentage of maxScale.
31
32 float age = 1.0; // particle lifetime
33 float rate = 0.1; // particle burst rate
34 integer count = 5; // particle count
35 vector startScale = <0.1, 1.0, 0.0>; // particle start size
36 vector endScale = <0.1, 1.0, 0.0>; // particle end size
37 float minSpeed = 0.1; // particle min. burst speed
38 float maxSpeed = 0.1; // particle max. burst speed
39 float burstRadius = 0.0; // particle burst radius
40 vector partAccel = <0.0, 0.0, 0.0>; // particle accelleration
41
42 // Variables
43
44 float particleSize; // particle size (percentage)
45 float defParticleSize; // default particle size (percentage)
46 float minParticleSize; // minimum particle size (percentage)
47
48 // Functions
49
50 startParticles(vector color, vector start, vector end, float min, float max, float radius, vector push, string txtr)
51 {
66 PSYS_SRC_ACCEL, push,
67 PSYS_SRC_TEXTURE, txtr,
69 0 |
75 }
76
77 /////////////////////////////////////////////////////////////////
78 // From this point onwards, every particle script is identical //
79 /////////////////////////////////////////////////////////////////
80
81 // Particle size = largest dimension across both scale vectors
82
83 float getParticleSize (vector start, vector end)
84 {
85 float max = 0.0;
86 if(start.x > max) max = start.x;
87 if(start.y > max) max = start.y;
88 if(end.x > max) max = end.x;
89 if(end.y > max) max = end.y;
90 return max / (maxScale / 100.0);
91 }
92
93 // Particle size is too small if both start.x and end.x < minScale (0.03125), or...
94 // both start.y and end.y < minScale (0.03125)
95
96 float getMinSize (vector start, vector end, float size)
97 {
98 float maxX = 0.0;
99 float maxY = 0.0;
100 float minXY = 0.0;
101
102 if(start.x < minScale && end.x < minScale) {
103 if(start.x > end.x) maxX = start.x;
104 else maxX = end.x;
105 }
106
107 if(start.y < minScale && end.y < minScale) {
108 if(start.y > end.y) maxY = start.y;
109 else maxY = end.y;
110 }
111
112 if(maxX == 0.0 && maxY == 0.0) return size;
113
114 if(maxX == 0.0) minXY = maxY;
115 else if(maxY == 0.0) minXY = maxX;
116 else if(maxX < maxY) minXY = maxX;
117 else minXY = maxY;
118
119 return (float)llCeil((minScale / minXY) * size);
120 }
121
122 unpackMessage(string msg)
123 {
124 list msgList = llCSV2List(msg);
125
126 integer on = (integer)llList2String(msgList, 0); // particles on/off
127 vector color = (vector)llList2String(msgList, 1); // particle color
128 float size = (float)llList2String(msgList, 2); // particle size (%) from notecard
129 float inc = (float)llList2String(msgList, 3); // particle increase/decrease (%) from menu
130 string texture = llList2String(msgList, 4); // particle texture from notecard
131
132 if(inc == 999) particleSize = size; // reset particle size
133 else particleSize += inc; // increase/decrease particle size
134 if(particleSize < 1) particleSize = 1; // correct if size < 1%
135 else if(particleSize > 100) particleSize = 100; // correct if size > 100%
136 if(particleSize < minParticleSize) particleSize = minParticleSize; // correct undersized particles
137
138 if(on) {
139 vector start = startScale / defParticleSize * particleSize; // start scale
140 vector end = endScale / defParticleSize * particleSize; // end scale
141 float min = minSpeed / defParticleSize * particleSize; // equally resize min. burst speed
142 float max = maxSpeed / defParticleSize * particleSize; // equally resize max. burst speed
143 float radius = burstRadius / defParticleSize * particleSize; // equally resize burst radius
144 vector push = partAccel / defParticleSize * particleSize; // equally resize accelleration
145 startParticles(color, start, end, min, max, radius, push, texture);
146 }
147 else {
149 }
150 }
151
152 default
153 {
155 {
156 defParticleSize = getParticleSize(startScale, endScale); // default particle size (percentage)
157 vector start = startScale / defParticleSize; // start scale = 1%
158 vector end = endScale / defParticleSize; // end scale = 1%
159 minParticleSize = getMinSize(start, end, 1.0); // minimum particle size (percentage)
160 if(!silent) llWhisper(0, title + " \"" + name + "\" " + version + " ready");
161 llMessageLinked(LINK_THIS, feedbackChannel, "READY", ""); // request particle info from light script
162 }
163
164 on_rez(integer start_param)
165 {
167 }
168
169 link_message(integer sender_number, integer number, string msg, key id)
170 {
171 if(number == particleChannel) unpackMessage(msg);
172 }
173 }

Back to the Best Free Tools in Second Life and OpenSim.