为了使当前包含特殊门的 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 都没有看到这个东西,我也不能在代码的其他地方使用它。我仅从仅在函数中作为参数知道的参数中知道这种行为。所以这让我更加困惑......