Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help: I don't like to move nearby objects.

Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
04-28-2005 19:17
Hello there,

I'm still sticking with "Touch and Move Objects". :D
OK, I explain it briefly.
There are three objects lined up vertically. They are named "a1", "a2",
and "a3" from the bottom. Now, if you tocuh "a3", it goes up only by
itself. But if you tocuh "a2", it goes up with "a3". And if you touch
"a1", all objects go up together.
Each object says, "llSay(n, llGetObjectName() + " up";);" when you tocuh
it. That is, when "a1" goes up and says, "a1 up", "a2" hears it and goes
up and says, "a2 up" and so on.

Now, here is a problem. There may be the same objects lined up as near.
If you touch "a2", "a3" which is nearby will also go up. I don't like to
do it.

Conditon:
1. Owner has nothing to do with it. Everbody can touch and move them.
2. The same name lining up objects are within 5m distance.
3. I can't change the objects' name on the each vertical line.

It is on the same vertical line that allows objects to move.

Could anyone plz tell me what to do?
_____________________
:) Seagel Neville :)
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
04-28-2005 19:37
There are a couple things you can do to solve this problem.

1) Use a different command channel for each "nearby" group. You can randomize this fairly easily with something like this:

CODE
// Touch one of the objects after you've rezzed the entire set of three
// This will initialize all of them to the same channel

integer init_channel = 10000; // Initialization Channel
integer g_listener = FALSE; // Variable for the initial listener

default
{
state_entry()
{
g_listener = llListen(init_channel,"","","");
}

touch_start(integer total_number)
{
integer next_chan = (integer)(llFrand(1000000) + 10);
llListenRemove(g_listener);
llSay(init_channel,(string)next_chan);
g_listener = llListen(next_chan,"","","");
}
listen(integer chan, string name, key id, string msg)
{
if(chan == init_chan)
{
llListenRemove(g_listener);
g_listener = llListen((integer)msg,"","","");
}
}
}

... which is more code written out of world.

2) You can do this by sending keys instead of channel numbers.
3) You can do it with randomizing the names.
... etc.

Basically, so long as you uniquely identify a group, you'll be fine.
_____________________
---
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
04-28-2005 20:46
Hi Jeffrey,

It's always very kind of you! Thank you so much. :)
_____________________
:) Seagel Neville :)
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
04-28-2005 23:39
You could also use something like llGetPos() and check that the x and y components are the same, or close enough (so you check the a1 that's just something is actually under you).

You'd have to amend your llSay and add the x and y parts of it's position, say after commas so you can use llCSV2List to parse the parts. That said you control the message so you can control the length of the parts precisely and do it with sub-strings easily enough.
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
04-29-2005 09:49
Hello Eloise,

Wow, nice idea! Thank you. :)
_____________________
:) Seagel Neville :)