1

I'm trying to make a game in Inform 7 and have encountered a major problem, the answer to which apparently can't be found with a google search.

I'm using an 'if' argument to change certain situations based on what room the player is in. Instead of seeing what I have written as an 'if' argument, it has assumed 'If the player' to be an entity of itself.

This is the error message:

You wrote 'If the player is in Reception' , but also 'If the player is in the Corner Table' : that seems to be saying that the same object (If the player) must be in two different places (Reception and Corner Table). This looks like a contradiction.

This is my code in both places:

If the player is in the Corner Table;
    Understand the command "leave" or "exit" as something new.
    Understand "leave" or "exit" as northwest.

If the player is in Reception;
    Understand "key" as the Janitor's Key.

So, uh... can anybody help me?

4

1 回答 1

1

您发布的代码有几个问题:

  • 你不能有一个 if 短语脱离上下文。您必须为何时考虑 if 短语编写规则。
  • 相反,您不能在上下文中使用理解短语。更具体地说,if ...: understand "..." as ...是不可能的。理解短语必须始终是独立的。
  • if 短语应该以冒号结尾,而不是分号。
  • “西北”本身并不是一个动作;“向西北走”是。

你显然想要这个:

Instead of exiting when the location is the Corner Table:
    try going northwest.

这会将退出动作(包括命令“离开”和“退出”)重定向到该特定房间中的西北方向动作。

对于第二个 if 短语,首先如果您有一个名为“看门人的钥匙”的对象,游戏已经将“钥匙”理解为指的是该对象,除非您专门将该对象设为private-named。其次,为什么游戏只能在一个位置识别“钥匙”?内置的作用域已经确保你不能引用与玩家不在同一个房间的东西。

因此,如果该对象是私有命名的,并且只有在一个位置应该这样引用密钥是有原因的,那么代码是:

Understand "key" as the Janitor's Key when the location is the Reception.

但是,如前所述,这在非常特定的情况下是必要的,并且很可能最好让标准库处理它并完全忽略它。

于 2013-12-06T12:49:55.153 回答