ID:273973
Oct 17 2011, 9:17 pm
|
|
How would it be possible to have findtext locate "Hi" in "hi my name is bob." and send a command thats related to it, but at the same time not send the command when "thing" is said. Seeing as "thing" also has "hi" in it as well. Id also like to refrain from using FindTextEx seeing as not everyone uses correct spelling or cap. online. Thanks for any help you guys can provide.
|
Oct 17 2011, 11:54 pm
|
|
You can use <code>lowertext()</code> included with <code>findtext()</code> to compare text strings.
|
In response to Neimo
|
|
Neimo wrote:
You can use <code>lowertext()</code> included with <code>findtext()</code> to compare text strings. Example? |
In response to D-Cire
|
|
There are examples in the reference.
|
You could try using findtext to find the spaces, or certain key characters around the string you want, or even using a command word such as 'SYSHELP:'
mob/verb/Say1(var/T as text) |
In response to El Wookie
|
|
El Wookie wrote:
You could try using findtext to find the spaces, or certain key characters around the string you want, or even using a command word such as 'SYSHELP:' > mob/verb/Say1(var/T as text) I was more looking for the first thing you stated wookie, thanks! Im trying to make a sort of "Reply Bot" may you call it? Not really for a game or anything just as something i want to do, and this was confusing me :P |
In response to El Wookie
|
|
If I remember how findtext() works, your Say1 has an error in it, because it will respond to things such as "I like the letter phi a lot" and not to strings such as "hi". This might work better:
<code>if (findtext (" [T] ", " hi ")||findtext (" [T] "," hi. "||findtext(" [T] "," hi, "), ...)</code> (fill in the remaining punctuation marks) Edit: I guess it's cleaner if you just have a proc that strips punctuation marks altogether var/list/punct = list(...) // all punctuation marks (Haven't tested) So then the only conditional you need is: <code>if (findtext (" [stripPnctMarks(T)] ", " hi ")</code> |
In response to Toadfish
|
|
Wouldn't that require a space before the word itself to trigger?
|
In response to Lugia319
|
|
No, because we're parsing " [text] " and not "[text]".
|
In response to Toadfish
|
|
Toadfish wrote:
No, because we're parsing " [text] " and not "[text]". I basically just made it check for "Hi.", "Hi!", "Hi?" or " Hi " And mad an add punctuation point proc to add a period if they just typed "Hi". Anything else will just end up in a random response. Not the best way, but better than i originally had planed. |
In response to D-Cire
|
|
Another way you could do it, a far more accurate one, would be to split up the text string into a list via spaces, so for example:
'Hi there you! This is cool!' Would become a list as such list("Hi","there","you!","This","is","cool!") Obviously you'd need a few check for punctuation and what not, but as far as I can see this would be the best solution to your problem. (Now that I fully understand it =P) |
In response to El Wookie
|
|
El Wookie wrote:
Another way you could do it, a far more accurate one, would be to split up the text string into a list via spaces, so for example: Lol, i see. Well i dont really know how that would be done. Ive stated before im a fast learner, but im still pretty new to the DM Language. |
In response to D-Cire
|
|
proc Using a proc from a library by Forum_Account to easily split the text string into a list of words. |
In response to El Wookie
|
|
You're welcome =)
|
In response to Forum_account
|
|
Forum_account wrote:
You're welcome =)Thank you both! =3 |
In response to Toadfish
|
|
I tried hard to think of any words which ended in 'hi', and when I couldn't think of any I added the second option to include the space at the end.
Sorry for being less smarterer than you D: |