Who Is Online

1
Online

Tuesday, 26 September 2017 05:32

*SRU* light script

//prim colour

vector red = <0.86,0.0,0.14>; 
vector green  = <0,0.9,0>; 
vector white  = <1,1,1>;
vector black  = <0.12,0.1,0.12>;
vector steel  = <0.27,0.51,0.71>;
vector blue  = <0.1,0.31,0.98>;
vector orange  = <1,.6,0>;
vector yellow  = <1,1,0.1>;
vector brown  = <0.5,0.25,0>;
vector pink  = <0.85,0,0.75>;
vector purple  = <0.8,0.21,0.8>;
vector lime  = <0.18,0.75,0.34>;


float intensity;
float radius;
float falloff;
vector colour;
integer toggle;
vector pColour;
float alpha = 1.0;

integer channel;

default
{
    state_entry()
    {
        channel = llRound(llFrand(2000000.0)) + 1;
        llListen(channel, "", llGetOwner(), ""); 
        pColour = (vector) llList2String(llGetPrimitiveParams([PRIM_COLOR, 1]),0);
        alpha = llGetAlpha(ALL_SIDES);
        intensity = (float) llList2String(llGetPrimitiveParams([PRIM_POINT_LIGHT]),2);
        radius    = (float) llList2String(llGetPrimitiveParams([PRIM_POINT_LIGHT]),3);
        falloff   = (float)  llList2String(llGetPrimitiveParams([PRIM_POINT_LIGHT]),4);
        colour    = (vector) llList2String(llGetPrimitiveParams([PRIM_POINT_LIGHT]),1);
        toggle    = (integer)  llList2String(llGetPrimitiveParams([PRIM_POINT_LIGHT]),0);
    }
    
    on_rez(integer param)
    {
        llResetScript();
    }
    
    touch_start(integer total_number)
    {
        if (llDetectedKey(0) == llGetOwner())
        {
            llDialog(llGetOwner(), "Light menu", ["radius", "falloff", "alpha", "prim colour", "light colour", "intensity", "full bright", "on/off", "store"], channel);   
        }
    }
    
    listen(integer channel, string name, key id, string message)
    {
        if (message == "store")
        {
            llResetScript();
        }
        
        if (message == "radius")
        {
            llDialog(llGetOwner(), "Radius menu", ["+", "++", "+++", "-", "--", "---"], channel);
        }
        
        if (message == "+")
        {
            radius += 0.5;
            if (radius > 20) {radius = 20;}
            llSetPrimitiveParams([PRIM_POINT_LIGHT, toggle, colour, intensity, radius, falloff]);
        }
        if (message == "++")
        {
            radius += 1;
            if (radius > 20) {radius = 20;}
            llSetPrimitiveParams([PRIM_POINT_LIGHT, toggle, colour, intensity, radius, falloff]);
        }
        if (message == "+++")
        {
            radius += 5;
            if (radius > 20) {radius = 20;}
            llSetPrimitiveParams([PRIM_POINT_LIGHT, toggle, colour, intensity, radius, falloff]);
        }    
        if (message == "-")
        {
            radius -= 0.5;
            if (radius < 1) {radius = 1;}
            llSetPrimitiveParams([PRIM_POINT_LIGHT, toggle, colour, intensity, radius, falloff]);
        }
        if (message == "--")
        {
            radius -= 1;
            if (radius < 1) {radius = 1;}
            llSetPrimitiveParams([PRIM_POINT_LIGHT, toggle, colour, intensity, radius, falloff]);
        }
        if (message == "---")
        {
            radius -= 5;
            if (radius < 1) {radius = 1;}
            llSetPrimitiveParams([PRIM_POINT_LIGHT, toggle, colour, intensity, radius, falloff]);
        }
        
        if (message == "prim colour")
        {
            llDialog(llGetOwner(), "Prim colour menu", ["p.red","p.green","p.white","p.black","p.steel","p.blue","p.orange","p.yellow","p.brown","p.pink","p.purple","p.lime"], channel);
        }   
        
        if (llGetSubString(message,0,1) == "p.")
        {
            string c = llGetSubString(message,2,-1);
            
            if (c == "brown")
            {
                pColour = brown;
            }
            if (c == "pink")
            {
                pColour = pink;
            }

            if (c == "purple")
            {
                pColour = purple;
            }
            if (c == "lime")
            {
                pColour = lime;
            }
            
            if (c == "yellow")
            {
                pColour = yellow;
            }
            if (c == "orange")
            {
                pColour = orange;
            }    
            if (c == "blue")
            {
                pColour = blue;
            }
            if (c == "steel")
            {
                pColour = steel;
            }
            if (c == "black")
            {
                pColour = black;
            }
            if (c == "white")
            {
                pColour = white;
            }
            if (c == "red")
            {
                pColour = red;
            }
            if (c == "green")
            {
                pColour = green;
            }
            llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, pColour, alpha]);
        }
        
        
        if (message == "light colour")
        {
            llDialog(llGetOwner(), "Light colour menu", ["l.red","l.green","l.white","l.black","l.steel","l.blue","l.orange","l.yellow","l.brown","l.pink","l.purple","l.lime"]   , channel);   
        }
        
        if (llGetSubString(message,0,1) == "l.")
        {
            string c = llGetSubString(message,2,-1);
            
            if (c == "brown")
            {
                colour = brown;
            }
            if (c == "pink")
            {
                colour = pink;
            }

            if (c == "purple")
            {
                colour = purple;
            }
            if (c == "lime")
            {
                colour = lime;
            }
            
            if (c == "yellow")
            {
                colour = yellow;
            }
            if (c == "orange")
            {
                colour = orange;
            }    
            if (c == "blue")
            {
                colour = blue;
            }
            if (c == "steel")
            {
                colour = steel;
            }
            if (c == "black")
            {
                colour = black;
            }
            if (c == "white")
            {
                colour = white;
            }
            if (c == "red")
            {
                colour = red;
            }
            if (c == "green")
            {
                colour = green;
            }
            llSetPrimitiveParams([PRIM_POINT_LIGHT, toggle, colour, intensity, radius, falloff]);
        }
        
        // Intensity toggle
        if (message == "intensity")
        {
            llDialog(llGetOwner(), "Intensity menu", ["i.0 %","i.10 %","i.20 %","i.30 %","i.40 %","i.50 %","i.60 %","i.70 %","i.80 %","i.90 %","i.100 %"], channel);   
        }
        
        if (message == "falloff")
        {
            llDialog(llGetOwner(), "fall off menu", ["f.0 %","f.20 %","f.40 %","f.60 %","f.80 %","f.100 %","f.120 %","f.140 %","f.160 %","f.180 %","f.200 %"], channel);   
        }

        if (message == "alpha")
        {
            llDialog(llGetOwner(), "Intensity menu", ["a.5 %","a.10 %","a.20 %","a.30 %","a.40 %","a.50 %","a.60 %","a.70 %","a.80 %","a.90 %","a.100 %"], channel);   
        }


        
        if (llGetSubString(message,0,1) == "i.")
        {
            list templist = llParseString2List(message,[" "], []);
            intensity = (float) llGetSubString(llList2String(templist,0),2,-1);
            intensity = intensity * 0.01;
            llSetPrimitiveParams([PRIM_POINT_LIGHT, toggle, colour, intensity, radius, falloff]);
        }
        
        if (llGetSubString(message,0,1) == "a.")
        {
            list templist = llParseString2List(message,[" "], []);
            alpha = (float) llGetSubString(llList2String(templist,0),2,-1);
            alpha = alpha * 0.01;
            llSetAlpha(alpha, ALL_SIDES);
        }

        
        if (llGetSubString(message,0,1) == "f.")
        {
            list templist = llParseString2List(message,[" "], []);
            falloff = (float) llGetSubString(llList2String(templist,0),2,-1);
            falloff = falloff * 0.01;
            llSetPrimitiveParams([PRIM_POINT_LIGHT, toggle, colour, intensity, radius, falloff]);
        }
        
        // full brigth toggle
        if (message == "full bright")
        {
            llDialog(llGetOwner(), "Full bright menu", ["fb.on", "fb.off"], channel);   
        }
        if (message == "fb.on")
        {
            llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, TRUE]);
        }
        if (message == "fb.off")
        {
            llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, FALSE]);
        }
        
        // on off menu
        if (message == "on/off")
        {
            llDialog(llGetOwner(), "On off switch menu", ["t.on", "t.off"], channel);
        }
        if (message == "t.on")
        {
            toggle = TRUE;
            llSetPrimitiveParams([PRIM_POINT_LIGHT, toggle, colour, intensity, radius, falloff]);
        }
        if (message == "t.off")
        {
            toggle = FALSE;
            llSetPrimitiveParams([PRIM_POINT_LIGHT, toggle, colour, intensity, radius, falloff]);
        }
    }
}

 

Flash Scratch to SL - Your Scripting Tool

Script ImageNeed to write a LSL script and don't know how to script?  I know I hate trying to get my head around LSLS when I an in a time crunch. So why not give Flash Scratch a try! Its a great tool for learning and scoding your own scripts for Second Life without having to pay someone to do it and without a crash course in LSL

A Huge thanks to John Bennet of ATLAS Institute at University of Colorado and Eric Rosenbaum at MIT for writing Scratch for SL to begin with.

Read more: Flash Scratch to SL - Your Scripting Tool