Reading Player's command abbreviated

Hi guys, how can i read the player’s command but only the 3 first letters?

Example:

say please

Please do not say please.

After reading a command: if the player's command includes "ple": say "Please do not say please."; reject the player's command.

The code doesn’t work.

Thanks,

Does it produce an error message or silently do the wrong thing?

Not error, just understand “please” but no “ple”…

Sorry, yes, silently only understand if I type “say ple”…

I’m not sure about the internals, but I think snippet-to-snippet comparisons as used in “if the player’s command includes…” work only on whole words. Try using a text comparison as in section 20.5:

if the player's command matches the text "ple":

(Note that for text comparisons “matches” means “has as a substring” and “exactly matches” means “is exactly the same as,” while for snippet comparisons “includes” means “has as a substring” and “matches” means “is exactly the same as.” This always confuses me.)

ETA: You might even want to get a bit fancy with regular expressions so as to guarantee that “ple” is the beginning of the word, so you don’t reject “x apple.” See section 20.6, though keep in mind the adage: “Some people, when confronted with a problem, think ‘I know, I’ll use regular expressions.’ Now they have two problems.”

Thank you Matt, it works! Another question, how can I achieve the same with the verb?

For example I have an action like “Understand “hel” as helping”, when the player types “help” or “help me”, I want to redirect the action to the hel action instead.

[code]if the player’s command matches the text “ple”:[code]

This will catch “PLEASE GO AWAY” but also “GET APPLE”.

Yeah, that’s what I meant about the regular expressions, but I was a bit too rushed to work out exactly which one you should use. I guess it’d be, hm:

if the player's command matches the regular expression "\bple"

(Since \b signifies a word boundary.)

Iam: Turning this into a verb match for ordinary processing seems like it’d be a big lift–the mechanism we’re talking about bypasses the parser completely, and there isn’t really a mechanism to say “Understand anything starting with ‘hel’ as asking for help.” The understanding mechanism works on whole words.

If you really really want to make sure that the parser only looks at the first three letters of every word you can do this:

Use DICT_WORD_SIZE of 3.

But you need to be sure that you don’t need “help” and “hello” because those both get cut off to “hel.”

Thank you, “Use…” is what I was looking for. However, for some reason is messing the code, I had some printed names and now the description say “two” for some reason:

You can see two  here.

I bet you’ve got two objects that can’t be distinguished any more, because their names are the same up to three letters.

(It’s a bug that the name gets dropped like that – the library wants to say “You can see two things here.” But you have to make the names distinguishable by the player anyhow.)