Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

how to set terminal points of child llSetPos()?

Lulu Ludovico
Registered User
Join date: 24 Jan 2005
Posts: 27
02-21-2005 02:23
Hi,

Anyone can help with this?

Imagine a 3-prim object (say a lipstick container Prim #1 and a a 2-prim lipstick, Prim #2 and Prim #3), all linked. I'd like to be able to get the lipstick (Prim #2 and #3) to move out of the container upon touching Prim #2, and to recede back to the container upon touching Prim #3.

How do I set the extreme limits of Prim #2 and #3 so they don't move upwards or downwards forever (or up to 10m) when touched?

Thanks a bunch.
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
02-21-2005 03:07
Well, assuming things about your build I can't know...

CODE


vector position = <0,0,0>; // Uh, whatever fully retracted might be.
// and I'm assuming extended is along the Z axis.
float myz = 0;

link_message( integer src, integer num, string msg, key id)
{
if ( msg == "extend" )
{
myz = myz + 0.01;
if ( myz > 1.0 ) myz = 1.0;
position.z = myz;
llSetPos(position);
}
else if ( msg == "retract" )
{
myz = myz - 0.01;
if ( myz < 0.0 ) myz = 0.0;
position.z = myz;
llSetPos(position);
}
}


And the scripts in the other two prims would just send the extend and retract messages with llMessageLinked.

Someone will be along shortly to teach me a better way :p
_____________________
Lulu Ludovico
Registered User
Join date: 24 Jan 2005
Posts: 27
Syntax error
02-22-2005 02:01
okay I modified the above code a little in my experiment (forgive my poor newbie scripting skills). Unfortunately it hit a syntax error and I can't figure out what's the problem:

CODE
default
{

state_entry()
{
vector position = <0,0,0>;
float myx = 0.5;
}

touch_start(integer total_number)
{
myx = myx - 0.01; // <===SYNTAX ERROR HERE
if ( myx < 0.0 ) myx = 0.0;
position.x = myx;
llSetPos(position);


vector location = llGetLocalPos();
llSay(0,(string)location);
}
}


The error message was: Name not defined within scope, and the cursor was pointing at the first "myx". Any ideas?

Thanks,
Lulu
Moleculor Satyr
Fireflies!
Join date: 5 Jan 2004
Posts: 2,650
02-22-2005 08:14
Move the "float myx = 0.5" out to above the default line. Where you have it now, that variable exists only within the state_entry event, and disappears essentially as soon as it's created. When you move it above the default (and outside of the state) it becomes a global variable available at all times.
_____________________
</sarcasm>
Lulu Ludovico
Registered User
Join date: 24 Jan 2005
Posts: 27
Thanks!
02-23-2005 03:04
Thanks very much! Will try that. ;)