Jump to content
Sunbleached

Blinking light without timer Script

Recommended Posts

Hello! What is the easiest way to make the light blink using the llSetLinkPrimitiveParametersFast? Preferably not using a timer, since there is already one timer, and I tried to build it into it, but it didn’t work out yet. Is it possible at all?

Share this post


Link to post
Share on other sites
5 minutes ago, Fionalein said:

while true loop + sleep

Thanks for responding so quickly!


I've never come across while before, can I have a little more details, please?

Share this post


Link to post
Share on other sites

Why not just run a second fake timer?  

Or, depending on what sort of light you have, how about using llSetTextureAnim to ping-pong back and forth between a nice yellow light image and a dull gray one?

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
1 hour ago, Fionalein said:

while true loop + sleep

But this would lock the script into that one loop, unable to process any new events once it begins.

  • Like 2

Share this post


Link to post
Share on other sites
1 hour ago, Wulfie Reanimator said:

But this would lock the script into that one loop, unable to process any new events once it begins.

True, but since the OP never said what else he expects the script to do, we're free to guess.  It's not our script.  ;)

  • Like 1

Share this post


Link to post
Share on other sites

If you only need the "impression" of a light and no change in light emission you can use a two step texture animation and consume no script time.

  • Like 3

Share this post


Link to post
Share on other sites
3 hours ago, Kyrah Abattoir said:

If you only need the "impression" of a light and no change in light emission you can use a two step texture animation and consume no script time.

As I suggested earlier ^^   🙃

  • Like 1

Share this post


Link to post
Share on other sites
5 hours ago, Rolig Loon said:

True, but since the OP never said what else he expects the script to do, we're free to guess.  It's not our script.  ;)

But there was this:

7 hours ago, Sunbleached said:

... there is already one timer...

so that timer won't work while the script is in a tight while loop. I guess it's possible there's no blinkenlight while the existing timer is relevant, but then the timer would be eligible to control the light blink.

Anyway, I mostly wanted to mention that under advanced lighting, emitted light "blinks" when behind a texture animation that's part transparent, part opaque, requiring no script at all. Of course, those without ALM enabled won't see it, but I use this often for stuff like flickering fluorescent lights and candles, figuring the non-ALM-equipped are already missing a lot more than some flickering lights.

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
1 hour ago, Qie Niangao said:

that under advanced lighting, emitted light "blinks" when behind a texture animation that's part transparent, part opaque, requiring no script at all.

Does that work only with shadows on?

  • Like 1

Share this post


Link to post
Share on other sites

My only gripe with animated texture "light blinking" is that depending on the size of the object, animated textures stop animated from a certain draw distance.

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, animats said:

Does that work only with shadows on?

Yeah, I think that's probably right.

Also, I realize I said "emitted light" when I should have said "projected light" -- it's not enough for it to be simply a point light source, it has to be using projected light.

The distance where it's visible definitely depends on keeping the light-masking object rezzed -- if it's small enough to disappear (or, I suppose, lose shape by LoD), the blinking will stop -- but I've usually set the projected light radius shorter than that anyway.

  • Like 1

Share this post


Link to post
Share on other sites
Posted (edited)

The script itself if it somehow clarifies the situation, this was the basic menu script, I only built-in options for controlling the brightness of the light and on/off. trying to add a blinking button. I tried

giTick

  and BillThePirate by Rolig. But no success. I also plan to add automatic on and off depending on the position of the sun and this will be the third timer!

vector LIGHT_COLOR = < 1.0, 1.0, 1.0 > ; //Light color
integer LIGHT_PRIM = LINK_THIS; //LINK_SET or prim number
integer LIGHT_FACE = ALL_SIDES; //light face

list MENU_MAIN = ["MIN","MID","MAX","ON","OFF","DELETE","BLINK","AUTO ON","AUTO OFF"]; 

float   sun_height;
vector  sun_position;

integer menu_handler;
integer menu_channel;
menu(key user,string title,list buttons)
{
    llListenRemove(menu_handler); 
    menu_channel = (integer)(llFrand(99999.0) * -1);
    menu_handler = llListen(menu_channel,"","","");
    llDialog(user,title,buttons,menu_channel);
    llSetTimerEvent(30.0); //how long to wait for user to press a button before giving up and closing listen
}

default
{
    state_entry()
    {

    }

    touch_start(integer total_number)
    {
        menu(llDetectedKey(0), "\nText for Menu.", MENU_MAIN);
    }
    
    listen(integer channel,string name,key id,string message)
    {
        if (channel == menu_channel) 
        {
            llListenRemove(menu_handler); //close listen
            llSetTimerEvent(0); //stop timeout timer
            if (message == "MIN")
            {
            llSay(0, "Min Light");
            llSetLinkPrimitiveParamsFast(LIGHT_PRIM,
            [PRIM_GLOW, LIGHT_FACE, 0.25,
            PRIM_POINT_LIGHT, TRUE,
            LIGHT_COLOR // START COLOR
            , 0.25 // START INTENSITY
            , 5.0 // START RADIUS
            , 1.0 // START FALLOFF
            ]);
                
            }
            else if (message == "MID")
            {
            llSay(0, "Mid Light");
            llSetLinkPrimitiveParamsFast(LIGHT_PRIM,
            [PRIM_GLOW, LIGHT_FACE, 0.50,
            PRIM_POINT_LIGHT, TRUE,
            LIGHT_COLOR // START COLOR
            , 0.5 // START INTENSITY
            , 10.0 // START RADIUS
            , 0.5 // START FALLOFF
            ]);
            }
            else if (message == "MAX")
            {
            llSay(0, "Max Light");
            llSetLinkPrimitiveParamsFast(LIGHT_PRIM,
            [PRIM_GLOW, LIGHT_FACE, 1.00,
            PRIM_POINT_LIGHT, TRUE,
            LIGHT_COLOR // START COLOR
            , 1.0 // START INTENSITY
            , 20.0 // START RADIUS
            , 0.0 // START FALLOFF
            ]);
            }
            else if (message == "ON")
            {
            llSay(0, "Light is ON");
            llSetLinkPrimitiveParamsFast(LIGHT_PRIM,
            [PRIM_GLOW, LIGHT_FACE, 1.00,
            PRIM_POINT_LIGHT, TRUE,
            LIGHT_COLOR // START COLOR
            , 1.0 // START INTENSITY
            , 20.0 // START RADIUS
            , 0.0 // START FALLOFF
            ]);
            }
            else if (message == "OFF")
            {
            llSay(0, "Light is OFF");
            llSetLinkPrimitiveParamsFast(LIGHT_PRIM,
            [PRIM_GLOW, ALL_SIDES, FALSE, PRIM_POINT_LIGHT, FALSE,
            ZERO_VECTOR // COLOR
            , 0.0 // INTENSITY
            , 0.0 // RADIUS
            , 2.0 // FALLOFF
            ]);
            }
            else if (message == "DELETE")
            {
            llSay(0, "Script Deleted");
            llRemoveInventory(llGetScriptName());
            }
            else if (message == "BLINK")
            {
            llSay(0, "Blinking");

            // BLINKING STUFF
 
            }
            else if (message == "AUTO ON")
            {
            llSay(0, "Automatic light on");
            sun_position = llGetSunDirection();        
            sun_height = sun_position.z; 
            if(sun_height < 0.0)
            {
            llSetLinkPrimitiveParamsFast(LIGHT_PRIM,
            [PRIM_GLOW, LIGHT_FACE, 1.00,
            PRIM_POINT_LIGHT, TRUE,
            LIGHT_COLOR // START COLOR
            , 1.0 // START INTENSITY
            , 20.0 // START RADIUS
            , 0.0 // START FALLOFF
            ]);        
            }       
            else        
            {            
            llSetLinkPrimitiveParamsFast(LIGHT_PRIM,
            [PRIM_GLOW, ALL_SIDES, FALSE, PRIM_POINT_LIGHT, FALSE,
            ZERO_VECTOR // COLOR
            , 0.0 // INTENSITY
            , 0.0 // RADIUS
            , 2.0 // FALLOFF
            ]);       
            }

            }
            else if (message == "AUTO OFF")
            {
            llSay(0, "Automatic light off");
            llSetLinkPrimitiveParamsFast(LIGHT_PRIM,
            [PRIM_GLOW, ALL_SIDES, FALSE, PRIM_POINT_LIGHT, FALSE,
            ZERO_VECTOR // COLOR
            , 0.0 // INTENSITY
            , 0.0 // RADIUS
            , 2.0 // FALLOFF
            ]);
            }
            //else if (message == "Button")
            //{
                //do something
            //}
        }
    }
    
    timer() //VERY IMPORTANT menu timeout
    {
        
        
        llListenRemove(menu_handler); //close listen
        llSetTimerEvent(0); //stop timeout timer
    }
    
}

 

Edited by Sunbleached

Share this post


Link to post
Share on other sites

Is that all?  Just multiplex the timer.

integer iTouched;

default
{
    state_entry()
    {
        llSetTimerEvent(1.0);
        // and whatever else
    }

    touch_start(integer num)
    {
        iTouched = 1;
        // and whatever else ...
    }

    timer()
    {
         if (iTouched > 1)
        {
            ++iTouched;
        }
        if (iTouched > 30)
        {
            iTouched = 0;
            llListenRemove(menu_handler);
        }
    }
}

 

  • Thanks 1

Share this post


Link to post
Share on other sites
55 minutes ago, Rolig Loon said:

Is that all?  Just multiplex the timer.

 

@Rolig Loon

Thank you very much!

In this discussion, the main focus was on the timers, but it’s also incomprehensible to me how to make the light blink? I would also like to understand how to make it?

 

 

Share this post


Link to post
Share on other sites

I should try harder, but I’m still unable to use multiplex timer. how to add it to my script?

 

vector LIGHT_COLOR = < 1.0, 1.0, 1.0 > ; //Light color
integer LIGHT_PRIM = LINK_THIS; //LINK_SET or prim number
integer LIGHT_FACE = ALL_SIDES; //light face

list MENU_MAIN = ["MIN","MID","MAX","ON","OFF","DELETE","BLINK","AUTO ON","AUTO OFF"]; 

float   sun_height;
vector  sun_position;
integer iTouched;
integer menu_handler;
integer menu_channel;
menu(key user,string title,list buttons)
{
    llListenRemove(menu_handler); 
    menu_channel = (integer)(llFrand(99999.0) * -1);
    menu_handler = llListen(menu_channel,"","","");
    llDialog(user,title,buttons,menu_channel);
    llSetTimerEvent(30.0); //how long to wait for user to press a button before giving up and closing listen
}

default
{
    state_entry()
    {
        llSetTimerEvent(1.0);
        // and whatever else
    }

    touch_start(integer total_number)
    
    {
        {
        iTouched = 1;
        // and whatever else ...
        
    
        
    }
    
    
    {
        menu(llDetectedKey(0), "\nText for Menu.", MENU_MAIN);
    }
    }
    
    listen(integer channel,string name,key id,string message)
    {
        if (channel == menu_channel) 
        {
            llListenRemove(menu_handler); //close listen
            llSetTimerEvent(0); //stop timeout timer
            if (message == "MIN")
            {
            llSay(0, "Min Light");
            llSetLinkPrimitiveParamsFast(LIGHT_PRIM,
            [PRIM_GLOW, LIGHT_FACE, 0.25,
            PRIM_POINT_LIGHT, TRUE,
            LIGHT_COLOR // START COLOR
            , 0.25 // START INTENSITY
            , 5.0 // START RADIUS
            , 1.0 // START FALLOFF
            ]);
                
            }
            else if (message == "MID")
            {
            llSay(0, "Mid Light");
            llSetLinkPrimitiveParamsFast(LIGHT_PRIM,
            [PRIM_GLOW, LIGHT_FACE, 0.50,
            PRIM_POINT_LIGHT, TRUE,
            LIGHT_COLOR // START COLOR
            , 0.5 // START INTENSITY
            , 10.0 // START RADIUS
            , 0.5 // START FALLOFF
            ]);
            }
            else if (message == "MAX")
            {
            llSay(0, "Max Light");
            llSetLinkPrimitiveParamsFast(LIGHT_PRIM,
            [PRIM_GLOW, LIGHT_FACE, 1.00,
            PRIM_POINT_LIGHT, TRUE,
            LIGHT_COLOR // START COLOR
            , 1.0 // START INTENSITY
            , 20.0 // START RADIUS
            , 0.0 // START FALLOFF
            ]);
            }
            else if (message == "ON")
            {
            llSay(0, "Light is ON");
            llSetLinkPrimitiveParamsFast(LIGHT_PRIM,
            [PRIM_GLOW, LIGHT_FACE, 1.00,
            PRIM_POINT_LIGHT, TRUE,
            LIGHT_COLOR // START COLOR
            , 1.0 // START INTENSITY
            , 20.0 // START RADIUS
            , 0.0 // START FALLOFF
            ]);
            }
            else if (message == "OFF")
            {
            llSay(0, "Light is OFF");
            llSetLinkPrimitiveParamsFast(LIGHT_PRIM,
            [PRIM_GLOW, ALL_SIDES, FALSE, PRIM_POINT_LIGHT, FALSE,
            ZERO_VECTOR // COLOR
            , 0.0 // INTENSITY
            , 0.0 // RADIUS
            , 2.0 // FALLOFF
            ]);
            }
            else if (message == "DELETE")
            {
            llSay(0, "Script Deleted");
            llRemoveInventory(llGetScriptName());
            }
            else if (message == "BLINK")
            {
            llSay(0, "Blinking");

            
            
            llSetLinkPrimitiveParamsFast(LIGHT_PRIM,
            [PRIM_GLOW, LIGHT_FACE, 1.00,
            PRIM_POINT_LIGHT, TRUE,
            LIGHT_COLOR // START COLOR
            , 1.0 // START INTENSITY
            , 20.0 // START RADIUS
            , 0.0 // START FALLOFF
            ]);
            llSleep(1);
            llSetLinkPrimitiveParamsFast(LIGHT_PRIM,
            [PRIM_GLOW, ALL_SIDES, FALSE, PRIM_POINT_LIGHT, FALSE,
            ZERO_VECTOR // COLOR
            , 0.0 // INTENSITY
            , 0.0 // RADIUS
            , 2.0 // FALLOFF
            ]);


            
            
            
            
            

            // BLINKING STUFF
 
            }
            else if (message == "AUTO ON")
            {
            llSay(0, "Automatic light on");
            sun_position = llGetSunDirection();        
            sun_height = sun_position.z; 
            if(sun_height < 0.0)
            {
            llSetLinkPrimitiveParamsFast(LIGHT_PRIM,
            [PRIM_GLOW, LIGHT_FACE, 1.00,
            PRIM_POINT_LIGHT, TRUE,
            LIGHT_COLOR // START COLOR
            , 1.0 // START INTENSITY
            , 20.0 // START RADIUS
            , 0.0 // START FALLOFF
            ]);        
            }       
            else        
            {            
            llSetLinkPrimitiveParamsFast(LIGHT_PRIM,
            [PRIM_GLOW, ALL_SIDES, FALSE, PRIM_POINT_LIGHT, FALSE,
            ZERO_VECTOR // COLOR
            , 0.0 // INTENSITY
            , 0.0 // RADIUS
            , 2.0 // FALLOFF
            ]);       
            }

            }
            else if (message == "AUTO OFF")
            {
            llSay(0, "Automatic light off");
            llSetLinkPrimitiveParamsFast(LIGHT_PRIM,
            [PRIM_GLOW, ALL_SIDES, FALSE, PRIM_POINT_LIGHT, FALSE,
            ZERO_VECTOR // COLOR
            , 0.0 // INTENSITY
            , 0.0 // RADIUS
            , 2.0 // FALLOFF
            ]);
            }
            //else if (message == "Button")
            //{
                //do something
            //}
        }
    }
    
    timer() //VERY IMPORTANT menu timeout
    {
          if (iTouched > 1)
        {
            ++iTouched;
        }
        if (iTouched > 30)
        {
            iTouched = 0;
            llListenRemove(menu_handler);
        }       
        
        




    }
    
}

 

Share this post


Link to post
Share on other sites

Step aside for a while, take a long walk to clear your head, then come back and think this through.  You have all the parts you need now.  We're not going to write your script for you. ;)

  • Thanks 2

Share this post


Link to post
Share on other sites
1 hour ago, Rolig Loon said:

Step aside for a while, take a long walk to clear your head, then come back and think this through.  You have all the parts you need now.  We're not going to write your script for you. ;)

Thank you very much! That's exactly what I am going to do!

The only thing makes me sad is if I may never come back to it and if all your efforts were in vain...

But the script is good for me even as is - without blinking and automation!

Thank's!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...