Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

If() help

Parsalin Gullwing
The big PG
Join date: 16 Aug 2004
Posts: 32
01-16-2005 23:05
Hey im trying to make an event that will trigger when it hears a specific word said by its owner

i have

if(m=="lol";)
{
updateparticles;
}

and this works if i say "lol" and nothing else around it

i need it to trigger the event weather i say just "lol" or "omg lol how funny" or "wow lol thats neat"

or any sentance that has lol in it at some place

i thought maybe listing out m but i cant find or it isnt plain to see in wiki an even that will notice one word out of a list also i think this way wouldnt be proficient on resources.

if anyone can help me that would be great thanks
Moleculor Satyr
Fireflies!
Join date: 5 Jan 2004
Posts: 2,650
01-16-2005 23:17
Check out llGetSubString.

Sorry! The administrator has specified that users can only post one message every 30 seconds.
_____________________
</sarcasm>
Parsalin Gullwing
The big PG
Join date: 16 Aug 2004
Posts: 32
01-16-2005 23:22
From: Moleculor Satyr
Check out llGetSubString.

Sorry! The administrator has specified that users can only post one message every 30 seconds.


i saw that wiki seems to explain it in such a way that it will return a specific word in the string or the whole string or a part of the string so then if i set it to return the 3rd word and lol was the forth it wouldnt work

or am i reading this completely wrong
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
01-16-2005 23:40
Actually, llSubStringIndex may be of more use to you then llGetSubString.
It returns the index of the speficied string within another or -1 if the substring isnt found.
This way, you could do
CODE

if (llSubStringIndex(m, "lol") != -1) {
// Then "lol" is in the message.
}

==Chris
Jake Cellardoor
CHM builder
Join date: 27 Mar 2003
Posts: 528
01-16-2005 23:40
I think Moleculor mean llSubStringIndex, which searches for a specified substring and returns -1 if the substring is not found. So you could try something like this:
CODE

if ( llSubStringIndex( msg, "lol") != -1 )
{
// do whatever
}


Edit: Whoops, looks like Christopher beat me to it
Catherine Omega
Geometry Ninja
Join date: 10 Jan 2003
Posts: 2,053
01-16-2005 23:46
The best way to do it is to use llDumpList2String to convert the entire line of text to a list, then check whether or not "lol" exists somewhere in that list, by using llListFindList. Because llListFindList will return the first occurrence of "lol", or -1 if it's not found, you can then do 'if (position > -1)' to do the equivalent of an OR check, rather than looking for the position.

Edit: heh, beat to it. Also, I like lists, can you tell? :)
_____________________
Need scripting help? Visit the LSL Wiki!
Omega Point - Catherine Omega's Blog
Parsalin Gullwing
The big PG
Join date: 16 Aug 2004
Posts: 32
01-16-2005 23:58
From: Christopher Omega
Actually, llSubStringIndex may be of more use to you then llGetSubString.
It returns the index of the speficied string within another or -1 if the substring isnt found.
This way, you could do
CODE

if (llSubStringIndex(m, "lol") != -1) {
// Then "lol" is in the message.
}

==Chris

thank you very much this is exactly what i was looking for

funny thing is i passed over the index one in wiki because it didnt seem to be what i was looking for but it worked so awesome thanks to everyone who helped too this is awesome i can move and now :D
Hank Ramos
Lifetime Scripter
Join date: 15 Nov 2003
Posts: 2,328
01-17-2005 05:57
You might want to try...

CODE

if (llSubStringIndex(m, " lol ") != -1)
{
}

so that it doesn't trigger on "lollypop" or other words with "lol" inside of it.