How to check if player supplied optional [text] or didn't

Understand "think", "think [text]" as newthinking.

If I make a command like this that can take text, but doesn’t have to, how can I check if the player supplied no topic? I don’t want to use the ‘mistake’ mechanism or make a second action here.

-Wade

Weirdly enough, I can’t find a pure-I7 way to do this. But it’s an oversight that’s easy enough to remedy with a tiny bit of I6.

Definition: a snippet is empty if I6 routine "SnippetEmpty" says so (it contains no words).
Include (-
[ SnippetEmpty s ;
	return (s == 0);
];
-).

Now you can just check “if the topic understood is empty”.

(Well, you can do it with pure I7, by checking “if the number understood is 0”, since an empty snippet corresponds to the number 0. But breaking type-safety by looking at the wrong “the ___ understood” is a great way to make your code opaque and unreadable.)

Here’s a pure I7 option (that would rapidly become less attractive if the command verb had multiple synonyms): if the player's command exactly matches the text "think".

And I think this would work as a function-less I6 inclusion alternative:

To decide if no topic was specified: (- (num_words == 1) -).
1 Like

If you’re dipping down to I6, I would rather check consult_words or parsed_number (i.e. the topic understood); this won’t work for an Understand line like “think about [text]”.

Easiest solution is to make a second action.

See, this is why answering questions is hard.

3 Likes