help with wildcard
|
|
Chri5 Somme
:)
Join date: 18 Nov 2005
Posts: 204
|
03-29-2006 21:53
ok i am completely lost, the wiki didn't really give a good explination of how to use certain commands so I come to the forums, I am trying to make a little script that allows a user to type "/40 ls x" and then record x as the integer. It is just one integer and no list is needed or anything like that.
"/40" is the channel "ls" is the wildcard and "x" is the message following and converted to an integer.
I am totally stuck on this one, im trying to get the variable x to save as an integer after but I want the wildcard to be used inorder to use it. I looked up the llGetSubString and i'm lost, somebody please help?
|
|
Chri5 Somme
:)
Join date: 18 Nov 2005
Posts: 204
|
03-29-2006 22:35
never mind i figured it out. If you want a great example of how to use a wildcard then here you go. integer lh; default { state_entry() { lh = llListen(0, "", NULL_KEY, ""  ; } listen(integer channel, string name, key id, string message) { if (llSubStringIndex(llToLower(message), "ls"  == 0) { string param = llGetSubString(message, 3, -1); llSay(0, param); } } }
|
|
Chri5 Somme
:)
Join date: 18 Nov 2005
Posts: 204
|
03-29-2006 22:36
never mind i figured it out. If you want a great example of how to use a wildcard then here you go. integer lh;
default { state_entry() { lh = llListen(0, "", NULL_KEY, ""); } listen(integer channel, string name, key id, string message) { if (llSubStringIndex(llToLower(message), "ls") == 0) { string param = llGetSubString(message, 3, -1); llSay(0, param); } } }
|
|
Darkside Eldrich
Registered User
Join date: 10 Feb 2006
Posts: 200
|
03-30-2006 12:21
I just ran into this same problem, and I was afraid I'd have to do it this way. I know this is a "feature request / gripe", but can we get some regular expression parsing into LSL? Maybe something like PHP, with string llRegexSwap(string source, string expression) So that, say, llRegexSwap("foobarfoobar", "/bar//g"  ; would return foofoo? Hmm, I'll throw it into the feature pile.
|
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
03-30-2006 15:04
Since SL is writen in C++ maybe LSL should use PCRE lib for its RegEx (of course if Mono is used then .Net's RegEx can be used); and not try and emulate the format of PHP.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|
|
Darkside Eldrich
Registered User
Join date: 10 Feb 2006
Posts: 200
|
03-31-2006 10:15
From: Strife Onizuka Since SL is writen in C++ maybe LSL should use PCRE lib for its RegEx (of course if Mono is used then .Net's RegEx can be used); and not try and emulate the format of PHP. Or you could do it the easy way. If you're lazy.  But yeah, however they do it, I wants it. Although I've found that llParseList2String makes a great string tokenizer, it still leaves lots to be desired (like decent efficiency)
|