Login
Remember
IF Answers
Ask a Question

# How can I check the user's command?

+1 vote
83 views
asked Apr 23 in Authoring by Sciver (23 points)

I have a turn script that I need to be conditional depending on what the user's command entry is.
I still want to parse the command, but I want additional code to run depending on what the user just did...

As an arbitrary example, print a message admonishing the player for looking around idly when their life is in mortal danger this very moment.

Or actually in the specific case, not counting Look At [enemy] as a full turn, but counting any kid of physical action as a turn. Since looking at something doesn't necessarily take a long time, I don't want to end a player's combat turn when using Look At once. (repeated stares of course I'll punish later once I know how to differentiate)

I'd like to avoid passing everything through Get Input, as I've found it doesn't always work correctly. (Sometimes the text entered doesn't get processed and needs to be entered a second time. I experienced this frequently with the Character Naming script I made)

so can anyone help?

- quest
- programming
- turn-script

## 1 Answer

+1 vote
answered Apr 23 by Sciver (23 points)

Ok, so, after some testing, it looks like you can get this information by looking at this variable:

    game.pov.currentcommandpattern.name

which is the name of the last valid command OR verb used. To compare a command, that command must have a name attribute. (all the default game commands and verbs do, but custom ones need to be assigned a name upon creation.)

When used in a turn script at the start of the game, it will not exist. Turn scripts appear to execute BEFORE the player finishes their turn, that is, at the beginning of a turn, not the end. Something I'll have to keep in mind.

## Related questions

- How do I use the create exit command properly in Quest
- How can I make use of the health variable in Quest through the editor
- How do I find the default parser verbs in Quest?
- How can I run a command via script? [Quest]
- How can I set the player smell in Inform 6?

...