To use a noose

How can I create a noose which will be able to attach to a lighting fixture and then hang the player (thus transporting the player to another room, called the afterlife?)

Snarky answer: By thinking through the problem in a logical, step-by-step manner.

Unhelpful answer: Have you read section 10.6 in the Recipe Book?

Slightly more helpful answer: First, create a rope. Second, allow the rope to be fashioned into a noose. When this step is done, whisk the rope offstage and replace it with a noose object. This is tricky, however, because the player may try “tie noose” before the noose is created, so you’ll need to figure out how to let the word “noose” be used. You might try making a fake-noose object be a part of the rope, and reject most of the commands directed to the noose with a “You haven’t created a noose” message.

Third, use a standard attaching action (whatever it is) to put the noose on the lighting fixture. Fourth, implement the commands “put head through noose” and “put neck in noose,” and so forth.

Oh, by the way – you might want to provide a chair. Have the player only be allowed to “put neck in noose” while standing on the chair. After which, “kick chair” or “step off of chair” or “get down” would hang the player.

Yes. So I have made the rope and noose and have figured out how to “tie” it which is actually making the rope disappear and the noose appear in the inventory. I actually have a stool in the room.
In Section 10.6, “Snip” is completely useless and “Otranto” actually creates a rope that, although very realistic, is in fact too complicated for my needs.

I’ve been ruminating on this little problem for ages actually but the idea of creating a separate action never occurred to me.
However my main stuck bit you seemed to skip over. How can I actually attach the noose to the lighting fixture?
And will the player’s head actually be IN the noose (like a wearable object) or not?

I’m considering playing around with this problem, but I suspect that the reply will be “some time ago, I wrote an extension to do just this. Hanging by Jim Aikin. Download it today.”

I’d download an extension if I really had too, it’s just I am sure it’s possible.
I tried making the noose two parts, one part wearable (the loop) and the end attachable but firstly Inform doesn’t like one part of something being wearable (at least that’s what I’ve found) and it doesn’t know what “attaching” is besides that it is a action that does nothing.
I tried writing “The block tying rule is not listed in the check tying it to rulebook” but this doesn’t really do much (mainly because I can’t really figure out how to “reconstruct the action as something more substantial” like Inform suggests). And Inform thinks tying to and attaching are the same thing.

Any suggestions?

The comment about an extension was a joke. For context, see Jim’s replies to code that I posted in this thread and this thread.

As for your noose, I’d try modeling it as one wearable object and have attachment be a one-to-one relation, assuming that you won’t allow different ends of the rope, prior to its becoming a noose, to be attached to different things.

You could also just do the whole thing in an ad hoc manner and forego the idea of a relation. Give the noose a “tied to the beam” property, set it when the player types “tie noose to beam” or “attach noose to beam”, disallow attaching the noose to anything else, and then alter the noose description, the room description, the player’s inventory, and the player’s ability to travel when holding the noose based on whether the property is set.

The whole thing is going to be an exercise in thinking up corner cases and making sure that they’re handled properly: can’t tie the noose to the beam unless standing on the stool, complain if it’s already tied, mock the player if they kick the stool or jump off the stool wearing the noose when it’s not attached to the beam (or not wearing the noose when it is attached to the beam), and so on. I’d suggest getting the expected sequence of actions working properly first and then testing it vigorously and fixing issues as you discover them.

To solve this particular issue, assuming you’ve defined an “attaching it to” action, you can do:

Understand the command "attach" as something new.
Understand "attach [something] to [something]" as attaching it to.

to make “attach” distinct from “tie”, although I don’t think that in this case you need to separate these two actions.

Well I knew it was a bit of a joke (regarding the “some time ago, I wrote an extension to do just this. Hanging by Jim Aikin. Download it today”) but I also took the existence of a extension as serious.

Anyway. That’s a lot of information to digest. I’ll give it the ol’ college try and see if I can get it to work.

I gave this a shot as an exercise and came up with a reasonable first draft. It’s fairly involved, so I’m sticking the code in rant tags and also attaching it as a file. I’m still learning Inform 7, so I’m sure that this could be a lot tighter. I don’t intend to do anything with this code other than having it sit here and be an example of the evilness of rope, but I welcome any corrections or suggestions.

[rant=Hanging Around][code]
“Hanging Around”

[Don’t read too much into this. It’s inspired by a programming question asked here:
https://intfiction.org/t/to-use-a-noose/9721/1]

Section 1 - The Lab and the Lighting Fixture

Lab is a room. “A dismal room with a lighting fixture overhead. A hallway is to the south.”

The lighting fixture is scenery in the Lab. The description of the lighting fixture is “This rectangular enclosure of frosted glass protrudes about six inches from the ceiling.[if the rope is attached to the lighting fixture] [A rope] has been tied to the fixture.[end if]”.
Understand “light” or “lights” as the lighting fixture.

Instead of doing something other than examining to the lighting fixture when the player is not on the stool:
say “You can’t reach the lighting fixture from here.”

Instead of doing something when the lighting fixture is the second noun and the player is not on the stool:
say “You can’t reach the lighting fixture from here.”

Instead of tying the rope to the lighting fixture:
if the rope is attached to the lighting fixture:
instead say “[The rope] is already tied to the lighting fixture.”;
if the player does not enclose the rope:
instead say “You’re not carrying [the rope].”;
if the player is not on the stool:
instead say “You can’t reach the lighting fixture from here.”;
now the rope is attached to the lighting fixture;
say “You wrap [the rope] around the lighting fixture and secure it with a strong knot.”

Instead of untying the rope when the rope is attached to the lighting fixture:
try untying the rope from the lighting fixture.

Instead of untying the rope from the lighting fixture when the rope is attached to the lighting fixture:
if the player is not on the stool:
instead say “You can’t reach the lighting fixture from here.”;
now the rope is unattached;
now the player carries the rope;
say “You untie the knot, grab hold of [the rope], and remove it from around the lighting fixture.”

Section 2 - The Stool

A stool is here. The stool is an enterable supporter. The stool is not fixed in place. The stool can be upright or kicked over. The stool is upright. The description of the stool is “Tall, but flimsy.”

Rule for writing a paragraph about the stool:
if the stool is kicked over:
say “A stool lies on its side on the ground here.”;
otherwise:
say “There is a stool [no line break]”;
if there is something on the stool:
say “(on which [are] [a list of things on the stool]) [no line break]”;
say “here.”

Before taking the stool when the stool is kicked over:
if the player’s command includes “pick up”:
instead try straightening the stool.

After taking the stool when the stool is kicked over:
say “(righting the stool)”;
now the stool is upright;
continue the action.

After dropping the stool:
say “You set down the stool.”

Before straightening the stool:
if the stool is upright:
instead say “The stool is already upright.”

After straightening the stool:
now the stool is upright;
say “You pick up the stool and set it down upright.”

Before entering the stool when the stool is kicked over:
instead say “You’ll need to pick up the stool first.”

Before putting something on the stool when the stool is kicked over:
instead say “You’ll need to pick up the stool first.”

To flatten the stool:
now the stool is kicked over;
repeat with item running through things that are on the stool:
if item is not the player:
now item is in the location of the stool.

To take a fall with action text (T - a text):
if the rope is worn by the player and the rope is attached to the lighting fixture:
say “You [T] the stool and feel the noose tighten around your neck as you plummet…[paragraph break]”;
now the rope is in the Lab;
now the player is in the Afterlife;
continue the action;
otherwise if the rope is worn by the player and the rope is unattached:
say “You [T] the stool and fall to the floor. The noose is tight around your neck, but the rope trails loosely and ineffectually behind you.”;
otherwise if the rope is attached to the lighting fixture and the player encloses the rope:
now the rope is in the Lab;
say “You [T] the stool and begin to fall. [The rope], firmly attached to the lighting fixture, slips from your hands as you crash to the ground[no line break]”;
if the current action is jumping off:
flatten the stool;
say “, knocking over the stool[no line break]”;
say “.”;
if the rope is tied into a noose and the rope is not thought provoking:
now the rope is thought provoking;
say “It occurs to you that things could have gone very differently had you been wearing the noose.”;
now the player is in the location of the stool;
continue the action;

After kicking over the stool:
flatten the stool;
if the player is on the stool:
if the rope is worn by the player or (the rope is attached to the lighting fixture and the player encloses the rope):
instead take a fall with action text “kick over”;
say “You kick over the stool and fall to the floor.”;
now the player is in the location of the stool;
otherwise:
say “You kick over the stool.”

After jumping off the stool:
if the rope is worn by the player or (the rope is attached to the lighting fixture and the player encloses the rope):
instead take a fall with action text “jump off”;
continue the action;

Instead of jumping when the player is on the stool:
try jumping off the stool.

Instead of going down when the player is on the stool:
try jumping off the stool.

Instead of going up when the stool is in the location of the player:
try entering the stool.

Instead of climbing the stool:
try entering the stool.

Instead of getting off the stool:
try jumping off the stool.

Section 3 - The Rope and the Noose

A rope is here. The rope can be attached to the lighting fixture or unattached. The rope can be tied into a noose or untied. The rope can be thought provoking. The rope is unattached and untied and not thought provoking.
Understand “noose” as the rope when the rope is tied into a noose.

Instead of examining the rope:
say “Sturdy.[no line break]”;
if the rope is tied into a noose:
say " One end of the rope has been tied into a noose[no line break]";
if the player is wearing the rope:
say " (which is secured around your neck)[no line break]";
say “.[no line break]”;
if the rope is attached to the lighting fixture:
if the rope is tied into a noose:
say " The other end is[no line break]";
otherwise:
say " One end of the rope has been[no line break]";
say " tied to the lighting fixture.[no line break]";
say “[line break]”.

Rule for writing a paragraph about the rope:
if the rope is attached to the lighting fixture:
say “[The rope] hangs from the lighting fixture[if the player is not on the stool], out of reach[end if].[no line break]”;
if the player encloses the rope:
if the rope is worn:
say " The noose is secured around your neck.[no line break]";
otherwise:
say " You’re holding one the loose end of the rope.[no line break]";
say “[line break]”;

After looking when the Lab encloses the player and the player encloses the rope and the rope is attached to the lighting fixture:
if the rope is worn:
say “The rope extends from the noose around your neck up to the lighting fixture, where it is attached.”;
otherwise:
say “[The rope] that you’re holding extends up to the lighting fixture, where it is attached.”

Rule for printing inventory details of the rope:
if the rope is worn:
say " (around your neck)";
if the rope is attached to the lighting fixture:
say " (attached to the lighting fixture)";

Instead of doing something other than examining to the rope when the player is on the stool and the rope is unattached and the rope is in the location of the stool:
say “You can’t reach [the rope] from up here.”

Instead of doing something when the rope is the second noun and the player is on the stool and the rope is unattached and the rope is in the location of the stool:
say “You can’t reach [the rope] from up here.”

After dropping the rope when the rope is attached to the lighting fixture:
now the rope is in the Lab;
instead say “You let go of [the rope]. It continues to hang from the lighting fixture where you attached it.”

Before taking the rope when the rope is attached to the lighting fixture:
if the player is not on the stool:
instead say “You can’t reach [the rope] from down here.”

After taking the rope when the rope is attached to the lighting fixture:
Instead say “You take hold of [the rope].”

Instead of rope shaping the rope when the second noun is a noose:
if the rope is tied into a noose:
instead say “The rope is already tied into a noose.”;
if the player does not enclose the rope and (the rope is not attached to the lighting fixture or the player is not on the stool):
instead say “You’re not carrying the rope.”;
now the rope is tied into a noose;
now the rope is wearable;
now the printed name of the rope is “noose”;
say “You tie [if the rope is unattached]one end[otherwise]the loose end[end if] of the rope into a noose.”

Instead of untying the rope from the rope when the rope is tied into a noose and the rope is not attached to the lighting fixture:
try untying the rope.

Instead of untying the rope when the rope is unattached and the rope is tied into a noose:
if the player does not enclose the rope:
instead say “You’re not carrying the noose.”;
if the player is wearing the rope:
now the player carries the rope;
say “(first taking off the noose)[line break]”;
now the rope is untied;
now the rope is not wearable;
now the printed name of the rope is “rope”;
say “You untie the noose. Now it’s just a rope.”

After wearing the rope:
say “You slip the noose around your neck and tighten it.”

After taking off the rope:
say “You loosen the noose and slip it off.”

Section 4 - The Hallway and the Afterlife

Hallway is south of the Lab. “The lab is to the north.”

Afterlife is a room. “Fluffy clouds and long lines. You should have made a reservation.[if Afterlife is not visited][paragraph break]None of your friends are here.[end if]”

Every turn when the player is in the Afterlife:
If the player has been in the Afterlife for five turns:
end the story finally saying “You must wait”.

Section 5 - Actions and Parsing

Kicking over is an action applying to one visible thing.
Understand “kick [something]” or “kick over [something]” as kicking over.

Check kicking over:
if the player encloses the noun:
instead say “You’ll have to put down [the noun] first.”

Understand “set down [something]” as dropping.

Straightening is an action applying to one visible thing.
Understand “straighten [something]” or “right [something]” as straightening.

Report straightening:
instead say “[The noun] doesn’t need straightening.”

Jumping off is an action applying to one visible thing.
Understand “jump off [something]” or “jump off of [something]” as jumping off.

Check jumping off:
if the player is not on the noun:
instead say “You’re not on [the noun].”

Carry out jumping off:
move the player to the location of the noun, without printing a room description.

Report jumping off:
say “You jump off of [the noun].”;
try looking.

A rope shape is a kind of thing. A rope shape is privately-named.
A noose is a rope shape. Understand “noose” as a noose.
[Anonymous shape is here to make the desired rope shape ambiguous and force the player to explicitly choose noose]
An anonymous rope shape is a rope shape.

Rope shaping is an action applying to one visible thing and one visible thing.
Understand “tie [something] into [any rope shape]” or “tie [something] to [any rope shape]” as rope shaping.
Understand “make [any rope shape] with [something]” or “form [any rope shape] with [something]” or “tie [any rope shape] with [something]” as rope shaping (with nouns reversed).

Report rope shaping:
instead say “You can’t make [a second noun] out of [the noun].”

Does the player mean tying the rope to the rope:
It is unlikely.

Does the player mean tying the rope to the lighting fixture:
It is likely.

Does the player mean kicking over the stool:
It is likely.

Untying is an action applying to one visible thing.
Understand “untie [something]” or “detach [something]” as untying.

Untying it from is an action applying to one visible thing and one visible thing.
Understand “untie [something] from [something]” or “detach [something] from [something]” as untying it from.

Does the player mean untying the rope from the lighting fixture:
if the rope is attached to the lighting fixture:
it is very likely.

Report untying:
instead say “[The noun] isn’t attached to anything.”

Report untying it from:
instead say “[The noun] isn’t attached to [the second noun].”

test me with “take rope / make noose / stand on stool / tie rope to fixture / wear noose / kick stool / z / z / z / z / z”
[/code][/rant]
Edit: fixed an oversight (handle “get off stool”)
hanging.txt (12.7 KB)

The only way I can see it get cleaned up a little is creating the rope and the noose as separate things, then the whole “rope shaping” phrases wont really need to be so explicit.

But this is just amazing!