2015-11-03 81 views
2

我有以下代码..印刷客房描述“去后”规则通知7

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! 

回答

2

发生这种情况,因为 “后,” 之前 “报告” 规则运行规则,而且房间介绍按报告规则打印。所以你有几个选项来解决它:

  • 打印您的规则后的房间描述。正如您所注意到,“尝试寻找”打破了短暂的模式,因为它总是作出响应,如果玩家输入的外观,但还有另外一个词组,你可以改用(它提到标准规则节上寻找):

    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!"
  • 从打印室的描述后运行的“报告会”的规则打印您的留言:

    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!"
0

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

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

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

+0

打印出“您听到远处有巨大的噪音了” - 在新的房间描述之前,对吗?问题是关于如何打印之后。 –

+0

啊,你说得对。那么这个答案是无用的。我可能会删除它,如果我想到其他解决方案,可能会创建一个新的。 – celticminstrel