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.
>