Jump to content

Full bright script


ElPancho
 Share

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

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

Recommended Posts

When you write your script, make it a simple toggle switch and use llSetLinkPrimitiveParams to set the PRIM_FULLBRIGHT parameter. You can communicate with that script from your HUD with llRegionSay. If you don't know how to do this, you can hire a scripter by posting in the InWorld Employment forum.

Link to comment
Share on other sites

I have this script:

 

integer fullbright;default{touch_start(integer t){llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, fullbright = !fullbright]);}}

 

But I don't want to use the llRegionSay as it would require to enter a chat command? I just want a script that I can place in a button in the HUD that will comunicate with the object and turn the bright on/off with a click on the HUD button (not at the item itself).

Link to comment
Share on other sites

/me tosses 2 cents on the table.

"There you go".

 

Not a coder, but seriously : Shouldn't you :

 

  • Obtain UUID of inworld object ?
  • Use touch-script within HUD-object to set brightness of object with certain inworld object UUID ?

 

Link to comment
Share on other sites

Excellent.  So you already have the switch that will turn full_bright on and off.  Congratulations.  That will go in your object, but you'll need to change its touch_start event to a listen event first, and you'll need to open a communication channel so that it can hear your HUD. Open the communication channel in a state_entry event with llListen and use a channel with a large negative number, like -9274826. Your HUD script can be extremely simple, because it only needs to say something on that same communication channel with llRegionSay when you click it.  It doesn't matter what the HUD says.  Any message will do, as long as the HUD and the object are using the same channel.

EDIT:  TDD123 has a good idea, but it's probably not necessary for something as simple as this, where you're only controlling one object.  If you wanted to be absoultely sure that no other object was listening, coincidentally, on the specific channel that you chose, you could in fact use llRegionSayTo and send the HUD's message only to an object with a specific UUID. 

Link to comment
Share on other sites

Thanks guys, I came up with this for the object I want bright:

 

integer ch=-19020555;//Channel for reception(Number same as a transmission channel)  integer fullbright;default{ listen(integer channel, string name, key id, string msg){llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, fullbright = !fullbright]);}}

 

The problem now sure is the script I want to place in the HUD button, I came up with this but I know it is wrong as it doesn't work, can anyone point where did I go wrong please? I've no idea.

 

integer ch=-19020555;             default{        touch_start(integer total_number)    {           llRegionSay (ch,"");      }}

 

Also, do I need to rename the scripts to a specific name to make it work?

Link to comment
Share on other sites

Almost there.  The script for your object has a channel now, but you haven't opened it.  That's why you need a state_entry event with a llListen statement in it.  The llListen opens the channel that you just defined.

The script for your HUD is fine.  It will do the job nicely.  The only thing you'll want to change there is to actually give it a message to send.  As I said earlier, it doesn't matter what the message is, because the listening script will respond to anything it hears on that channel.  The way you have it written now, though, it's saying nothing.  So ....  llRegionSay(ch, "Gotcha!");

Once you've done that, you have all the pieces: A script the speaks when you touch it and a script that listens and then does something when it hears the first script speak.  You can name the scripts anything you like.  They should work like a dream.

Link to comment
Share on other sites

:D So it came out this way:

 

For the object:

 

integer ch=-19020555;//Channel for reception(Number same as a transmission channel)  integer fullbright;default{    state_entry()    {        llListen(ch,"",NULL_KEY,"");    } listen(integer channel, string name, key id, string msg){llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, fullbright = !fullbright]);}}

 

For the Button:

 

integer ch=-19020555;             default{        touch_start(integer total_number)    {           llRegionSay (ch,"Gotcha");      }}

 

And as you said, it works like a charm! I placed the working version here in case other people need it. Tysvm for your help, really appreciated!

Link to comment
Share on other sites

Currently,  any object that says anything on channel -19020555 will trigger the full brightness to toggle, use the code below to only listen to the owner.

 

integer ch=-19020555;//Channel for reception(Number same as a transmission channel)  integer fullbright;default{    state_entry()    {        llListen(ch,"",NULL_KEY,"");    } listen(integer channel, string name, key id, string msg){    if(llGetOwnerKey(id)==llGetOwner()) //If the object's owner is the owner of this script.    {    llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, fullbright = !fullbright]);    }}}

 

Link to comment
Share on other sites

Hi,

 

Having come across this thread and finding what ElPanch was askign for was very similar to what i wanted for my home, I went ahead and created the 2 scripts as listed above.

So, its all working well but i'd also like to change not just the fullbright, but the glow as well.

I am a total script noob. In the script which changes the prim parameters I added this line:

llSetPrimitiveParams( [PRIM_GLOW, ALL_SIDES, 0.3] );

Ok so now when the light is turned on, it also glows - success!  .... but unfortunately when i turn the light off again, the full bright switches off, but the glow remains. What have i missed?

Link to comment
Share on other sites

You haven't turned the glow off yet.  :smileywink:

To do that, you'll need

llSetPrimitiveParams([PRIM_GLOW,ALL_SIDES,0.0]);

As the script is written, however, that's not going to help by itself, because the On/Off switch is in the call that handles the PRIM_FULLBRIGHT. The OP did a great job with that switch, but it needs reworking to tell the script when to activate one of the two lines that deal with glow. One way is

integer ch=-19020555;//Channel for reception(Number same as a transmission channel)  integer fullbright;default{    state_entry()    {        llListen(ch,"",NULL_KEY,"");    }    listen(integer channel, string name, key id, string msg)    {        fullbright = !fullbright;        llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, fullbright, PRIM_GLOW,ALL_SIDES,0.3*fullbright]);    }}

 Notice that the switch changes from ON to OFF (TRUE to FALSE, 1 to 0) and then you apply its new state to everything that follows.  Notice also that you can combine the two actions -- full_bright and glow -- in the same call. The value for glow will now change from 0.0 to 0.3 as fullbright switches from OFF to ON.

As GTASkinCentral commented in his note, there are other things you can add to the script to make it jump through fancier hoops or make it even safer from misuse. As written, though, this is a good, basic toggle switch that now toggles more than one function.

Link to comment
Share on other sites

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

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
 Share

×
×
  • Create New...