Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Any value of a list greater?

CamperDave Proudfoot
(_)|33P\ 1337 $xor
Join date: 16 Sep 2004
Posts: 205
05-19-2005 13:36
Hi.

Can someone show me the way to make a function that checks if ANY vaue is greater than or equal to a constant and returns the index of that number?

EX

list [1,6,2]

integer 6

should return 2.

Please help. :(
_____________________
The PWNED SHOP!


List of Cool Things I've done first... I think
  1. Put on sale a key mod that makes SL more like an FPS
  2. Made my own custom attachment points - looking for a good use
  3. Found "secret" login screen.
  4. Created a way to call Java methods from LSL --> Thread
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
05-19-2005 14:02
http://secondlife.com/badgeo/wakka.php?wakka=llListSort could make this more efficient, but for now...

CODE
list stuff = [0,20,10,4,25,16]; // Unformatted list

findGreater(integer num)
{
list test = llListSort(stuff,1,TRUE);
// Example syntax

integer count = llGetListLength(test);
integer i;

for(i = 0; i < count; ++i)
{
if(llList2Integer(test,i) >= num)
llOwnerSay((string)llList2Integer(test,i) + " is greater than or equal to your constant at index " + (string)i);
}
}
_____________________
---