Inform 不能很好地处理动态对象,但它们通常不是最好的方法。第10.3 节。手册中的Dispensers and Supplies of Small Objects可能会有所帮助。
我认为最好的模型是物理模型:在机器中制造有限的罐头供应。例如:
Breakroom is a room. "A run of the mill breakroom."
A soda pop is a kind of thing. The description is "A refreshing soda pop."
The soda machine is in the breakroom. It is fixed in place and transparent.
The description is "Just an average soda machine, with a large dispense
button."
There are three soda pops in the soda machine.
The dispense button is a part of the soda machine.
Instead of pushing the dispense button:
if a soda pop (called the can) is in the soda machine:
move the can to the breakroom;
say "A soda can dispenses.";
otherwise:
say "The machine is empty, so nothing happens.".
Test me with "look / x machine / push button / look / push button /
push button / push button / look".
(制造机器opaque
而不是transparent
你喜欢的!)。在上面,我还调整了汽水的描述——如果你只是说"Blah"
而不是The description is "Blah"
在对象定义之后,你设置初始描述(作为房间描述的一部分打印)而不是“检查”描述,我认为这不是你想要的——我已经把按钮变成了机器的“一部分”,而不是一个单独的对象。
结果:
Welcome
An Interactive Fiction
Release 1 / Serial number 110324 / Inform 7 build 6G60 (I6/v6.32 lib 6/12N) SD
Breakroom
A run of the mill breakroom.
You can see a soda machine (in which are three soda pops) here.
>test me
(Testing.)
>[1] look
Breakroom
A run of the mill breakroom.
You can see a soda machine (in which are three soda pops) here.
>[2] x machine
Just an average soda machine, with a large dispense button.
In the soda machine are three soda pops.
>[3] push button
A soda can dispenses.
>[4] look
Breakroom
A run of the mill breakroom.
You can see a soda pop and a soda machine (in which are two soda pops) here.
>[5] push button
A soda can dispenses.
>[6] push button
A soda can dispenses.
>[7] push button
The machine is empty, so nothing happens.
>[8] look
Breakroom
A run of the mill breakroom.
You can see three soda pops and a soda machine (empty) here.
>