Referencing a part of an assembly in code?

I’ve been experimenting with assemblies lately, and I’m rather stumped on how to refer to a particular child of an assembly. Given the example:

An ear is a kind of thing.
Every person incorporates an ear (called their left ear).
Every person incorporates an ear (called their right ear).

The Testhole is a room. Sam is a person and here.

I can refer to parts of the assembly in-game:

>x sam's left ear
You see nothing special about Sam's left ear.

However, I’m yet to figure out how to express something similar in code:

Yanking the ear of is an action applying to one thing.
Carry out yanking the ear of someone (called the victim):
	 let the attacked ear be [???];
	 say "You tug on [the attacked ear]."

In the blank slot, I’ve tried various phrases like the victim's left ear, the left ear part of the victim, and so forth-- but the compiler doesn’t accept any of these. (I can’t quite say a random ear part of the victim, since it could select the right ear instead.)

I’m not sure if I’m simply missing the syntax, somehow, or if it’s somehow impossible to reference a specific part of an assembly as such. What might I be missing?

I think in your case, the best solution is to actually let the player be specific in naming the ear they want to yank. Then Inform will automatically ask them which ear they want if they aren’t specific. It happens that this doesn’t involve trying to locate/identify parts of an assembly. Try this code:

The Testhole is a room. Sam is a person and here.

An ear is a kind of thing.

A left ear is a kind of ear.
A right ear is a kind of ear.

A left ear is part of every person.
A right ear is part of every person.

yanking a named ear is an action applying to one thing.

Understand "yank [an ear]" as yanking a named ear.

Test me with "yank ear/sam's right".

-Wade

1 Like

Returning to your original coding request, here’s a way to identify bits of people.

If you know the player has a left ear, choosing a random left ear enclosed by the player will return the only left ear you know they have… their left ear:

You can add the following three lines to my previous example to see it in action. It will always return an ear-ache in the left ear:

When play begins:
	say "You have an ear-ache! ";
	let the sore ear be a random left ear enclosed by the player;
	say "It's [sore ear].";

You could also randomly (actually randomly this time!) choose a different ear to be sore each time the game is restarted by changing the middle line to:

let the sore ear be a random ear enclosed by the player;

It is true that ‘incorporated by’ and ‘enclosed by’ are different, but in this example, we don’t expect the player to be carrying any extra ears around in their inventory or posessions, Blue Velvet-style. At least I hope not. But you could indeed replace the word ‘enclosed’ in my examples with ‘incorporated’.

-Wade

1 Like

The only thing I can think of that Wade hasn’t already covered is regarding your yanking action. Something like this should allow you to do action processing for particular ears:

Understand "yank" as pulling

Then you can do stuff like:

After pulling Sam's left ear:
	say "Sam glares."

This is more of a readability thing than anything else. You don’t have to tie this in to pulling, but you might want to make the last word of your action name a present participle (a word ending in -ing). The compiler can get really funny if it can’t break down sentences into verbs and nouns.

Thanks for all the advice! I think I’ll be using severedhand’s strategy of using a named kind (and I’ll keep the advice about the gerund in mind, thanks rainmaze). Cheers!