Window Opacity

Written by: Headmaster

This script changes the opacity of windows. It includes the script for the window and the controller script.

Window Opacity Script:

// script that changes opacity of object based on external messages

integer gChannel = 50; // communication channel on which we listen for opacity change commands
integer gLastListen; // id of last listen command

default
{
    state_entry()
    {
        gLastListen = llListen(gChannel, "", "", "0");
    }
    
    listen(integer channel, string name, key id, string msg)
    {
        llListenRemove(gLastListen);
        
        integer nextOpacityLvl = (integer)msg;
        nextOpacityLvl += 1;
        if (nextOpacityLvl > 3) nextOpacityLvl = 0;
        gLastListen = llListen(gChannel, "", "", (string)nextOpacityLvl);
        
        float opacityLvl = (float)msg;
        opacityLvl = 1 - ((opacityLvl / 3) * 0.9);
        llSetAlpha(opacityLvl, ALL_SIDES);
    } 
} 

 

Controller Script:

// script for a switch that controls window opacity
integer gOpacityLevel = 0; // current opacity level of windows
integer gChannel = 50; // channel that controls which windows respond to this switch

default
{
    state_entry()
    {
       
    }
    
    touch_start(integer num_touchers)
    {
        gOpacityLevel += 1;
        if (gOpacityLevel > 3)
        {
            gOpacityLevel = 0;
        }
        string opacityCmd = "";
        opacityCmd = opacityCmd + (string)gOpacityLevel;
        llSay(gChannel, opacityCmd);
    }
}