Difference between revisions of "Window Control"
Jump to navigation
Jump to search
m (fix) |
m (Replaced <source> with <syntaxhighlight>) |
||
(One intermediate revision by one other user not shown) | |||
Line 6: | Line 6: | ||
Put this in the windows; | Put this in the windows; | ||
< | <syntaxhighlight lang="lsl2"> | ||
// script that changes opacity of object based on external messages | // script that changes opacity of object based on external messages | ||
Line 32: | Line 32: | ||
llSetAlpha(opacityLvl, ALL_SIDES); | llSetAlpha(opacityLvl, ALL_SIDES); | ||
} | } | ||
}</ | }</syntaxhighlight> | ||
== Window Switch == | == Window Switch == | ||
Put this in a switch; | Put this in a switch; | ||
< | <syntaxhighlight lang="lsl2"> | ||
// script for a switch that controls window opacity | // script for a switch that controls window opacity | ||
integer gOpacityLevel = 0; // current opacity level of windows | integer gOpacityLevel = 0; // current opacity level of windows | ||
Line 60: | Line 60: | ||
llSay(gChannel, opacityCmd); | llSay(gChannel, opacityCmd); | ||
} | } | ||
}</ | }</syntaxhighlight> | ||
== How to work it == | == How to work with it == | ||
When you've put all the window opacity scripts in and done the switch, just click the switch to cycle through transparent and opaque. | When you've put all the window opacity scripts in and done the switch, just click the switch to cycle through transparent and opaque. |
Latest revision as of 17:50, 10 April 2022
What it does
Window Control is basically just to change the opacity of windows and such, helpful for buildings.
Window
Put this in the windows;
// script that changes opacity of object based on external messages
integer gChannel = 5; // 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.1 - ((opacityLvl / 3) * 0.9);
llSetAlpha(opacityLvl, ALL_SIDES);
}
}
Window Switch
Put this in a switch;
// script for a switch that controls window opacity
integer gOpacityLevel = 0; // current opacity level of windows
integer gChannel = 5; // 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);
}
}
How to work with it
When you've put all the window opacity scripts in and done the switch, just click the switch to cycle through transparent and opaque.