Login
Remember
IF Answers
Ask a Question

# How do I move an item I have more of in the world (since it's a kind of thing)?

0 votes
73 views
asked Jul 8 in Authoring by Ultrawup
edited Jul 8

I want to create something like this:

An apple is a kind of thing.
The Orchard is a room. In the Orchard is a tree. In the Orchard is a basket.
The basket is a container. In the basket are three apples.
instead of attacking the tree:
now an apple is in the Orchard;
say "You violently shake the tree, and apple falls down!"

But this results in an error, because "now an apple is in the Orchard" is not specific enough. However, I haven't been able to find a way for the game to just put a new apple in the room.
The compiler error can be circumvented by saying "now a random apple is in the Orchard", but that will take one of the apples from the basket.

How can I get Inform to spawn a new apple into the orchard every time the player attacks the tree?

- inform7
- programming
- kinds
- objects

## 1 Answer

0 votes
answered Jul 8 by HerrRau (26 points)

In Inform 7, you cannot dynamically (during play) create objects. All objects must be created beforehand (which makes it easier to alculate how much memory the game will require, which used to be very important). So you might create a number of apples and keep them offstage, and place them in the Orchard one by one. But again, this gives you only a finite number of objects, and you must decide on an upper limit beforehand.

Havind said that, there is an extension, "Dynamic Objects" by Jesse McGrew (http://inform7.com/extensions/Jesse%20McGrew/Dynamic%20Objects/index.html), which allows you to do just that, i.e. create objects during play.

## Related questions

- Copying the location of a thing to a variable when it's in something other than a room.
- How can I prevent appending (open), (closed) etc. to an object in Inform 7?
- How do I force Inform's listing to separate out identical items?
- How to make the player specify which thing of a kind they mean? (Inform 7)
- How do I find the default parser verbs in Inform?

...