Jump to content

List placements. Question.


TessaAnnaMarie
 Share

You are about to reply to a thread that has been inactive for 342 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Okay i have 2 lists. I'll keep it simple here. 

list Numbers = ["1", "2", "3", "4", "5"]
list Letters = ["A", "B", "C", "D", "E"]

What I need to do is check to see if something is in a list. 

if(msg == llListFindList(Numbers, (Numbers)msg))
{
      llSay(0, **this is where I need help**);
}

Simple. But what I need the outcome to do is use the letter that corresponds to the number. Meaning if the message is "3", the outcome will say "C". I'm pretty sure this is doable, but I can't for the life of me figure out how. 

Link to comment
Share on other sites

I'm not in front of a computer that can run SL at the moment, so I can't test it, but I believe you do this:
 

Do_The_Thing( string value ) {

    integer n;

    n = llListFindList( Numbers, [value] );

    if (-1 == n) {

          // not found

    } else {

        llOwnerSay( llList2String( Letters, n ) );

    }

}

The difference between this & your original code is that this one saves the result from llListFindList &, if it's in range (not -1), uses it as the index into the Letters list.

 

Edited by CmpZ
Corrected type of second actual argument to llListFindList
  • Like 1
Link to comment
Share on other sites

17 minutes ago, CmpZ said:

I'm not in front of a computer that can run SL at the moment, so I can't test it, but I believe you do this:
 

Do_The_Thing( string value ) {

    integer n;

    n = llListFindList( Numbers, value );

    if (-1 == n) {

          // not found

    } else {

        llOwnerSay( llList2String( Letters, n ) );

    }

}

The difference between this & your original code is that this one saves the result from llListFindList &, if it's in range (not -1), uses it as the index into the Letters list.

 

Thank you! Some minor adjustments and yes, this works! Thank you!

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 342 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...