Don't click here unless you want to be banned.

LSL Wiki : ExampleGetRootPos

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are
This function returns the position of the root object, even if called
from a child object.

-- Xylor

Also see llGetRootPosition.

vector GetRootPos() {
    // If this object is not linked, or if it is the
    // root object, just return llGetPos()
    integer LinkNum = llGetLinkNumber();
    if (LinkNum <= 1)
        return llGetPos();
    // Otherwise take local position into account.
    return llGetPos() - llGetLocalPos();

Comments [Hide comments/form]
Thats odd... unless I am totally off, why are you subtracting llGetLocalPos() from llGetPos()? llGetPos() always returns the position of the parent object in a linked set, unless they changed it on us.
-- ChristopherOmega (2004-02-17 20:06:11)
Also, changed if(LinkNum
0 || LinkNum
1) to if(LinkNum <= 1). One less command to process :) (Remember, the virtual machiene doesn't care about short circuit operators, so its best to use one comparison rather then two).
-- ChristopherOmega (2004-02-17 20:07:46)
:sigh: If only I could edit my commend :-/ The wiki parser completely mangled it. Here's the corrected version:

Changed if(LinkNum == 0 || LinkNum == 1) to if(LinkNum <= 1).
-- ChristopherOmega (2004-02-17 20:09:47)
Just delete the comment and redo it...
-- EepQuirk (2005-03-17 17:42:46)
Attach a comment to this page: