|
Aniam Ingmann
llOwnage(float pwnage);
Join date: 22 Oct 2005
Posts: 206
|
10-26-2007 02:56
What do you you think would happen if you were in a Listen event, and you wrote this: " if (msg >= "hello"  { llSay(0,"Hello "+llDetectedName(0)+"!"  ; } " What would using a greater than or equal sign do? Could I maybe say 'helloperson' and it would return pretty much the same thing as if it heard just a 'hello'?
_____________________
From: someone Don't worry, Aniam is here! - Noob
|
|
Stephen Zenith
Registered User
Join date: 15 May 2006
Posts: 1,029
|
10-26-2007 03:08
Not sure if <, <=, > and >= are defined for strings. However, you can always do something like: integer StringStartsWith (string a, string prefix) { // prefix is longer than whole of string a, a can't begin with prefix if (llStringLength (prefix) > llStringLength (a) ) return FALSE; if (llGetSubString (a, 0, llStringLength (prefix) - 1) == prefix) return TRUE; return FALSE; } if (StringStartsWith (msg, "hello"  ) { llSay(0,"Hello "+llDetectedName(0)+"!"  ; }
|
|
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
|
10-26-2007 03:35
From: Aniam Ingmann What do you you think would happen if you were in a Listen event, and you wrote this: " if (msg >= "hello"  { llSay(0,"Hello "+llDetectedName(0)+"!"  ; } " What would using a greater than or equal sign do? Could I maybe say 'helloperson' and it would return pretty much the same thing as if it heard just a 'hello'? Greater than or less than comparisons can't be done on strings in LSL, you'll get a compiler error. You can always try comparing the string lengths, or something similar..
|
|
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
|
10-26-2007 04:58
From: Aniam Ingmann Could I maybe say 'helloperson' and it would return pretty much the same thing as if it heard just a 'hello'? For that, you'd want something like: if( llSubStringIndex( msg, "hello" ) == 0 )
|
|
Bloodsong Termagant
Manic Artist
Join date: 22 Jan 2007
Posts: 615
|
10-26-2007 07:22
if you use
if( llSubStringIndex( msg, "hello" ) != -1 )
you can find it anywhere in the string, not just starting position. (if you wanted). to be really really really REALLY sure to get all the hello's, you can also do llToLower(msg), "hello"
_____________________
Why Johnny Can't Rotate: http://forums.secondlife.com/showthread.php?t=94705
|
|
Aniam Ingmann
llOwnage(float pwnage);
Join date: 22 Oct 2005
Posts: 206
|
10-26-2007 10:22
Heh okay, cool. Thanks.
_____________________
From: someone Don't worry, Aniam is here! - Noob
|