如何读取Inform 7中的输入行?

Jas*_*rff 9 inform7

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

> north

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

Enter the password: _
Run Code Online (Sandbox Code Playgroud)

此时游戏应暂停并让玩家尝试猜测密码.例如,假设我猜"fribble",这不是密码:

Enter the password: fribble

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

>
Run Code Online (Sandbox Code Playgroud)

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

Jas*_*rff 12

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.
Run Code Online (Sandbox Code Playgroud)

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

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!'"
Run Code Online (Sandbox Code Playgroud)

命令说xyzzy回答xyzzy机器人,xyzzy说xyzzy到机器人都将工作.


cur*_*nii 5

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