Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

help needed - each touched box sets a different texture

Rigrunner Rang
...Newb
Join date: 23 May 2007
Posts: 162
04-12-2008 00:24
Hi all,

I don't have the most logical mind and I'm a little confused as to how I go about scripting this little project.

I've got 4 small boxes and one large one. Each small box will have a different texture on it. I'd like the texture to appear on the large box when the small images are touched by somebody.

Here's an image to help make my explanation clearer (I hope!)



So... Where would I start?

Thanks in advance

EDIT: Ideally I'd like them not to be linked prims!
_____________________
Visit Knockout!
http://slurl.com/secondlife/Junlong/164/135/51
Cerulean Deadlight
Registered User
Join date: 6 May 2007
Posts: 28
04-12-2008 01:09
I think I would put this script in each of the 4 boxes.

default
{

touch_start(integer total_number)
{
llSay(-198165, llGetObjectName());
}
}


All it does is says the object name on channel -198165. So you would give each box a different name based on the texture.

Then in the larger box I'd put this one.


default
{

state_entry()
{
llListen(-198165, "", "", "";);
}

listen(integer channel, string name, key id, string message)
{
if(message == "boxName1";)
{
llSetTexture("Texture UUID or Texture Name 1", ALL_SIDES);
}
else if(message == "boxName2";)
{
llSetTexture("Texture UUID or Texture Name 2", ALL_SIDES);
}
else if(message == "boxName3";)
{
llSetTexture("Texture UUID or Texture Name 3", ALL_SIDES);
}
else if(message == "boxName4";)
{
llSetTexture("Texture UUID or Texture Name 4", ALL_SIDES);
}
}
}


You could replace "ALL_SIDES" with an integer from 1-8 so the texture only appears on that one face.
Rigrunner Rang
...Newb
Join date: 23 May 2007
Posts: 162
04-12-2008 03:37
Hey, thanks very much for such a quick response!!
_____________________
Visit Knockout!
http://slurl.com/secondlife/Junlong/164/135/51
Kahiro Watanabe
Registered User
Join date: 28 Sep 2007
Posts: 572
04-12-2008 08:13
But if the boxes are linked you MUST use linked messages!
Beverly Ultsch
Registered User
Join date: 6 Sep 2007
Posts: 229
04-12-2008 09:17
If you want to be a bit more flexible you could try

small box's

CODE


default
{
touch_start(integer total_number)
{
llSay(-198165, llGetTexture(ALL_SIDES));
}
}



large box

CODE

default
{
state_entry()
{
llListen(-198165, "", "", "");
}

listen(integer channel, string name, key id, string message)
{
llSetTexture(message, ALL_SIDES);
}
}
Rigrunner Rang
...Newb
Join date: 23 May 2007
Posts: 162
04-12-2008 10:45
Thanks Beverly, another interesting solution! :-))

Object communication was the obvious way to do it, I was just a bit too slow to pick up on that ahahahaha...I don't have that logical programmer brain! It was nice of you guys to post code too.

Thanks again everybody, your help is greatly appreciated.
_____________________
Visit Knockout!
http://slurl.com/secondlife/Junlong/164/135/51
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
04-12-2008 11:15
From: Kahiro Watanabe
But if the boxes are linked you MUST use linked messages!

Should, not must.
_____________________
So many monkeys, so little Shakespeare.
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
04-12-2008 12:49
And remember to use llRegionSay instead of llSay. Keeps the simulator from having to process distances between objects.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Cerulean Deadlight
Registered User
Join date: 6 May 2007
Posts: 28
04-12-2008 14:51
I thought about sending the texture id directly, but I didn't know how important it was to Rigrunner to protect the textures, since someone could get the texture id if they knew which channel to listen on. It's definitely easier to use though.

I was under the impression that the smaller the chat radius, the less server resources would be used. Is that incorrect? EDIT: Apparently it is. Good to know!
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
04-12-2008 15:20
From: Cerulean Deadlight
I was under the impression that the smaller the chat radius, the less server resources would be used. Is that incorrect?

Indeed, that is incorrect.

During it's assigned slice of processor time, each listen processes all messages:

1st)Channel

2nd)Distance/llRegionSay

3rd)Key(if specified)

4th)Name(if specified)

5th)Message(if specified)

If it has to process llSay, then it has to get the position of the object the listen is in and check that against the position of the object/objects that have said something on that channel. With llRegionSay, it gets to skip that extra processing.

It seems counter-intuitive at first until you think about this scenario: Object A has a script that uses llSay on channel 20 and is located 20.001 meters from Object B which is listening on channel 20. During each slice of runtime, the simulator is having to do the extra work of discouting any messages said on that channel because it is .001 meters too far away. (haven't tested the exact distance tolerance, but you get the idea)
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Kahiro Watanabe
Registered User
Join date: 28 Sep 2007
Posts: 572
04-12-2008 16:10
From: Lee Ponzu
Should, not must.


MUST, for the love of no lag :D.