Jump to content
ermanart

Switch Script?

You are about to reply to a thread that has been inactive for 992 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hi everyone. There are fullperm lights in the lantern you have seen in the picture below. How can we open this light that is separate from the lantern.

I want you to open it with the touch of a lantern. Please help in this regard.

01

 

 

Share this post


Link to post
Share on other sites

The basic form of a simple toggle switch is
 

integer iON;

default
{
    touch_start(integer num)
    {
        iON = !iON;
        if (iON)
       {
            //Do something
        }
        else
        {
            // Stop doing it
        }
    }
}

In your case, "something" is making a prim light up.  The three things you can change to make a prim light up are fullbright, glow, and point source light.  You can control all three with llSetLinkPrimitiveParamsFast.  So to make the prim bright, you might write:

llSetLinkPrimitiveParamsFast(link_number,[PRIM_FULLBRIGHT,ALL_SIDES,TRUE,PRIM_GLOW,ALL_SIDES,0.03,PRIM_POINT_LIGHT,TRUE,<1.0,1.0,0.0>,1.0,2.0,0.7]);

and to turn it off:

llSetLinkPrimitiveParamsFast(link_number,[PRIM_FULLBRIGHT,ALL_SIDES,FALSE,PRIM_GLOW,ALL_SIDES,0.0,PRIM_POINT_LIGHT,FALSE,<1.0,1.0,0.0>,1.0,2.0,0.7]);

Just be sure you use the correct link number for the prim that is your light source.

  • Thanks 1

Share this post


Link to post
Share on other sites

Do not rely on Firestorm's editor tool to tell you the link number of the light emitter.  It's not reliable.   The only safe way to know the link number is to read it by script, something like this


integer iEmitterPrim;

string strEmitter = "Light Emitter";

default {
	state_entry() {
		//loop through the linkset, looking for the light emitter
		integer max = llGetNumberOfPrims();
		do{
			if(llGetLinkName(max) == strEmitter){ //found it
				iEmitterPrim = max; //make a note of the link number
			}
		}
		while(--max);

	}

	changed(integer change){ 
		if(change & CHANGED_LINK){
			llResetScript();//check again for the light prim's link number, since it may have changed
		}
	}


}

Just name the emitter prim "Light Emitter" before putting in the script (or reset the script after you name the prim) and the script should then know which prim you want to affect.

Edited by Innula Zenovka
  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
On 11/23/2017 at 5:19 PM, Innula Zenovka said:

Do not rely on Firestorm's editor tool to tell you the link number of the light emitter.  It's not reliable.   The only safe way to know the link number is to read it by script, something like this

-snip-

Just name the emitter prim "Light Emitter" before putting in the script (or reset the script after you name the prim) and the script should then know which prim you want to affect.

Firestorm's link numbers show correctly after you (re-)rez the object after linking new prims. Scripting a search-loop is a bit overkill if the link is unlikely to change.

Edited by Wulfie Reanimator
  • Thanks 1

Share this post


Link to post
Share on other sites
You are about to reply to a thread that has been inactive for 992 days.

Please take a moment to consider if this thread is worth bumping.

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...