Defining the relation "door blockage"

Hi there,

I’m still a beginner in Inform 7 and I’ve run across another problem I need help with. I want to define a door blockage relation so you cannot simply open a door that is blocked by something.
Here’s what I tried but I get an error that Inform doesn’t understand “'moving a door-blocking thing”:

[code]Door blockage relates various things to one door.
The verb to block means the door blockage relation.

Definition: A thing is door-blocking if it is blocking a door.
Definition: A door is blocked if the list of things blocking the noun is not empty.

Instead of opening a blocked door, say “[We] [cannot] [open] [the noun] because it is blocked by [a list of things blocking the noun].”

After examining a blocked door, say “The door is currently blocked by [a list of things blocking the noun].”
After examining a door-blocking thing, say “It is currently blocking [the door blocked by the noun].”

Instead of moving a door-blocking thing:
say “[We] [move] [the noun] away from [the door blocked by the noun].”;
now the door blocked by the noun is not blocked by the noun.[/code]
How should I rephrase it?
Thanks for your answers!

“Moving” isn’t a built-in action. You could use “pushing” or “pulling” instead, or define a new action for it.

I made it work with open and closed doors (you can’t open a blocked door, and you can’t traverse an open door with a filing cabinet blocking it). I also made a verb so if an object is declared an “impediment” the player can use it to block a door. If you want to prevent NPCs moving through blocked doors, it will require some additional “check an actor/carry out an actor” rules.

[code]“Blocking/Barring Test” by Hanon Ondricek

a thing can be an impediment. a thing can be blockable. A door is usually blockable.

blocking relates one door to various things. The verb to block implies the reversed blocking relation.

Last report examining a thing (called D):
if something blocks D:
say “[The noun] is blocked by [a list of things blocking D].”

Check opening a door (called D):
if something blocks D:
say “[The D] is blocked by [a list of things blocking D], so it won’t open easily.” instead.

Check going through a door (called D):
if something blocks D:
say “[The D] is blocked by [a list of things blocking D]. You’ll need to move [if the number of things blocking D is 1]it[otherwise]them[end if] first.” instead.

Carry out taking:
if the noun blocks something:
say “(First moving [the noun] out of the way of [the random thing blocked by the noun].)[command clarification break]”;
now the noun blocks nothing.

Check pushing something (called I):
if I blocks something:
try taking I instead.

barring is an action applying to two things. Understand “block [something] with [something preferably held]” and “bar [something] with [something preferably held]” and “obstruct [something] with [something preferably held]” as barring.

Check barring:
if the second noun is not an impediment:
say “[The second noun] isn’t a suitable thing to block [the noun].” instead.

Check barring:
if the noun is not blockable:
say “You see no good way to block [the noun].” instead.

Carry out barring:
now the second noun blocks the noun;
now the second noun is in the location.

Report barring:
say “You manage to obstruct [the noun] with [the second noun] as well as you can.”

Last report examining:
if the noun blocks something:
say “[The noun] is blocking [the random thing blocked by the noun].”

Example Location is a room.

Success Location is a room.

a battered door is a door. It is north of Example Location and south of Success Location. “A battered door is your only way out to the [direction of battered door from the location].”

a splintery plank is an impediment in Example Location. It blocks battered door.

a flimsy bent wood chair is an impediment in example location. It blocks battered door. It is an impediment.

a short filing cabinet is a container in example location. It blocks battered door. It is an impediment.

A plate of spaghetti is in Example Location.

Check taking short filing cabinet:
say “Ugh, it’s a little heavy to pick up, but you do manage to budge it a few feet from where it was.”;
now short filing cabinet blocks nothing;
rule succeeds.

Test me with “n/open door/take plank/n/move chair/push cabinet/open door/n/l/s/take spaghetti/block door with spaghetti/block door with chair/n/push chair/n”[/code]

Thanks, that helps a lot! :slight_smile:

I’ve also implemented an unblocking action that works:

[code]Unblocking is an action applying to one thing. Understand “unblock [something]” as unblocking.

Check unblocking when the list of things blocking the noun is empty:
say “[We] [cannot] unblock something that isn’t blocked.”;
stop the action.

Carry out unblocking:
let B be the number of things blocking the noun;
repeat with N running through the list of things blocking the noun:
try moving out N;
if the list of things blocking the noun is empty:
say “[We] [have] successfully unblocked [the noun].”;
now nothing blocks the noun;
otherwise:
let C be the number of things blocking the noun;
say “[We] [could not] unblock [the noun][if C is less than B] completely. The following things are still blocking [the noun]: [a list of things blocking the noun][end if].”.[/code]
P.S.: “moving out” is defined properly somewhere else.

At that point, “N” isn’t defined. A variable created in a repeat-block doesn’t exist after the block, since it’s unclear what value you’d expect it to have; even if it were allowed, it certainly wouldn’t be a number (since all of its values are things).

By the way, you don’t need the “list of” phrases here; you can also say “repeat with N running through things blocking the noun” and “if nothing is blocking the noun”.

Ah sorry, I wrote N instead of B… :unamused:

I also refined the rules a little bit for blocking things that are not visible (when the door is blocked from the inside and the player is on the outside for example):

[code]Check opening a door (called D):
if something blocks D:
let B be the number of visible things blocking D;
say “[The D] won’t open [if B > 0] because it is blocked by [a list of visible things blocking D].[end if][if B is 0] It seems to be blocked by something[end if].” instead.

Check going through a door (called D):
if something blocks D:
let B be the number of visible things blocking D;
say “[if B is 0][The D] seems to be blocked.[end if][if B > 0][The D] is blocked by [a list of visible things blocking D]. You’ll need to move[end if] [if B is 1]it[else if B > 1]them[end if] first.” instead.[/code]