0

为了使当前包含特殊门的 Inform7 项目中的代码更具可读性,我决定创建各种门和作为门的一部分的东西,以回溯要打开和关闭的门。
背景:一扇门只有在之前被一个叫做 Mobitab 的东西操纵然后被安全通行证解锁的情况下才能打开。所以我创建了一种叫做 DoorpanelSM 的东西,它有一个属性被操纵(通常为 0)和一个属性被激活(通常为 0)。我的门操作和解锁代码如下所示:

注意:问题进一步缩小。编辑一直到底部!

TürpanelSM is a kind of a thing. Sicherheitsausweis can be used with TürpanelSM. TürpanelSM has a number called activated. Activated of TürpanelSM is usually 0. TürpanelSM has a number called manipulated. Manipulated of TürpanelSM is usually 0.

Unlocking a TürpanelSM with Sicherheitsausweis is an action applying to two things.
Understand "use [Sicherheitsausweis] with [a TürpanelSM]" as unlocking a TürpanelSM with Sicherheitsausweis.

Manipulating a TürpanelSM with Mobitab is an action applying to two things.
Understand "manipulate [a TürpanelSM]" as manipulating a TürpanelSM with Mobitab.
Understand "use [Mobitab] with [a TürpanelSM]" as manipulating a TürpanelSM with Mobitab.

Instead of unlocking a TürpanelSM with Sicherheitsausweis:
    if TürpanelSM (called currentPanel) is part of a door and manipulated of the currentPanel is 0:
        say "Securitypass not accepted. You could try to manipulate the panel...";
    otherwise if TürpanelSM (called currentPanel) is a part of a door (called the parent) and activated of the currentPanel is 0:
        now the parent is unlocked;
        now the parent is open;
        now activated of the currentPanel is 1;
    otherwise if TürpanelSM (called currentPanel) is a part of a door (called the parent) and activated of the currentPanel is 1:
        now the parent is closed;
        now the parent is locked;
        now activated of the currentPanel is 0;
otherwise if TürpanelSM (called currentPanel) is a part of a door:
Instead of manipulating a TürpanelSM with Mobitab:
    if TürpanelSM (called currentPanel) is a part of a door and manipulated of the currentPanel is 0:
        now manipulated of the currentPanel is 1;
        say "Panel got manipulated";
    otherwise if TürpanelSM (called currentPanel) is a part of a door and manipulated of the currentPanel is 1:
        say "Panel was manipulated already.";

只有一扇门才能发挥作用。但是,如果我使用两个或更多门,则定义的门板的属性似乎是全局的。我确信这now activated of the currentPanel is 0;不会改变 currentPanel 的属性,而是声明了一个全局变量,该变量在以下每个条件下都被要求。我完全无法找到正确设置和获取我要求的面板值的方法。

显示问题的小测试程序(包括上述):

"TestsForSO" by geisterfurz007

Locker is a container.
Mobitab is in Locker.
Securitypass is in Locker.
Locker is in Hangar.

DoorpanelSM is a kind of a thing. Securitypass can be used with DoorpanelSM. DoorpanelSM has a number called activated. Activated of DoorpanelSM is usually 0. DoorpanelSM has a number called manipulated. Manipulated of DoorpanelSM is usually 0.

Unlocking a DoorpanelSM with Securitypass is an action applying to two things.
Understand "use [Securitypass] with [a DoorpanelSM]" as unlocking a DoorpanelSM with Securitypass.

Manipulating a DoorpanelSM with Mobitab is an action applying to two things.
Understand "manipulate [a DoorpanelSM]" as manipulating a DoorpanelSM with Mobitab.
Understand "use [Mobitab] with [a DoorpanelSM]" as manipulating a DoorpanelSM with Mobitab.

Instead of unlocking a DoorpanelSM with Securitypass:
    if DoorpanelSM (called currentPanel) is part of a door and manipulated of the currentPanel is 0:
        say "Securitypass not accepted. You could try to manipulate the panel...";
    otherwise if DoorpanelSM (called currentPanel) is a part of a door (called the parent) and activated of the currentPanel is 0:
        now the parent is unlocked;
        now the parent is open;
        now activated of the currentPanel is 1;
    otherwise if DoorpanelSM (called currentPanel) is a part of a door (called the parent) and activated of the currentPanel is 1:
        now the parent is closed;
        now the parent is locked;
        now activated of the currentPanel is 0.

Instead of manipulating a DoorpanelSM with Mobitab:
    if DoorpanelSM (called currentPanel) is a part of a door and manipulated of the currentPanel is 0:
        now manipulated of the currentPanel is 1;
        say "Panel got manipulated";
    otherwise if DoorpanelSM (called currentPanel) is a part of a door and manipulated of the currentPanel is 1:
        say "Panel was manipulated already.";

想法是执行以下操作:

使用 Securitypass
使用 Mobitab
使用 Mobitab 和 TPTSM1 //这是第一个门板;操作门
使用带有 TPTSM1 的 Securitypass //打开门
向西
使用带有 TPTSM2 的 Mobitab //这将是第二个门板(向西北);表示面板已经被操纵。

而且我不知道为什么......任何帮助都非常感谢!

编辑:进一步调查,我使用了该showme命令,发现变量在第一扇门上已正确更改,并且它们都正确为 0。但是据说尽管操纵值是 0,但面板已经被操纵。也许是问题是连接到currentPanel 的东西吗?
更多编辑:实际上它看起来就像那样...... currentPanel 似乎总是 TPTSM1。我的理解是,每次对任何门板执行规则时,它都会相应地改变。我将如何更改代码来实现这一点?
更多编辑:如上所述(看起来)currentPanel操作/解锁后似乎已修复。然而,showme 都没有看到这个东西,我也不能在代码的其他地方使用它。我仅从仅在函数中作为参数知道的参数中知道这种行为。所以这让我更加困惑......

4

1 回答 1

1

您定义“currentPanel”为时已晚。例如,这里没有指向玩家当前正在操作的门板的链接:

if DoorpanelSM (called currentPanel) is part of a door ...

它只选择游戏中存在的一些面板,恰好总是 TPTSM1。

如果您之前定义它,请在此处:

Instead of unlocking a DoorpanelSM (called currentPanel) with Securitypass:

然后它选择当前正在解锁的面板。或者,您可以使用“名词”,它自动成为当前操作的目标。


不相关的旁注:

Sicherheitsausweis can be used with TürpanelSM不太可能按照您的意思去做:它创建了一个名为“与 TürpanelSM 一起使用”的形容词,而没有做其他任何事情。

相反,使用数字属性来跟踪对象状态有些笨拙,通常使用形容词来代替。因此,您将使用 and 定义、DoorpanelSM can be activated测试if currentPanel is activated和设置它。now currentPanel is activatednow currentPanel is not activated

于 2017-05-12T08:00:27.447 回答