[i7][solved] Countable objects: how to remove quantities

I am just experimenting with larger quantities of objects. However, I have trouble taking a specific amount of countable objects out of the game:

[code]A coin is a kind of thing.
The Cellar is a room.
There are 5 coins in the cellar.
The player is in the cellar.
The coin-eater is in the cellar.

The coin-eater is an animal with printed name “coin eater”.
Understand “coin eater” as coin-eater.
The description of coin-eater is “The coin eater is a dangerous creature that will eat a coin if poked.”

Understand “poke [something]” as poking.
Poking is an action applying to one thing.

Carry out poking:
say “You poke [the noun].”.

instead of taking a coin:
say “The coin eater appears to have a keen eye on them - you’d rather not take one.”.

instead of poking the coin-eater:
say “The coin eater barks and grabs a coin, just to swallow it immediately.”;
remove one coin from play.[/code]
This results in the error:

Sadly I can’t find a remove example in the manual which targets countable things. How is it done?

Also, since many instances of those objects might be around, how can I prefer specific instances for deletion like preferrably deleting ones which the player is carrying?

Try: remove a random coin from play (You need to phrase it thus, even if there is just one object of the coin kind in play.)

Thanks :slight_smile: how can I destroy one that is specifically carried by a character, e.g. the player? Or one in a specific room that is not the current location (even if there might be coins at the current location aswell)?

“remove a random coin carried by the player from play”
“remove a random coin in the Kitchen from play”

Of course you’d want to check that there is such an item, or you’ll get a run-time error. You might do this:

	if the player carries a coin (called C):
		remove C from play.

Thanks again!

I have one remaining question:

I want to destroy a certain kind of object and replace it with another. So there is really no point pre-creating the resulting “other” in some hidden room, way too much hassle (I want to possibly make this happen everytime the player brings a new old kind of object, then destroy it and give him a new kind of object - a converter basically). I really want to create the new one at runtime somehow. So how do I do that? Destroy one object, then spawn another kind of object without having it off stage somewhere, just out of nothing? (and do something with it, e.g. moving it into the player inventory)

(both objects are countable unspecific quantity-type objects like coins, but not of the same kind)

The easiest plan is to pre-create a bunch of “other” items in a hidden room somewhere.

Well this converter device will get used a lot in the game. I don’t want it to randomly stop working for some reason because those items run out. Is there no way to create objects on the fly?

There is a Dynamic Objects Extension. It’s the less-easy plan.

The way you describe it, it sounds like there are a limited number of precursor objects, so there would be known maximum number of result objects.

Yea, the resulting number of objects will have a practical limitation because the “input” objects aren’t infinite, but I just don’t want to hardcode it. So if there was a way to avoid that, I’d prefer that. I’ll take a look at the dynamic object extension!

It sounds like, if you’re turning say coins into pigeons, you could create a bunch of coin objects and give them a property (like “converted” or something) such that a converted coin behaved like a pigeon – its printed name is “pigeon,” you can understand “pigeon” as a converted coin, etc. (You might want to make them privately-named and add a line about understanding “coin” as an unconverted coin in order to make sure that “coin” couldn’t be used to refer to a pigeon.) The details might be complicated though.

Actually, if I were worried about having to hardcode the number of result objects because I didn’t want to have to change the hardcoding every time I added a new “input” object to my code, this is what I’d do:

Code in a number of result objects that is greater than what I need.
Write some not-for-release code that checks the number of possible input objects when play begins,
compares it to the number of result objects,
and stops play immediately if there aren’t enough result objects. (Or just prints a big flashing warning so you can keep testing but you know you have to increase the number of result objects.)

This seems to me like it’d be less hassle than using Dynamic Objects to create the result items at runtime, but YMMV, I guess.

http://inform7.com/extensions/Jesse%20McGrew/Dynamic%20Objects/doc_5.html sounds exactly like what I want.

Due to the amount of converters I want which would require a lot of hacks otherwise, and my general desire for dynamic things, I think dynamic objects really are the thing I should go for. Thanks for the hints!

Sadly, I’m stuck right at the start :frowning: can’t get it to work:

The extension is advertised as “Dynamic Objects” and the docs example suggests Include Dynamic Objects by Jesse McGrew. to use it.

However, the extension installs with the menu entry “Dynamic Objects (for Glulx only)” and opening the extension file through the open extension menu yields a first line that says


So I tried this first:

Include Dynamic Objects by Jesse McGrew.
[/code]and then this:[code]
Include Dynamic Objects (for Glulx only) by Jesse McGrew.

… and nothing of that works :question:

The errors I get:

All other extensions I ever added work fine. So I have no idea what to do to make this one work :neutral_face: any hints appreciated!

Dynamic Objects in turn includes another extension, Dynamic Tables, by the same author. Maybe you don’t have the latter installed? The error message would be misleading, but it’s worth checking that.

I do have it installed, and including that one works just fine with Include Dynamic Tables by Jesse McGrew.

Also, the dynamic objects package as I downloaded it was named “Dynamic Objects.i7x”, but the folder with the installed extensions now contains it named as “Dynamic Objects (for Glulx only).i7x”.

Ok, now I just went ahead and renamed the file in the installed extensions folder of Inform to “Dynamic Objects.i7x” (previously “Dynamic Objects (for Glulx only).i7x”), then simply edited the file with a text editor and altered the first line in the file so it now reads: “Version 7/130712 of Dynamic Objects by Jesse McGrew begins here.” (previously it was: “Version 7/130712 of Dynamic Objects (for Glulx only) by Jesse McGrew begins here.”)

Now the include works, even both ways of including it with the glulx stuff appended and not appended:

Include Dynamic Objects (for Glulx only) by Jesse McGrew.
[/code] or [code]
Include Dynamic Objects by Jesse McGrew.

I don’t know if this is an Inform bug for not handling the name with brackets correctly or an extension bug for doing that in the first place, but now I can start coding dynamic things! yay :slight_smile: