Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Rotation help with unlinked child

Cheewha Palen
Registered User
Join date: 27 Nov 2007
Posts: 78
05-09-2009 22:37
Hello all,

I am scripting a prim which will find the position of another prim (there is a script inside calling out position) to which the first prim will match position and rotation.

So far I have this working 90%.

The first prim finds the position just fine but does not adjust rotation. I am pretty sure I do not have the rotation correct in the following script:
//script
integer build_link_chan=999;

default
{
state_entry()
{
llListen(build_link_chan,"","","";);
}
listen(integer channel,string name,key id,string msg)
{
if(channel==build_link_chan)
{
llSetPos(((vector)msg)+<0,0,0>;);
llSetRot(<0,0,0,1>;);
}
}
}
//script


Can anyone plz offer advice if you know what I am doing wrong?

Thanks--cheewha
Cerulean Deadlight
Registered User
Join date: 6 May 2007
Posts: 28
05-09-2009 23:39
The child object is receiving the position but it's not receiving the rotation (because it's not even being sent).

You'd have to make the first object say its rotation too the same way you've done with the position.


You could also take a look at llGetObjectDetails(). You could have that first object say its key, and then the child object could take the key and get the rotation and position from that.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
05-10-2009 03:54
assuming the message sent is something like
"<vector>:<rotation>"

you could break it down with
list temp = llParseString2List( msg, [":"], [] );
and then apply them with
llSetRot( (rotation)llList2String( temp, 1) );
and
llSetPos( (vector)llList2String( temp, 0 ) + offset );

offset can be removed if you are putting the prim in that exact place, or it can be multiplied by the rotation to get an offset relative to the original position. (like one airplane being next to another)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Cheewha Palen
Registered User
Join date: 27 Nov 2007
Posts: 78
05-10-2009 11:13
Hi, sry I posted this late last nite prolly should have shown both scripts so you see my work. Most of this came from looking at apt rez scripts in the script library.

I have a simple need for something that works like a house rezzer...minus the rezzing part. So that when the parent box is moved or rotated the build with the child script will match its position.

Thank you everyone who posted! I know rotation is one of the hardest things to master for most so I apologize but I need further help.

Void in your example you said;

you could break it down with
list temp = llParseString2List( msg, [":"], [] );

Q: does this pertain to the parent or child script?

I am getting syntax errors trying to work this information into the scripts (syntax err, not within scope, type mismatched, etc). Sry I am just confused.

Here is the parent script which calls its position to the child scripts in the build

//script//

integer Nearby = 0;
integer build_link_chan=999;
integer channel=1000;



default
{
state_entry()
{
llListen(channel,"","","";);
llListen(build_link_chan,"","","";);
}
on_rez(integer total_number)
{
llSetTimerEvent(1.0);
}


timer()
{
llRegionSay(build_link_chan,(string)llGetPos());
}
}

//end script//

and here is the child script

//script//

integer build_link_chan=999;

default
{
state_entry()
{
llListen(build_link_chan,"","","";);
}
listen(integer channel,string name,key id,string msg)
{
if(channel==build_link_chan)
{
llSetPos(((vector)msg)+<0,0,0>;);
llSetLocalRot(<0,0,0,1>;);
}
}
}
//end script//

Thank you guys for any help!

cheewha
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
05-10-2009 18:56
my previous would go in the child script, the parent script needs to call
llRegionSay( build_link_chan, (string)llGetPos() + ":" + (string)llGetRot );

there's also no reason to add <0, 0, 0> in the child script... if you want it at the exact position of the build object, remove it, if it need to be offset, then you need some numbers in there
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -