(WIP) Duplicatable objects extension

Soliciting feedback on this (work in progress) extension, allowing for an arbitrary number of copies of an object to be effectively used at once.

We’re sure someone’s done this before, but we can’t find it, and we wanna share our own attempt. Is there anything obvious we can improve here? Let us know what you think!

Multiplicity by Sunroses begins here.

Chapter 1 - Quantities

A thing has a number called quantity. The quantity of a thing is usually 1.

To discard (N - number) of (item - a thing):
	If the quantity of the item is greater than N:
		Decrease the quantity of the item by N;
		Now the item is nowhere.

Carry out eating:
	Discard 1 of the noun.
For printing the name of something (called item):
	If the quantity of item is 1:
		Continue the activity;
		Say "[quantity of item] [the printed name of item][s]";

Chapter 2 - Cloning and Prototyping

A clone is a kind of thing.
Copying relates various clones to one thing (called the prototype).

The verb to copy implies the copying relation.
The verb to prototype implies the reversed copying relation.

Definition: a thing is archetypal if it prototypes something.
CRITICAL NOTE: the whole point of this is that we can't create new objects, so...
A prototype should *only ever be* either in the player's inventory or "nowhere".
If you want an instance in the world, make a clone.
TODO: make it possible to have a clone appear and disappear from a given location instead of going "nowhere" permanently when taken?

To collect (N - a number) of (item - a thing):
	Let P be a thing;
	If item is a clone:
		now P is the prototype of item;
		now P is the item;
	if the player has P:
		Increase the quantity of P by N;
		Now the quantity of P is N;
		Now the player carries P;

Instead of taking a clone:
	let P be the prototype of the noun;
	let N be the quantity of the noun;
	collect N of P.
Before dropping a thing:
	If the noun is archetypal:
		Say "Can't drop that!" instead.

Before putting a thing on a supporter:
	If the noun is archetypal:
		Say "Can't place that!" instead.
Before inserting a thing into a container:
	If the noun is archetypal:
		Say "Can't put that there!" instead.

Multiplicity ends here.


Example: * Intro - A simple example
Here's a sample code where you get two sticks every time you enter a room.

	*: "Intro"
	Include Multiplicity by Sunroses.
	Stick is a thing.
	Sample stick is a clone. The prototype of the sample stick is the stick.
	Entryway is a room.
	North of the Entryway is the Free Sticks Zone.
	After going to Free Sticks Zone:
		Say "Free sticks!";
		Collect 2 of Stick.

	Test me with "go north / go south / go north / go south / go north / go south / go north / go south / go north / go south / go north / go south / go north / inv"

also we know this line isn’t quite right, but we don’t know how to activate the plural name printer from within this command, and putting it afterwards doesn’t work.

…uh oh.

we may have bitten off more than we can chew here, no pun intended…

1 Like

There is a whole lot of built-in stuff that’s not very obvious when starting out, and I’m afraid that quite a lot of it will conflict with what you’re trying to do with this extension. (As an example, your post at Removing "a" or "an" From Inventory List - #6 by Sunroses – this is happening because the standard code sees a singular object.)

It seems like in essence what you want to do is try to create single objects that act as quantities of objects, but it’s not clear why you want this approach over making multiple instances of new kinds. If you describe what you’re trying to achieve at a higher level, someone might be able to offer better advice.


Might want to check this extension out which is similar, or mine it for your customized extension.


might be worth a shot, yeah! we couldn’t find this one but we knew it existed, thanks for linking it <3


turns out this extension–or rather one that relies on it–is out of date and no longer works on the current version of Inform…


Understood, but it’s always possible to mine extensions for useful code that can be applied to your own work or a new extension that does work! :smiley: