dee*_*ee1 9 creation object inform7
非常新的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.
Run Code Online (Sandbox Code Playgroud)
"在休息室里制作苏打水(称为流行音乐)." 显然不是一个有效的命令,但我希望它能传达我想做的事情.我不知道如何在运行时实例化对象.这可以合理地完成吗?任何帮助,将不胜感激.我知道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".
Run Code Online (Sandbox Code Playgroud)
(制作机器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.
>
Run Code Online (Sandbox Code Playgroud)
我写了一个扩展来做这种事情:http://inform7.com/extensions/Jesse%20McGrew/Dynamic%20Objects/index.html
要使用它,您必须创建一个原型对象(例如,"原始的苏打水"),然后使用该表达式a new object cloned from the original soda pop来实例化新对象.这比创建大型静态对象池更节省内存,但它不适用于Z机器(仅限Glulx),并且如果您的对象很复杂,则会有一些注意事项.
另外,要认真考虑是否真的需要动态对象创建.如果你只是想出一个明智的理由拒绝这个动作,对于玩家来说可能会更容易,更容易混淆,比如"当你甚至没有完成你买的最后一瓶苏打水时,你不能让自己花钱." 周围有几千个汽水罐可能会让游戏变慢而不会增加太多的好处.
| 归档时间: |
|
| 查看次数: |
1139 次 |
| 最近记录: |