Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Touch texture change using states - window example

ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
09-16-2006 09:04
Here is a script using touch to rotate between two different textures. I tested these scripts in SL before posting them here.

If you use the texture name, such as "window" in the llSetTexture call, then you must also include the texture in the object contents with the script. You can use the UUID of the texture instead, which is what I prefer to do, as it simplifies the permissions issues.

These will respond to anyone's touch, not just those you give permissions to. That is another level of complications I have not addressed.

CODE
//This script rotates between textures window and blind textures when touched.

default
{
touch_start(integer total_number)
{
llSetTexture("window",ALL_SIDES);//the texture shown in the default state is "window".
llSetAlpha(1.0,ALL_SIDES);//1.0 shows all of a texture, 0.0 shows none
llScaleTexture(1,1, ALL_SIDES);//adjusts texture scale if needed.
state blinds;

}
}
state blinds
{
touch_start(integer total_number)
{
llSetTexture("blinds",ALL_SIDES);
llSetAlpha(1.0,ALL_SIDES);
llScaleTexture(1,1, ALL_SIDES);
state default;
}
}


Here is another example rotating between 3 textures:

CODE
//This script rotates between textures 3 textures when touched.

default
{
touch_start(integer total_number)
{
llSetTexture("window",ALL_SIDES);//the texture shown in the default state is "window".
llSetAlpha(1.0,ALL_SIDES);//1.0 shows all of a texture, 0.0 shows none
llScaleTexture(1,1, ALL_SIDES);//adjusts texture scale if needed.
state blinds;

}
}
state blinds
{
touch_start(integer total_number)
{
llSetTexture("blinds",ALL_SIDES);
llSetAlpha(1.0,ALL_SIDES);
llScaleTexture(1,1, ALL_SIDES);
state stone;
}
}
state stone
{
touch_start(integer total_number)
{
llSetTexture("stone",ALL_SIDES);
llSetAlpha(1.0,ALL_SIDES);
llScaleTexture(1,1, ALL_SIDES);
state default;
}
}
_____________________

VRchitecture Model Homes at http://slurl.com/secondlife/Shona/60/220/30
http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=2240
http://shop.onrez.com/Archtx_Edo
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
09-16-2006 13:48
/15/79/137912/1.html
_____________________
i've got nothing. ;)
Soen Eber
Registered User
Join date: 3 Aug 2006
Posts: 428
04-18-2007 18:15
An evolution on the 3 way blind script - switches between a window, open blinds, and closed blinds. The window texture is semi-transparent. The blind textures are grayscale, and can be set to any color with normal editing controls.

Setting one blind via touch sets all blinds to the same setting. Because I had to retrofit a window blinds script to an existing build, I couldn't use link messages to communicate between blinds - couldn't ask the owner to unlink and relink everything - hence the use of chat. This is a drop-in script for any normal window.

CODE

//This script rotates between textures 3 textures when touched.

integer channel = -1212;
string blinds_open = "638591c2-16e8-6b84-6561-5fb681bf0f10";
string blinds_closed = "5e78b55b-ec4f-53af-96d3-8a063cfa0371";
string glass = "59facb66-4a72-40a2-815c-7d9b42c56f60";

switch(string blind_state)
{
if (blind_state == "default") state default;
if (blind_state == "open") state open;
if (blind_state == "close") state close;
}
default
{
state_entry()
{
llListen(channel, "", NULL_KEY, "" );
llSetTexture(glass,ALL_SIDES);//the texture shown in the default state is "window".
llSetAlpha(1.0,ALL_SIDES);//1.0 shows all of a texture, 0.0 shows none
llScaleTexture(1,1, ALL_SIDES);//adjusts texture scale if needed.
}
touch_start(integer total_number)
{
llShout(channel, "open");
state open;
}
listen( integer channel, string name, key id, string message )
{
if (llSameGroup(id)) switch(message);
}
}
state open
{
state_entry()
{
llListen(channel, "", NULL_KEY, "" );
llSetTexture(blinds_open,ALL_SIDES);
llSetAlpha(1.0,ALL_SIDES);
llScaleTexture(1,1, ALL_SIDES);
}
touch_start(integer total_number)
{
llShout(channel, "close");
state close;
}
listen( integer channel, string name, key id, string message )
{
if (llSameGroup(id)) switch(message);
}
}
state close
{
state_entry()
{
llListen(channel, "", NULL_KEY, "" );
llSetTexture(blinds_closed,ALL_SIDES);
llSetAlpha(1.0,ALL_SIDES);
llScaleTexture(1,1, ALL_SIDES);
}
touch_start(integer total_number)
{
llShout(channel, "default");
state default;
}
listen( integer channel, string name, key id, string message )
{
if (llSameGroup(id)) switch(message);
}
}
Liekie Ivory
huh huh..
Join date: 28 Feb 2007
Posts: 10
07-20-2007 16:55
Soen, I've got 2 questions about your script:

First: how can I lock the windows so the owner and the persons who are authorised are the only ones to control the windows?

Second: how can I use this script in combination with a remote control and more as 1 window?
Soen Eber
Registered User
Join date: 3 Aug 2006
Posts: 428
07-20-2007 23:57
Access is determined by group membership. If you are in the same group the windows containing the blinds are in, they will pay attention to you.

For the remote, I *think* after a cursory look at the script, that if you drop the same script into a remote control prim but remove the commands that set the texture & alpha (i.e., just leave the state changes and communication code in) that it should work...I think.