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;
Otherwise:
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;
Otherwise:
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;
Otherwise:
now P is the item;
if the player has P:
Increase the quantity of P by N;
otherwise:
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.
---- DOCUMENTATION ----
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"