9

我只想在操作中间提示用户输入一行文本。效果应该是这样的:

> north

The robot steps in front of you as you approach the gate.
"PAASSWAAAAWRD!!" it bellows.

Enter the password: _

此时游戏应该暂停,让玩家尝试猜测密码。例如,假设我猜“fribble”,这不是密码:

Enter the password: fribble

"WRONG PASSWAAARD!" roars the robot. "CHECK CAPS LAAAWWWWK!"

>

我想要的行为类似于if the player consents,但我想要整行输入,而不仅仅是是或否。

4

3 回答 3

13

Inform 没有提供简单的方法来做到这一点,尽管您可以通过下降到 Inform 6 来访问键盘原语。

但是可以达到预期的效果:

The Loading Zone is a room. "Concrete with yellow stripes. The Hold is north."
The robot is an animal in the Loading Zone. "However, a robot the size of an Arcturan megaladon guards the way."

North of the Loading Zone is the Hold.

Instead of going north from the Loading Zone:
    say "The robot steps in front of you as you approach the gate. 'PAASSWAAAAWRD!!' it bellows.";
    now the command prompt is "Enter password: ".

After reading a command when the command prompt is "Enter password: ":
    if the player's command matches "xyzzy":
        say "The robot folds itself up into a cube to let you pass.";
        move the player to the Hold;
    otherwise:
        say "'WRONG PASSWAAARD!' roars the robot. 'CHECK CAPS LAAAWWWWK!'";
    now the command prompt is ">";
    reject the player's command.

我认为这种事情被认为是糟糕的游戏玩法:它迫使玩家猜测,这会损害玩家控制和选择的错觉。更传统的方法是要求玩家说出密码:

The Loading Zone is a room. "Concrete with yellow stripes. The Hold is north."
The robot is an animal in the Loading Zone. The robot is either awake or asleep. The robot is awake. "[if awake]However, a robot the size of an Arcturan megaladon guards the way.[otherwise]A cube of metal the size of an Arctural megaladon snores loudly.[end if]".
North of the Loading Zone is the Hold.

Instead of going north from the Loading Zone when the robot is awake:
    say "The robot steps in front of you as you approach the gate. 'PAASSWAAAAWRD!!' it bellows."

Instead of answering the robot that some text:
    if the topic understood matches "xyzzy":
        say "The robot folds itself up into a cube to let you pass.";
        now the robot is asleep;
    otherwise:
        say "'WRONG PASSWAAARD!' roars the robot. 'CHECK CAPS LAAAWWWWK!'"

命令说 xyzzy回答 xyzzy机器人,xyzzy说 xyzzy 对机器人都可以工作。

于 2012-11-08T13:48:35.653 回答
5

Michael Callaghan的扩展问题将对此有所帮助。请注意,您可能无法可靠地测试输入大小写敏感。

于 2013-10-07T10:44:32.203 回答
0

像这样下降到 I6 在 Inform 7.9.3 中有效。这可能是个坏主意。

Section 1 - Line input

Include (- Global user_input = 100; -) after "Parser.i6t".

The user input is a snippet that varies. The user input variable translates into I6 as "user_input".

To get a line of input: (-
    KeyboardPrimitive(buffer, parse);
    user_input = 100 + WordCount();
-).

然后,您可以使用短语“get a line of input”来读取一行,短语“the user's input”给出他们输入的行。(片段是一种文本。)

示例如下所示:

Section 2 - Example

The Loading Zone is a room. "Concrete with yellow stripes. The Hold is north."

The robot is an animal in the Loading Zone. "However, a robot the size of an Arcturan megaladon guards the way."

North of the Loading Zone is the Hold.

Instead of going north from the Loading Zone:
    say "The robot steps in front of you as you approach the gate. 'PAASSWAAAAWRD!!' it bellows.[paragraph break]";
    say "Enter password: ";
    get a line of input;
    if the user input matches "xyzzy":
        say "The robot folds itself up into a cube to let you pass.";
        move the player to the Hold;
    otherwise:
        say "'WRONG PASSWAAARD!' roars the robot. 'CHECK CAPS LAAAWWWWK!'".

Test me with "n / password / n / xyzzy".
于 2020-03-06T23:00:44.367 回答