Syntax problem when defining a "generic" action

Hello,

once again I fall prey to Inform 7’s syntax and after many hours of trying permutations I have managed to go nowehre and thus I end up here again - hoping some of you folks can tell me what I am doing wrong.

I initially started with a single named person and everything was fine - I’ll put an excerpt of the code here:

RightHere is a room.

Sylke is a woman in RightHere.
Some hands are a kind of thing. some hands are part of every woman.
Hands can be cuffed or uncuffed. hands usually are uncuffed.

Restraints are a kind of thing. Restraints are wearable.
The Handcuffs are a restraints in RightHere.

Instead of frisking someone: 
	say "[The noun] is carrying [the list of things carried by the noun].";
	say "[The noun] is wearing [the list of things worn by the noun].".

After examining a woman:
	If the hands are cuffed:
		Say "Her hands are cuffed behind her back.";
	Otherwise:
		Say "Her hands are uncuffed.".

Cuffing is an action applying to one thing. Understand "Cuff [something]" as cuffing.

frisking is an action applying to a thing. Understand "frisk [something]" as frisking.

Instead of frisking someone: 
	say "[The noun] is carrying [the list of things carried by the noun].";
	say "[The noun] is wearing [the list of things worn by the noun].".

Instead of cuffing Sylke's hands:
	If Sylke's hands are cuffed:
		Say "But why do that AGAIN?";
	Otherwise:
		Say "Sylke's hands are now cuffed";
		Now Sylke has the Handcuffs;
		Now Sylke wears the Handcuffs;
		Now Sylke's hands are cuffed.

Now - the problem is that the person in the room can vary. So hardcoding the name is really, really uncomfortable because they differ in only some aspects but there is a wide range of things that are identical and independent of the actual person. So I tried to make a generic function for those and try to extract the actual person - and failed miserably. I didn’t even manage to get the generic thing right. I got as far as:

Instead of cuffing the hands part of a woman (called cuffee):
	If the hands are cuffed:
		Say "But why do that AGAIN?";
	Otherwise:
		Say "[cuffee]'s hands are now cuffed";
		Now cuffee has the Handcuffs;
		Now cuffee wears the Handcuffs.
		Let the hands part of cuffee be cuffed.

The final part is what I ended up with before I gave up - if does compile but it does not work as the examine action will prove.

I tried:

Now the hands are cuffed - compiler error
Now the hands part of cuffee are cuffed - compiler error
Now cuffee’s hands are cuffed - compiler error

And so on, and so on - it does evaluate “if the hands are cuffed” properly but I fail miserably at assigning a different status to those hands … the Let statement does compile but as the examine action shows, they’re still uncuffed.

What am I doing wrong? Is it something fundamental I am not getting? Why does “Sylke’s hands” work but “cuffee’s hands” fail?

I hope you guys can help me. :slight_smile:

Inform has problems with “the hands part of the cuffee”, because it doesn’t know this is a uniquely defined thing. It’s OK in the rule preamble, because Inform just interprets it as “any hands part of the cuffee”. But it doesn’t like it in the last line of the rule, because if a woman had multiple hands parts then it wouldn’t know which to cuff.

In fact, as you have written the rule, you can just say

now the noun is cuffed;

since the noun here is the particular set of hands you are trying to cuff. (Note: now…, not let… .)

By the way, you could declare “cuffed” by a definition (which Inform can test whenever needed) rather than a binary property which you have to set yourself. Something like this:

Definition: some hands are cuffed rather than uncuffed if a person incorporating them is wearing handcuffs.

Ah - thanks for the reply and there’s something else to look into now :slight_smile: I am using a property because the status is sometimes impeded by something not worn (I could have used “if the woman wears handcuffs” in my examine command but I was using a property for a reasaon. Now - I’ll look into that defintion thing - it does look promising and I anticipate more hours of struggling with the syntax - but for a worthwhile goal! :slight_smile:

Ack - still having a problem :frowning:

I chose the definition for a reason because I wanted to provide a shortcut for cuffing the whole person (hands and feet) or just an individual part. Now - in the above example things worked because I was referring to the part specifically but for the Whole persone routine I end up qith the same problem - especially since [the noun] in this case holds the name of the Person and I’m still stuck with addressing their part …

Before cuffing a woman (called cuffee): 
	Say "Debug: [the noun]";
	if (the player does not have Handcuffs and the player does not have Legirons):
		Say "Yeah, right - you WISH!.";
	if the player has handcuffs:
		Say "Handcuffs are being applied";
		Now cuffee has Handcuffs;
		Now cuffee wears Handcuffs;
		Now the hands are cuffed; <-- problem zone
	if the player has Legirons:
		Say "Legirons are being applied.";
		Now cuffee has Legirons;
		Now cuffee wears Legirons;
		Now the feet are cuffed. <--problem zone

I tried with “the noun’s” and “the hands part of cuffee” and a couple of other permutations but I’m again not getting anywhere. Since [the noun] can’t be used here as in before - is there still a way to reference the “proper” limbs and change their properties?

Well - I’m still interested in how to access a part’s properties via a generic function as in:

function arrest (woman suspect) {
suspect.hands = cuffed;
}

arrest(Mandy);

but I found that properties of the parent are not as problematic as properties of parts so I shifted all those now to the woman itself and can continue - I’m still curious, however, if there is an Inform 7 solution to my “function” above and how it’s actual syntax is. :slight_smile:

This is the trick:

now a random hands part of the cuffee is cuffed.

Yay - that works!

I’m still laughing though at the “elegance” of natural language versus cuffee.hands = :slight_smile:

Is it because of my declaration of the hands that we have to use “random” instead of just “the”? Would “The hands” work better - Unfortunately I never found a … conventional programmer style manual for Inform so most of what I do is from examples and modifications and far, oh so far, from what I’d call a true and thorough understanding of the language. :frowning:

Is it because of my declaration of the hands that we have to use "random" instead of just "the"?

It’s because there isn’t anything that guarantees that one and only one pair of hands will be part of any given woman. Sometimes you can declare a relation in a way that guarantees that there is only one thing that has that relation, and you can give that an appropriate name which you can refer to that in source code, and you can even use relations like this to create one such thing for each person:

[code]Ownership relates one animal (called the pet) to one woman. The verb to belong to means the ownership relation. An animal belongs to every woman.

Lab is a room. Sylke is a woman in the lab.

Instead of examining a woman (called the subject):
if the subject can see the pet of the subject:
say “[The subject] is happy to see [their] pet.”;
otherwise:
say “[The subject] looks around anxiously for [their] pet.”

After jumping when the pet of Sylke is nowhere:
say “Sylke’s pet comes to investigate the noise.”;
now the pet of Sylke is in the location.[/code]

Notice that here, since we defined ownership as a one-to-one relation and we gave the animal the name “the pet,” we can then say “the pet of sylke” without using that “a random” formulation. But I don’t know that you can combine this with “some hands are part of every woman,” because “are part of” is a predefined relation that isn’t one-to-one.

(By the way–the reason “Sylke’s hands” works is that when you say “some hands are part of every woman” and define Sylke as a woman, it generates an object whose name is “Sylke’s hands.” The apostrophe-s isn’t understood as a separate unit otherwise. If you run the pet code above, you will note that in this case the pet is not given the name “Sylke’s pet” but is just “an animal.” And in fact in that code you can’t use “Sylke’s pet” to refer to the pet in the source code.)

Also the compiler cannot assume that every woman always has exactly one pair of hands. When you say “some hands are part of every woman” you are defining how the game starts. You could later remove a pair of hands from play, or even move them to a different (Kali-esque) woman.

This has nothing to do with the natural-language setup – it would be an issue in any programming language with this world model.

(But we acknowledge that “a random…” is a clunky way to work around this rather common case.)

…I prefer a phrasing like (not tested)

if a pair of hands (called H) is part of the cuffee:
  now H is cuffed;

(And we don’t worry about the “else” case if we know that hands won’t be moved around during play.) Takes two lines, though.