1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-05 16:44:21 +03:00
inform7/Documentation/Examples/Alpha.txt
2019-02-05 00:44:07 +00:00

21 lines
992 B
Plaintext

* Regular expression matching
(Testing command; Alpha)
Creating a beta-testing command that matches any line starting with punctuation.
Sometimes we want to let testers of a game insert their own comments during a transcript, without those comments wasting turns of the game or producing lengthy or inappropriate parser errors. Many testers have a habit of prefacing comments with a punctuation mark, so let's say that we'd like to catch any command that starts with any punctuation at all:
{*} "Alpha"
When play begins:
say "Hi, Larry! Thanks for testing my game!!"
Unimplemented Room is a room. "Room description goes here..."
The scary troll is a man in Unimplemented Room.
After reading a command (this is the ignore beta-comments rule):
if the player's command matches the regular expression "^\p":
say "(Noted.)";
reject the player's command.
Test me with "x me / x troll / !this game is a bit dull so far / kiss troll / ? does this troll do anything? / :yawn".