5

我有以下代码:

After going to room1:
    if button1 is switched on:
        say "You hear a loud noise in the distance!";

不幸的是,这会阻止打印房间描述。如果我添加“继续操作;” 最后,输出是“你听到远处有很大的噪音!” 在房间描述之前。我真的想要房间描述第一。如果我添加“尝试寻找;” 作为第一行,它打破了简要/详细模型。如何编码以获得以下输出?

(详细)

>e
Room1
This is a small room.
There is a letter here.
You hear a loud noise in the distance!

(简短,第二次入住时)

>e
Room1
There is a letter here.
You hear a loud noise in the distance!
4

2 回答 2

5

发生这种情况是因为“之后”规则在“报告”规则之前运行,并且房间描述由报告规则打印。所以你有几个选项来修复它:

  • 在您的规则中打印房间描述。正如您所注意到的,“尝试查找”会中断简短模式,因为它总是会像玩家键入 LOOK 一样做出响应,但是您可以使用另一个短语来代替(在关于查找的标准规则部分中提到过):

    After going to room1:
        produce a room description with going spacing conventions;
        if button1 is switched on:
            say "You hear a loud noise in the distance!"
  • 从打印房间描述后运行的“report going”规则打印您的消息:

    Last report going rule (this is the report loud noise in the distance rule):
        if the room gone to is room1 and button1 is switched on:
            say "You hear a loud noise in the distance!"
  • 从“每轮”规则打印您的消息,该规则在所有操作规则手册之后运行:

    Every turn when the player is in room1 and the player was not in room1:
        if button1 is switched on:
            say "You hear a loud noise in the distance!"
于 2015-11-24T21:51:23.787 回答
0

发生这种情况是因为“之后”规则默认为“成功”,这意味着稍后将发生的任何事情(包括报告规则和房间描述)都将被取消。解决方案是简单地添加continue the action您的规则:

After going to room1:
    if button1 is switched on:
        say "You hear a loud noise in the distance!";
    continue the action;

这有点类似于“替代”规则的工作方式——默认情况下,规则终止进一步的处理(但替代规则默认为失败而不是成功)。

于 2016-02-12T23:45:31.973 回答