Dividing a room into sections

I had the idea a while back to create a “metroidvania” style game in Inform, with equipment-based progression being the rule of thumb. First, I decided to make an “Equipment Testing Facility” for coding how the equipment would work independent of any puzzles, so I can work on the puzzles with knowledge of what the equipment will do.

Where I’ve run into trouble is with making a grappling hook item. What I want this item to do is allow the player to traverse certain gaps, preferably within rooms. In order to have this, I’ve realized I need a way to create gaps in rooms. This is what I have so far:

[code]Equipment is a kind of thing. Equipment can be equipped or not equipped. Equipment is usually not equipped.
Carry out taking equipment:
say “[Noun] taken.”;
try silently examining the noun.

After taking something:
try silently equipping the noun.

Equipping is an action applying to one thing. Understand “q [something]”, “equip [something]”, and “put on [something]” as equipping.

Carry out equipping a thing:
if the noun is not equipment, say “You can’t equip that.”;
if the noun is equipment:
if the noun is equipped:
say “You’ve already equipped that.” instead;
if the noun is not equipped:
now the noun is equipped;
say “[Noun] equipped.”.

Unequipping is an action applying to one thing. Understand “unequip [something]” and “take off [something]” as unequipping.

Carry out unequipping a thing:
if the noun is not equipment, say “That can’t even be equipped, much less unequipped.”;
if the noun is equipment:
if the noun is not equipped:
say “That’s not equipped.”;
if the noun is equipped:
now the noun is not equipped;
say “You remove [the noun] with no trouble.”.

Grapple Room is a room. “This room is for testing the grappling hook.
You stand on one of four platforms above a featureless void. The four platforms are northside, southside, eastside, and westside. You stand on the [player position] platform. Above you are a few I-beams.”

After entering Grapple Room:
now the player position is eastside.

Check going somewhere when the location is grapple room:
if the internal position is eastside:
continue the action;
otherwise:
say “The door’s over on eastside, you numbnut.” instead.

The Grappling Hook is a thing in Grapple Room. It is equipment. Understand “grapple” as the grappling hook. The description of the Grappling Hook is “It’s a simple affair, a thin but strong-looking cable with a weighted, four-hooked grapple attached at one end. Attached to the other end is a note: 'Use the command ‘grapple to (direction)side’ to get to that location.”

Understand the command “grapple” as something new.

Grappling to is an action applying to an internal position. Understand “grapple to [an internal position]” as grappling to.

Carry out grappling to:
if the grappling hook is not equipped:
say “How are you going to do that?” instead;
otherwise if the grappling hook is equipped:
say “You throw the hook up to an I-beam, and after a quick check that it’s secure, swing across to the [internal position] platform with no trouble at all. Nice!”;
now the internal position is the player position.[/code]

The equipping and unequipping goes fine. What doesn’t work is the “internal position” value. Specifically, the error pops up in the “carry out grappling” section, where it says that the [internal position] thing doesn’t work, but doesn’t give a great solution. If there’s a better way to divide a room into sections, I would love to hear it; I took that from Inform’s documentation because I couldn’t find another method.

1 Like

Wouldn’t it be easier to have 4 different rooms, and pretend they are parts of one room? There would be no way of getting between them with out grappling.

They would all have the same room description, just varied by area. It might look a bit odd on the map, but there are ways to tweak the map output for the final game.

That would probably work, though I’ve had trouble with restricting travel between particular rooms. Perhaps I should make a rulebook for this?

I’ve had a read of the documentation, and I think you want Recipe book section 3.3 “positions within rooms”. [internal position] is not a standard I7 variable, it’s a type of value in the project “Further Reasons Why All Poets Are Liars”.

Restricting travel between rooms ought to be a fairly simple instead of going rule :question:

instead of going north from {the room that is pretending to be the south corner} do nothing.

grappling results in moving the player bodily to the new location but suppressing any other messages about arriving in a new room. I think…

Akshully, if there is no exit from each of the rooms*, then the only way between them would be by grappling, so if the player tries to go north, they fall in the gap and die (or get a warning if you like :smiley: )

*apart from the room with the real door

I was using code I cribbed from “Reasons All Poets Are Liars” for the “internal position” variable, and forgot to put that in the extracted code. My apologies. If I can make that work better, I’d prefer to use it over multiple rooms.

In your original code, you’re trying to treat “internal position” as both a kind and a variable, which won’t work. (You also wrote [internal position] at one point, which just comments out that text if it’s not inside a string.)

I imagine you have a declaration like

An internal position is a kind of value. The internal positions are eastside, westside, northside, southside.
The player position is an internal position that varies.

Remember to always refer to an internal position (the kind), and the player position (the variable). The compiler doesn’t require this, but it will keep you from getting confused.