Search code examples
linden-scripting-language

Change transparency of another object


I'm writing an LSL script attached to an object, and would like to change the transparency of another object which I have the UUID of (stored in a key variable).

I've read the documentation but can't even work out how to change the name/description of another object, let alone the transparency. I can only find methods for modifying the local object.

Does LSL not support modification of the properties of other objects, even when they're in the same region and have the same owner?


Solution

  • If it's in the same region then you could just add llListen() in one prim and use llRegionSay() in the other on a private channel.

    Like this:

    Prim 1 Script (Prim sending the command)

    default
    {
        state_entry()
        {
        }
    
        touch_start(integer total_number)
        {
            llRegionSay(-123456,"1.0"); // Channel -123456 can be anything.  "1.0" will be the transparency setting passed to the 2nd prim
        }
    }
    

    Prim 2 Script (Prim receiving the command)

    default
    {
        state_entry()
        {
            llListen(-123456, "", "", ""); // Make the prim listen
        }
        listen( integer channel, string name, key id, string message )
        {
            if (channel==-123456) {  // Match the same private channel
                llSetAlpha((float)message, ALL_SIDES);  // Convert "message" into an integer and pass to the llSetAlpha() function as the transparency - 0 = invisible  1 = visible
            }
        }
    }