Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Logic in If Statements

Laurence Llewellyn
Registered User
Join date: 4 Aug 2007
Posts: 8
08-11-2007 08:43
How could I either:

a) Have an if statement which relies on a message output from a llDialog matching any of a list of strings

ie, in a sort of pseudo-code:

If (message = "word1" OR "word2" OR "word3";)

or

b) Have an if statement rely upon a string being present in a predefined list?

Thanks
Espresso Saarinen
old geek
Join date: 22 Jan 2006
Posts: 93
08-11-2007 08:52
list src = ["word0", "word1"];
if ( llListFindList(src, [message])
Laurence Llewellyn
Registered User
Join date: 4 Aug 2007
Posts: 8
08-11-2007 09:10
Hmm, this doesn't seem to be working. Here's what I've got:


if(llListFindList(songs, [message]))
{
chosensong = message;
llLoopSound(chosensong, 1);
}



This is within a listen event. When I had this:


if(message = "sound1";)
{
chosensound = message;
llLoopSound(chosensound, 1);
}


It seemed to work. But what I'm trying to achieve is to have multiple possibilities where "sound1" is. When I switched it for the llListFindList, it seemed to just do nothing.

Edit: I changed the statement to:

if(llListFindList(songs, [message]) != -1)

And that seems to work.

Thanks.
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
08-11-2007 11:21
has to be done in pairs

if ( (word_one || word_2) || word_3)

or

if ( (word_one || word_2) || (word_3 || word_4) )

or

if ( ((word_one ||word_2) || (word_3 || word_4)) || word_5)

ect
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
08-11-2007 11:46
list options = [ "one", "two", "three"];

if (llListFindList(option, [message]) != -1) { ... }

http://www.lslwiki.net/lslwiki/wakka.php?wakka=llListFindList
_____________________
http://slurl.com/secondlife/Together
Jotheph Nemeth
Registered User
Join date: 9 Aug 2007
Posts: 142
08-11-2007 11:51
From: Laurence Llewellyn

if(llListFindList(songs, [message]) != -1)

And that seems to work.

Thanks.


That's because the 0 index is the first item in a list. -1 returns if it doesn't find the item in the list.