需要帮助在notify7中创建新对象

|| Inform7及其样式非常新。我已经查看了提供的文档,并且某些互联网浏览对我没有任何帮助……这是我正在寻找的简化版本。我想写这样的东西:
breakroom is a room. \"A run of the mill breakroom.\"

soda pop is a kind of thing. \"A refreshing soda pop.\"

soda machine is in the breakroom.  dispense button is on the soda machine.

instead of pushing dispense button:
    say \"A soda can dispenses\".
    create a soda pop (called pop) in the breakroom.
“在休息室创建一个苏打汽水(称为汽水)。”显然不是有效的命令,但我希望它传达了我想要做的事情。我不知道如何在运行时实例化对象。可以合理地做到这一点吗?任何帮助,将不胜感激。我知道Inform的追随者并不多,但我想我会试一试。     
已邀请:
Inform不能很好地处理动态对象,但是无论如何它们通常都不是最佳方法。 10.3节手册中的小物体分配器和补给可能会有所帮助。 我认为最好的模型是物理模型:在机器中创建有限的罐头供应。例如:
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.

>
    
我写了一个扩展程序来做这种事情:http://inform7.com/extensions/Jesse%20McGrew/Dynamic%20Objects/index.html 要使用它,您必须创建一个原型对象(例如,“原始苏打汽水”),然后使用表达式
a new object cloned from the original soda pop
实例化新对象。与创建大型静态对象池相比,此方法更节省内存,但是它不适用于Z机(仅适用于Glulx),并且如果您的对象很复杂,则有一些警告。 另外,请认真考虑是否真的需要创建动态对象。如果您只是想出一个合理的理由来拒绝该动作,这对于玩家来说可能会更容易且不会引起混淆,例如“ \“您甚至还没吃完最后买的苏打水,就无法带自己去花钱。 。\“周围有成千上万的汽水罐可能会使游戏变慢,而不会增加太多好处。     

要回复问题请先登录注册