|
Evol Menoptra
Registered User
Join date: 25 Nov 2005
Posts: 7
|
04-16-2006 12:05
silly title perhaps but what I ment is I normaly can do like say something like hello and the script does some action but saying like hello there doesn't work..
my question is how to make a piece of code that reacts on keywords
hope that makes some sense..
|
|
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
|
04-16-2006 12:18
in your listen event use if else statements ie:
listen(integer channel, string name, key id, string message) { if (message == "hello") llSay(0,"hello " + name); else if (message == "red") llSetColor(<1,0,0>,ALL_SIDES); else llSay(0,"invalid command"); }
|
|
Evol Menoptra
Registered User
Join date: 25 Nov 2005
Posts: 7
|
reply
04-16-2006 12:26
well its what I kinda am doing but I have to write that certain word and what I like to do is having a line like.. hey you hello there and have the script handle the word hello in that line no matter where placed... as far it works no I have to write hello... nothing before or after that word  hope that clears it up a lil, thanks none the less
|
|
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
|
04-16-2006 12:44
oh well 2 options llGetSubString which takes a predefined chunk of a string and makes it into its own element and llSubString Index, which in this case would need llGetSubString too, but it allows you to seach the string for a pattern and return the position of it ie integer x = llSubStringIndex(message," "  - 1); if (llGetSubString(message,0,x) == "hello"  do stuff http://secondlife.com/badgeo/wakka.php?wakka=string
|