Jump to content

Recommended Posts

Posted

Hello,

I have a small function that I often use to create list of the linked prims including their link numbers.

This saves me having to swap the linked prims around when adding further prims or/and having to change my coding each time.

This is a small script I wrote to show my problem:

default
{   state_entry()
    {   integer LinkNrforPIN;
        llOwnerSay("LinkNrforPIN="+(string)LinkNrforPIN); // Obvious, but wanted to show the content of this variable at the start
        integer linknr  = 2;
        integer linkmax = llGetNumberOfPrims();
        while (linknr <= linkmax)
        {   llOwnerSay("Link number "+(string)linknr+" has link name = "+llGetLinkName(linknr));
            if (llGetLinkName(linknr) == "PIN");
            {   LinkNrforPIN = linknr; // I am looking for the link number of this specific prim
            }
            ++linknr;
        }
        llOwnerSay("LinkNrforPIN="+(string)LinkNrforPIN);
    }
}

The result is:
[10:28] LinkTest: LinkNrforPIN=0
[10:28] LinkTest: Link number 2 has link name = PIN
[10:28] LinkTest: Link number 3 has link name = ON_OFF
[10:28] LinkTest: Link number 4 has link name = JS-Text:name:0:2
[10:28] LinkTest: Link number 5 has link name = JS-Text:name:0:1
[10:28] LinkTest: Link number 6 has link name = JS-Text:name:0:0
[10:28] LinkTest: Link number 7 has link name = JS-Text:pin:0:0
[10:28] LinkTest: LinkNrforPIN=7 ?????????????

It seems to be telling me that the Prim with the name "JS-Text:pin:0:0" is equal to the string "PIN" instead of the Prim with the link number 2 ?

 

Do I need new glasses or a new brain??? 🤪

Posted
if (llGetLinkName(linknr) == "PIN");

Note the trailing semicolon. That statement does nothing. The following block is always executed.

  • Like 1

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...