Alicia Sautereau Posted January 7, 2012 Share Posted January 7, 2012 Relative simple light controller ;) Create your linkset and drop this script into the rootName each light bulb prim "bulb" If lLinkBulbs = TRUE, all bulbs will set fullbright + lightif lLinkBulbs = FALSE, all bulbs will set fullbright but the root prim will be the light source instead //////////////////////////////////////////////////////// // Simple light controller // Created by Alicia Sautereau // // Free to improve, but sharing would be great :) // Free for personal use // Free to be resold in your products // Free to sell the script as-is/no-mod, but your an arse then... // // Created 27/12/2011 //////////////////////////////////////////////////////// vector sunDir; // Vector as we use a function integer cmdChannel = -900101; // Dialog channel we recieve commands on integer lState = 2; // 0 = off, 1 = on, 2 = sun controlled integer dState = 0; // 0 = main, 1 = intensity, 2 = falloff, 3 = radius, 4 = glow key User; integer listner; float sunTimer = 60.0; // 1 minute vector lColorOff = <222, 187, 153>; // Color of the prim when the light is off (255 = white) vector lColorOn = <222, 187, 153>; // These are the RGB values as you see in the color picker integer lLinkBulbs = TRUE; // Set all linked "bulb" prims to emit light TRUE = yes, FALSE = fullbright float lIntensity = 0.6; // Light intesity (doh) float lFalloff = 0.5; // Light falloff (double doh) float lRadius = 6.0; // Light radius (oh c`mon, like you didn`t guess that one coming...) float lGlow = 0.45; // Glow amount, steps of 0.05 float lGlowDefault = 0.05; // Amount of glow when the light is off list order_buttons(list buttons) { // Kinda pointless, but gotta have it as orderd buttons are cool xD return llList2List(buttons, -3, -1) + llList2List(buttons, -6, -4) + llList2List(buttons, -9, -7) + llList2List(buttons, -12, -10); } // As complicated as this looks, bad joke, we can`t be arsed to copy the dialog text 10 times :) list dM = ["Glow", "Show Settings", "Exit", "Intensity", "Falloff", "Radius", "Light On", "Light Off", "Light Sun"]; list dPM = ["--", "++", "Back"]; // No, it`s not the God function, christ... doLight() { integer i = llGetNumberOfPrims(); for (; i >= 0; --i) { if (llGetLinkName(i) == "bulb") { // We love burning electricity, ON! if (lState == 1 || (lState == 2 && sunDir.z < 0)) { llSetLinkPrimitiveParams( i, [PRIM_FULLBRIGHT, ALL_SIDES, TRUE]);} if (!lLinkBulbs && (lState == 1 || (lState == 2 && sunDir.z < 0))) { llSetLinkPrimitiveParams( 1, [PRIM_POINT_LIGHT,TRUE, (lColorOn/255), lIntensity, lRadius, lFalloff]); } if (lLinkBulbs && (lState == 1 || (lState == 2 && sunDir.z < 0))) { llSetLinkPrimitiveParams( i, [PRIM_POINT_LIGHT,TRUE, (lColorOn/255), lIntensity, lRadius, lFalloff, PRIM_GLOW, ALL_SIDES, lGlow, PRIM_COLOR, ALL_SIDES, (lColorOn/255), 1]); } // Ok, we`re kindof green...off :/ if (lState == 0 || (lState == 2 && sunDir.z > 0)) { llSetLinkPrimitiveParams( i, [PRIM_FULLBRIGHT, ALL_SIDES, FALSE]);} if (!lLinkBulbs && (lState == 0 || (lState == 2 && sunDir.z > 0))) { llSetLinkPrimitiveParams( 1, [PRIM_POINT_LIGHT,FALSE, (lColorOn/255), lIntensity, lRadius, lFalloff]); } if (lLinkBulbs && (lState == 0 || (lState == 2 && sunDir.z > 0))) { llSetLinkPrimitiveParams( i, [PRIM_POINT_LIGHT, FALSE, <0.0,1.0,0.0>,1.0, 10.0, 0.5, PRIM_GLOW, ALL_SIDES, lGlowDefault, PRIM_COLOR, ALL_SIDES, (lColorOff/255), 1]); } } } } default { on_rez(integer init) { // Allways cool to have! } state_entry() { // We could say something else, but "active" will let us know we didn`t kill the script engine, feel free to remove :) llSay(0, "Active"); // We are God, and there shall be, darkness??? if (lState == 2) { llSetTimerEvent(sunTimer); sunDir = llGetSunDirection(); } doLight(); } touch_start(integer total_number) { // Well, we are the user, gimme dialog! :) User = llDetectedKey(0); listner = llListen(cmdChannel, "", llGetOwner(), ""); llDialog(User, "\nLight controller:\n", dM, cmdChannel); } listen(integer cmdChannel, string name, key id, string dC) { // Stop reading right here, i know i did... dC = llToLower(dC); if (dC == "exit") { dState = 0; llListenRemove(listner);} if (dC == "light off") { lState = 0; llListenRemove(listner); llSetTimerEvent(0.0); llSay(0, "Light off"); doLight(); } if (dC == "light on") { lState = 1; llListenRemove(listner); llSetTimerEvent(0.0); llSay(0, "Light on"); doLight(); } if (dC == "light sun") { lState = 2; llListenRemove(listner); llSetTimerEvent(sunTimer); sunDir = llGetSunDirection(); llSay(0, "Sun controlled"); doLight(); } if (dC == "back") { dState = 0; llDialog(User,"\nLight controller:\n", dM, cmdChannel); llSetTimerEvent(sunTimer); doLight(); } if (dC == "intensity") { dState = 1; llDialog(User,"\nLight intensity:\n", dPM, cmdChannel); llSetTimerEvent(sunTimer); } if (dC == "falloff") { dState = 2; llDialog(User,"\nLight falloff:\n", dPM, cmdChannel); llSetTimerEvent(sunTimer); } if (dC == "radius") { dState = 3; llDialog(User,"\nLight radius:\n", dPM, cmdChannel); llSetTimerEvent(sunTimer); } if (dC == "glow") { dState = 4; llDialog(User,"\nLight glow:\n", dPM, cmdChannel); llSetTimerEvent(sunTimer); } if (dC == "--" && dState == 1) { lIntensity = lIntensity - 0.1; llDialog(User,"\nLight intensity:\n", dPM, cmdChannel); llSetTimerEvent(sunTimer); doLight(); } if (dC == "++" && dState == 1) { lIntensity = lIntensity + 0.1; llDialog(User,"\nLight intensity:\n", dPM, cmdChannel); llSetTimerEvent(sunTimer); doLight(); } if (dC == "--" && dState == 2) { lFalloff = lFalloff - 0.1; llDialog(User,"\nLight falloff:\n", dPM, cmdChannel); llSetTimerEvent(sunTimer); doLight(); } if (dC == "++" && dState == 2) { lFalloff = lFalloff + 0.1; llDialog(User,"\nLight falloff:\n", dPM, cmdChannel); llSetTimerEvent(sunTimer); doLight(); } if (dC == "--" && dState == 3) { lRadius = lRadius - 1.0; llDialog(User,"\nLight radius:\n", dPM, cmdChannel); llSetTimerEvent(sunTimer); doLight(); } if (dC == "++" && dState == 3) { lRadius = lRadius + 1.0; llDialog(User,"\nLight radius:\n", dPM, cmdChannel); llSetTimerEvent(sunTimer); doLight(); } if (dC == "--" && dState == 4) { lGlow = lGlow - 0.05; llDialog(User,"\nLight glow:\n", dPM, cmdChannel); llSetTimerEvent(sunTimer); doLight(); } if (dC == "++" && dState == 4) { lGlow = lGlow + 0.05; llDialog(User,"\nLight gLow:\n", dPM, cmdChannel); llSetTimerEvent(sunTimer); doLight(); } if (dC == "show settings") { llSay(0, "Intensity: "+ (string)lIntensity +", Falloff: "+ (string)lFalloff +", Radius: "+(string) lRadius +", Glow: "+ (string)lGlow +", Color: "+ (string)lColorOn ); llDialog(User, "\nLight controller:\n", dM, cmdChannel); } } timer() { // Kill listner just incase the user pressed ignore (to bad if he started it right befor the timer hits :)) llListenRemove(listner); if (lState != 2) { llSetTimerEvent(0.0); } // Can some one tell us where the sun is? please? if (lState == 2) { sunDir = llGetSunDirection(); doLight(); } } } 2 Link to comment Share on other sites More sharing options...
Alicia Sautereau Posted January 15, 2012 Author Share Posted January 15, 2012 Small revision: Re-added the exit button Removed the doLight() at the end of the listner to the end of each command Added a "show settings" button that says the current values in local, easy for making this the default light values when you have found a good settin, also works better when copy&ing the object for identical values. Link to comment Share on other sites More sharing options...
Alicia Sautereau Posted January 15, 2012 Author Share Posted January 15, 2012 Another addon: Added a glow option, 0.05 steps Added a default glow value for when the light is turned off (for who wants it) Added a RGB conversion, now you can just input the RGB values from the color picker :matte-motes-silly: Added a color value for when the light is off Light bulb now changes into the light color used Use a bright color, say white, for when the light is turned on and use a dark gray color when it`s turned off or keep both values the same Link to comment Share on other sites More sharing options...
Morgaine Christensen Posted January 15, 2012 Share Posted January 15, 2012 Thanks! Not sure I am using this correctly but it works in my opera lights for a build! Link to comment Share on other sites More sharing options...
desmine Magic Posted July 18, 2012 Share Posted July 18, 2012 anyway that others can use the controller to except for Owner? maybe for all or on group? thank you Link to comment Share on other sites More sharing options...
Rolig Loon Posted July 19, 2012 Share Posted July 19, 2012 Easy. Just replace llGetOwner() with "". Link to comment Share on other sites More sharing options...
Sunvile Posted October 25, 2014 Share Posted October 25, 2014 first script doesnt wor, it write "syntax error (65, 0 )" second script say if (lState == 2) { llSetTimerEvent(sunTimer); sunDir = (14, 19) name not define with scope Link to comment Share on other sites More sharing options...
Rolig Loon Posted October 25, 2014 Share Posted October 25, 2014 There's only one script. It sounds as if you copied only part of it instead of the whole thing. :smileywink: Link to comment Share on other sites More sharing options...
Serendip Soleil Posted November 11, 2015 Share Posted November 11, 2015 is there another script? where is the other script? ?? Link to comment Share on other sites More sharing options...
Rolig Loon Posted November 11, 2015 Share Posted November 11, 2015 No. As I said over a year ago when someone asked the same question, there is just one script, right at the top of this thread. It works just fine. Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now