Define a string using llListen
|
|
Suru Xia
Registered User
Join date: 26 Feb 2005
Posts: 20
|
04-01-2006 10:44
Ok, well I'm making an object which has multiple defined strings, for example: string test; string test2; string test3; And I want the user to be able to define those strings using a command, such as "/set test <desired text>". BUT, my problem, is that I can only seem to get llListen to recognize EXACT commands. This is why I think I need to replace *if (message == "/set etc."  * with something more dynamic. Is this possible? Kinda hard to explain but if you at least give me your best shot it would be greatly appreciated. I'm in game right now (10:46 AM GMT -8, April 1) if you wanna drop me a line, I would be ever thankful.  Thanks!
|
|
Nick Shatner
Isn't a game
Join date: 11 Jul 2005
Posts: 39
|
04-01-2006 11:15
You mean removing case sensitivity? string input; input = llToLower(input); if(input == "command"){ //Do stuff } [edit] Actually, I just realised what you meant, what you need to do is this: string input; if(llSubStringIndex(input, "/set ") != -1) { llSay(0, llDeleteSubString(input, 0, 4); }
passing "/set sometexthere" through that will say 'sometexthere'
|
|
Suru Xia
Registered User
Join date: 26 Feb 2005
Posts: 20
|
04-01-2006 11:56
Awesome thanks, I saw that substring script on the wiki, but wasnt sure what to make of it, and if it was what I needed. I'll try it out and let you know how it went. Thanks a bunch! (By the way I actually had that case sensitive thing in there already  )
|
|
Suru Xia
Registered User
Join date: 26 Feb 2005
Posts: 20
|
04-01-2006 14:16
Hmm, no luck yet, wanna run that by me again?  Im not sure how to tie listen into all this, and its just doing nothing  .
|
|
Keiki Lemieux
I make HUDDLES
Join date: 8 Jul 2005
Posts: 1,490
|
04-01-2006 14:42
One thing I do a lot is break a string down into words so I can test against specific criteria: default { state_entry() { llListen( 0, "", NULL_KEY, "" ); } listen( integer channel, string name, key id, string msg ) { list words = llParseString2List( msg, [ " " ], [] ); string command = llList2String( words, 0 ); string variable = llList2String( words, 1 ); string value = llList2String( words, 2 ); llSay( 0, "command = " + command ); llSay( 0, "variable = " + variable ); llSay( 0l, "value = " + value ); } }
_____________________
imakehuddles.com/wordpress/
|
|
Suru Xia
Registered User
Join date: 26 Feb 2005
Posts: 20
|
04-01-2006 15:21
Oh god, now I'm REALLY confused, and I think we are wayy off track from my original intentions. . .oh well.
|
|
Keiki Lemieux
I make HUDDLES
Join date: 8 Jul 2005
Posts: 1,490
|
04-01-2006 15:35
Ok sorry I didn't explain it when I posted it. Let me explain the code using comments and point you in the right direction. integer test = 0; integer test1 = 0; integer test2 = 0;
default { state_entry() { // begin listening to chanel 0 llListen( 0, "", NULL_KEY, "" ); } listen( integer channel, string name, key id, string msg ) { // break the message into a list of words list words = llParseString2List( msg, [ " " ], [] );
// type in /set test 0 and see what you get string command = llList2String( words, 0 ); string variable = llList2String( words, 1 ); string value = llList2String( words, 2 ); llSay( 0, "command = " + command ); llSay( 0, "variable = " + variable ); llSay( 0, "value = " + value );
// replace these llSay functions with check to see if someone actually says /set test maybe something similar to this:
if( command == "/set" && variable == "test" ) { test = (integer)value; } else if ( command == "/set" && variable == "test1" ) { test1 = (integer)value; } else if ( command == "/set" && variable == "test2" ) { test2 = (integer)value; } } }
_____________________
imakehuddles.com/wordpress/
|
|
Suru Xia
Registered User
Join date: 26 Feb 2005
Posts: 20
|
04-01-2006 20:35
Ahh I see what you mean. Actually we got it to work by using the llStringIndex and llDeleteIndex functions, er, think thats what its called. Thanks a bunch!
|