Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Thats right another child prim llSetPos question

Techzen Omega
Registered User
Join date: 31 Dec 1969
Posts: 58
02-18-2005 14:58
For the details...

Prim 1 - Base object, doesn't need to move or do anything

Prim 2 - Sits inside prim 1, top exposed, touch top and it rises out of prim 1 (think jack in the box or whatever)

Prim 3 - Linked to side of Prim 2, has texture animations, Needs to rise out of prim 1 with prim 2

Ok my problem is that Prim 1 and 2 are ok. But when i link prim 3 to prim 2 and then prim 2 &3 to prim 1... Prim 3 won't move with prim 2

Here is what i have in prim 2 :


integer open = 0;

default
{
touch_start(integer touchees)
{
open = !open;
if(open) llSetPos(llGetLocalPos() + <0, 0, 0.8>;);
else llSetPos(llGetLocalPos() + <0, 0, -0.8>;);
}
}


I've been reading over the wikki but am such a freaking script noob it's not funny. Found some stuff on passtouch but it doesn't seem like it would help as it says it passes from child to parent.

I tried adding the same script into prim 3 but that doesn't work either as there is no way to touch it.

Is there a way to have prim 2 send a message to prim 3 and have it move with prim 2? I saw Messages on the wikki but don't understand how to do them.

Any help would be apreciated.
TIA
_____________________
___________________________________________________

"Techzen, you definitely DO NOT suck at the forums." - Alicia Eldritch


"Do you think I'd get in trouble if I took a portable paint sprayer on a paintball field and said it was a paintball flamethrower"? "---SenorBiggles (Anandtech Forums)
Racer Plisskin
Rezerator
Join date: 2 Jan 2005
Posts: 147
02-18-2005 15:18
If the base prim never needs to move, why does it have to be linked to the moving prims?

Can you make #2 the base and link #3 to #2? That way, the touch event that moves #2 simply caries #3 with it.

If you do need to have all 3 linked together, you can use llLinkMessage to tell the 3rd prim to move as the last command befor llSetPos on #2.

I have a similar situation on a car. I have a 2 part door (door & window) that rotates up when touched. If either prim is touched, it sends a message to the other to move and then moves itself.

Admitedly, this does look odd in buisy SIMS as the two parts don't always stay synchronized, but it should serve to do what it sounds like you need.

I'm at work now or I would paste in a code sample on how it's done.

Racer P.
Techzen Omega
Registered User
Join date: 31 Dec 1969
Posts: 58
02-18-2005 15:41
Yeah I can get it to work without linking 2 & 3 to prim 1 but would like all the prims linked so others don't have to line everything up.

I also came up with a way of just getting rid of prim 3 all together by making more textures and having them animate on prim 2 front face.

But this is not a real fix as it limits the objects usability and I am trying to do allot of this to have a better understanding of how scripts work.

Right now all my scripting is just hacking away at scripts I can find, so If you can post it when you have time I would appreciate it. No hurry as I'll go have another look at the llLinkMessage some more too.

Thanks for the help. :)
_____________________
___________________________________________________

"Techzen, you definitely DO NOT suck at the forums." - Alicia Eldritch


"Do you think I'd get in trouble if I took a portable paint sprayer on a paintball field and said it was a paintball flamethrower"? "---SenorBiggles (Anandtech Forums)
Racer Plisskin
Rezerator
Join date: 2 Jan 2005
Posts: 147
02-18-2005 16:14
OK.

Basicaly, both prims get the same script as far as movement is concerned.

The difference is that #2 has an additional link message that gets sent just before it starts it's move and #3 has a link message event handler that trigers it's move so it follows #2.

EG: #2 has 2 llLinkMessage statements. One to tell #3 to move up and one to tell #3 to move down. #3 has a link message event handler that you parse. if string == "move up" then setPos up. if string =="move down" then setPos down. etc...

Like much of the LSL language, it sounds more complicated than it is.

If you want the user to be able to touch #3 as well as #2 to make the prims drop down again, you need to have both prims send and listen for messages back and forth to each other (how my doors work).

Here's the basic logic I'm using. (You need to have 2 sends (one for open and one for close) and you need to parse the incomming message and take appropriate action on the receiving side.)

--EDIT--
OK, I've added a LOT more detail to the code. I didn't have much time the other night... ;)

You could link the objects in a specific order and change the LINK_ALL_OTHERS to the specific prim you want in order to make the code below slightly more efficient as well.

door:
CODE

integer is_open = FALSE; // assume door starts out closed
vector open_vector;
vector closed_vector;

default
{

state_entry()
{
open_vector = (<YOUR VECTOR>);
closed_vector = (<YOUR VECTOR>);
}

touch_start
{
if ( is_open )
}
llLinkMessage(LINK_ALL_OTHERS, 0, "CLOSE WINDOW", NULL_KEY);
llSetPos(closed_vector);
is_open = TRUE;
{
else
{
llLinkMessage(LINK_ALL_OTHERS, 0, "OPEN WINDOW", NULL_KEY);
llSetPos(open_vector);
is_open = FALSE;
}
}

link_message(integer sender_num, integer num, string str, key id)
{
if ( str == "OPEN DOOR" )
{
llSetPos(open_vector);
is_open = FALSE;
}

if ( str == "CLOSE DOOR" )
{
llSetPos(closed_vector);
is_open = TRUE;
{
}
}


window:
CODE

integer is_open = FALSE; // assume window starts out closed
vector open_vector;
vector closed_vector;

default
{

state_entry()
{
open_vector = (<YOUR VECTOR>);
closed_vector = (<YOUR VECTOR>);
}

touch_start
{
if (is_open)
{
llLinkMessage(LINK_ALL_OTHERS, 0, "CLOSE DOOR", NULL_KEY);
llSetPos(closed_vector);
is_open = TRUE;
}
else
{
llLinkMessage(LINK_ALL_OTHERS, 0, "OPEN DOOR", NULL_KEY);
llSetPos(open_vector);
is_open = FALSE;
}
}

link_message(integer sender_num, integer num, string str, key id)
{
if ( str == "OPEN WINDOW" )
{
llSetPos(open_vector);
is_open = FALSE;
}

if ( str == "CLOSE WINDOW" )
{
llSetPos(closed_vector);
is_open = TRUE;
{
}
}


--END EDIT--

Racer P.
Techzen Omega
Registered User
Join date: 31 Dec 1969
Posts: 58
02-18-2005 16:26
Very cool and Big Thanks!

I'm side tracked doing some tech support for a friend of a friend but will try it later when I can log back in.
_____________________
___________________________________________________

"Techzen, you definitely DO NOT suck at the forums." - Alicia Eldritch


"Do you think I'd get in trouble if I took a portable paint sprayer on a paintball field and said it was a paintball flamethrower"? "---SenorBiggles (Anandtech Forums)
Racer Plisskin
Rezerator
Join date: 2 Jan 2005
Posts: 147
02-20-2005 09:49
/bump

OK, I've updated the code samples above so they are much more meaningfull now... ;)