Code for a label-maker

There was a conversation in chat about how to let the player name certain objects and then use that label to refer to them – I figured I’d take a quick crack at that. I’m sure this code could be improved in all sorts of ways, but it’s a reasonable starting point I think!

"Label Maker" by Mike Russo

The Kitchen is a room.  The label-maker is in the kitchen.  Understand "label/-- maker/labeler" as the label-maker.  The description of the label-maker is "It's one of those label-makers that prints out a customizable sticky label in all-white capitalized text, like in a 90s zine."

A labelable-thing is a kind of thing.  A labelable-thing is either labeled or unlabeled.  A labelable-thing is usually unlabeled.  A labelable-thing has a text called the current-label.  Understand the current-label property as describing a labelable-thing.  A labelable-thing has a text called the primitive-name.  A labelable-thing has a text called the primitive-description.  

For printing the name of a labelable-thing (called the foo):
	Say "[primitive-name of the foo][if the foo is labeled] labeled '[current-label of the foo]'[end if]".
	
Carry out examining a labelable-thing (called the foo):
	Say "[primitive-description of the foo][if the foo is labeled], with a stick-on label reading '[current-label of the foo]'[end if].";
	Stop the action.

The magnet is a labelable-thing in the kitchen.  The primitive-name is "magnet".  The primitive-description is "A simple black bar magnet".

The toaster is a labelable-thing in the kitchen.  The primitive-name is "toaster".  The primitive-description is "It's the kind of toaster where you push the slices of bread down into the slots".

The carrot is an edible thing in the kitchen.

Labeling it with is an action applying to one touchable thing and one topic.  Understand "label [something] with/as/-- [text]" as labeling it with.

Check labeling it with:
	If the player does not carry the label-maker:
		Say "How do you intend to do that, exactly?" instead;
	If the noun is not a labelable-thing:
		Say "It resists being labeled." instead;
	If the noun is the label-maker:
		Say "Yeah it isn't going to bend that way." instead.
		
Carry out labeling it with:
	Say "You print out a label reading '[topic understood]' and slap it on [the primitive-name of noun][if the noun is labeled], right over the previous label[end if].";
	Now the current-label of the noun is the topic understood;
	Now the noun is labeled.
	
Label-removing is an action applying to one touchable thing.  Understand "remove label from/off [something]" as label-removing.  Understand "pull label from/off [something]" as label-removing. Understand "delabel [something]" as label-removing.

Check label-removing:
	If the noun is not labeled, say "It doesn't currently have a label." instead.
	
Carry out label-removing:
	Say "You peel the label reading '[current-label of the noun]' off of the [primitive-name].";
	Now the noun is unlabeled.

(@pinkunz, @Zed, @Lancelot maybe? I forget who all was in the conversation).

6 Likes

Aotearoa lets you name dinosaurs and remembers the names throughout. It uses the name and lets the player refer to the dinosaur with it. I don’t know if there is source code or other documentation to be found for that game.

Aotearoa - Details (ifdb.org)

3 Likes

The documentation example “Fido” handles naming a game object, in somewhat less detail than Mike’s example above.

One problem I’ve encountered with understand the [whatever] property as describing [the thing] is that the property exists as a single text snippet. If you name the dog “Princess Grace,” the parser won’t know what you mean when you refer to the dog simply as “Grace.”

People were doing this sort of thing with the customizable jacket in Ryan Veeder’s Authentic Fly Fishing, so I had to work around it like this (simplified version):

Jacketcoloring is a truth state that varies. Jacketcoloring is false.

Instead of examining the jacket while jackethue of the jacket is "":
	say "It's a simple lightweight jacket. What color is it?[paragraph break][italic type]Please enter the color of your jacket[roman type].";
	now jacketcoloring is true;
		
After reading a command while jacketcoloring is true:
	now jackethue of the jacket is the player's command;
	now jackethue of the jacket is jackethue of the jacket in lower case;
	split up the jacket name;
	say "Your jacket is [jackethue of the jacket]. Is that correct?[paragraph break]>";
	now jacketcoloring is false;
	loop jacket color consent;
	reject the player's command;

To loop jacket color consent:
	if player consents:
		say "Gotcha.";
	otherwise:
		now jacketcoloring is true;
		say "Okay, let's try this again. What color is your jacket?";

“Splitting up the jacket name” involves assigning each word in the “jackethue” snippet to a different property of the jacket. There are eleven such properties, to accommodate some hilarious tester who wanted to wear a “dark blue floor-length dragon-embroidered sun-bleached cotton-rayon blend jacket” or something like that—and then expected the game to recognize “blue jacket” as the same jacket.

The jacket has a text called the jacketterm1. Understand the jacketterm1 property as describing the jacket.

The jacketterm1 of the jacket is "".

The jacket has a text called the jacketterm2. Understand the jacketterm2 property as describing the jacket.

The jacketterm2 of the jacket is "".

The jacket has a text called the jacketterm3. Understand the jacketterm3 property as describing the jacket.

The jacketterm3 of the jacket is "".

The jacket has a text called the jacketterm4. Understand the jacketterm4 property as describing the jacket.

The jacketterm4 of the jacket is "".

The jacket has a text called the jacketterm5. Understand the jacketterm5 property as describing the jacket.

The jacketterm5 of the jacket is "".

The jacket has a text called the jacketterm6. Understand the jacketterm6 property as describing the jacket.

The jacketterm6 of the jacket is "".

The jacket has a text called the jacketterm7. Understand the jacketterm7 property as describing the jacket.

The jacketterm7 of the jacket is "".

The jacket has a text called the jacketterm8. Understand the jacketterm8 property as describing the jacket.

The jacketterm8 of the jacket is "".

The jacket has a text called the jacketterm9. Understand the jacketterm9 property as describing the jacket.

The jacketterm9 of the jacket is "".

The jacket has a text called the jacketterm10. Understand the jacketterm10 property as describing the jacket.

The jacketterm10 of the jacket is "".

The jacket has a text called the jacketterm11. Understand the jacketterm11 property as describing the jacket.

The jacketterm11 of the jacket is "".

To split up the jacket name:
	now jacketterm1 of the jacket is "";
	now jacketterm2 of the jacket is "";
	now jacketterm3 of the jacket is "";
	now jacketterm4 of the jacket is "";
	now jacketterm5 of the jacket is "";
	now jacketterm6 of the jacket is "";
	now jacketterm7 of the jacket is "";
	now jacketterm8 of the jacket is "";
	now jacketterm9 of the jacket is "";
	now jacketterm10 of the jacket is "";
	now jacketterm11 of the jacket is "";
	now jacketterm1 of the jacket is word number 1 in the jackethue of the jacket;
	now jacketterm2 of the jacket is word number 2 in the jackethue of the jacket;
	now jacketterm3 of the jacket is word number 3 in the jackethue of the jacket;
	now jacketterm4 of the jacket is word number 4 in the jackethue of the jacket;
	now jacketterm5 of the jacket is word number 5 in the jackethue of the jacket;
	now jacketterm6 of the jacket is word number 6 in the jackethue of the jacket;
	now jacketterm7 of the jacket is word number 7 in the jackethue of the jacket;
	now jacketterm8 of the jacket is word number 8 in the jackethue of the jacket;
	now jacketterm9 of the jacket is word number 9 in the jackethue of the jacket;
	now jacketterm10 of the jacket is word number 10 in the jackethue of the jacket;
	now jacketterm11 of the jacket is word number 11 in the jackethue of the jacket;

I guess this could be generalized for a game where you can name/label a lot of things. A labelable-thing has a text called the custom-synonym-1...

3 Likes

That might be one of the few problems best solved by a custom Understand token.

2 Likes