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?

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.

This site is now closed.
As of 1st November 2015, this site is a read-only archive. For more information see the intfiction forum post

Welcome to IF Answers, a site for questions and answers about Interactive Fiction.

Technical questions about interactive fiction development tools such as Inform, Twine, Quest, QuestKit, Squiffy, Adrift, TADS etc. are all on-topic here.

Non-technical questions about interactive fiction are also on-topic. These questions could be about general IF design, specific games, entering the IF Comp etc.
...