Hidden door

I know I can’t be the only person to have wanted this, but I’ll be darned if I can figure out how to do it.

There’s a forest with underbrush. Until the player clears the underbrush, he can’t see the barbed wire, which is a door (and needless to say, can’t go east where it would lead). Even after clearing underbrush, he can’t climb the barbed wire without wearing a protective garment or clipping the barbed wire, but that seems easy enough to program and might be too much info for the problem at hand.

If I say

Barbed wire is a door. Barbed wire is east of the forest and west of the army base

You can see, climb, taste, and smell that darned barbed wire. And while I could omit it from the description, and program “instead” code for all that, it seems like there must be a better way, since a savvy player might detect the door.

If I say

[code]Limbo is a container. Barbed wire is in limbo.

Instead of cutting the underbrush:
say “now you’ve cut away the underbrush.”;
now barbed wire is a door;
now barbed wire is east of the forest and west of the army base.[/code]

Or any related construction, Inform doesn’t like that.

I could make barbed wire not a door per se, like so:

[code]Barbed wire is a thing. Barbed wire is fixed in place.
isUnderbrushCleared is a number that varies. isUnderbrushCleared is 0.

Instead of cutting the underbrush:
say “now you see barbed wire”;
move barbed wire to the location;
isUnderbrushCleared is 1.

Instead of going east when the player is in the forest and isUnderbrushCleared is 1:
say “You go east to the army base”;
move player to army base.[/code]

But I’m afraid this will give me trouble when I want other people in the game to be able to follow the player in and out the door, and possibly in other door-related situations as well.

I see a lot of ways to proceed, but I’m not sure which will give me the least trouble. Any advice?

Maybe the extension Secret Doors will do what you want?

Yeah, Secret Doors will probably be helpful, but I’ll explain some things which were causing you confusion:

Indeed, you can’t create new objects with “Now” – Inform does not allow dynamically allocating new objects or table rows at runtime (though Jesse McGrew has some extensions to allow this). I think you were on the right path as far as moving the barbed wire into place in the second example. Another option which is perhaps more complex is to take advantage of the “Deciding the scope of something” activity as documented in Chapter 17 of the Inform 7 manual. This would allow you to say that the barbed wire door is not in the scope of the player until he has cleared out the underbrush, which would mean that even though the barbed wire is there, it would not be accessible via any of those actions that you mentioned.

So, about your second example: there are a couple things that would generalize and simplify it. You didn’t need to create a new “isUnderbrushCleared” variable – instead, you could write your code such that instead of checking that variable, it would check for the presence of the barbed wire. You also don’t need to implement the “move” manually:

The forest is a room.
The underbrush is in the forest.
The barbed wire is a thing.

The destination is east of the forest.

Instead of cutting the underbrush:
    say "The barbed wire draws near!";
    move barbed wire to the location;

Before going east when the player is in the forest:
	if the barbed wire is not in the forest:
		say "There seems to be underbrush blocking your way!";
		stop the action;

Hope this helps a bit.

Radix, that’s certainly simpler than what I did. Thank you.

I haven’t yet dealt with the dynamics of having characters that obey the player and that move freely on their own, but toward the end of the game, I want the player’s family to follow him through that barbed wire door. Will I need to do some sort of “instead” code for each person in the game? This seems risky, somehow.

Emerald, I’ve never used one of those extensions before. Perhaps I should check that one out!

Also: there will be a time when the player cuts the barbed wire (after getting clippers or something from the other side of it) so there will be more than one way to handle the “instead” when the barbed wire is in the location (when it’s intact you must wear protection to climb over it, when it’s cut you can walk through). However I guess I can do that with an “if barbedWireIsCut is 0” sort of variable in the same instead code.

I just remembered the flaw when making barbed wire not a door. I want it seen when you’re east of it and when you’re west of it, like a door. If it’s in one location, it’s not in the adjoining one.

I’ve come up with some hacks, maybe, but sometimes hacks are trouble…

[code]Instead of going east when the player is deep in the forest and the barbed wire is not in the location:
say “The forest is deep and inpenetrable to the east”.

[barbed wire is placed in the location after underbrush is cleared, as per discussion above]

Instead of going east when the player is deep in the forest and the barbed wire is in the location:
If the barbed wire is clipped begin;
move player to army base [which is east];
move barbed wire to army base;
Otherwise;
If the player is wearing the bark cloth begin; [haven’t tested this nested-if syntax yet – just learned it is possible]
say “Wrapped in the bark cloth for protection,
you are able to climb over the barbed wire with some difficulty.”;
move player to army base;
move barbed wire to army base;
Otherwise;
say “The barbed wire is in the way.”;
end if.
End if.

Instead of going West when the player is in army base and the barbed wire is in the location:
If the barbed wire is clipped begin;
move player to the deep in the forest;
move barbed wire to deep in the forest;
Otherwise;
If the player is wearing the bark cloth begin;
say “Wrapped in the bark cloth for protection,
you are able to climb over the barbed wire with some difficulty.”;
move player to deep in the forest;
move barbed wire to deep in the forest;
Otherwise;
say “The barbed wire is in the way.”;
end if.
End if.
[/code]

A test showed me that if sis is asked to go east when persuasion succeeds, the above doesn’t cover her. So she needs to also be programmed specifically to go through the barbed wire if it’s clipped, to not go through it if it’s not (there’s only one bark cloth and I’m not going to allow the player to dress sis specifically – hopefully dressing a NPC isn’t existing functionality?), and, I guess, I will NOT move the barbed wire to the next room with sis, since what’s important is that the player see it. Unless there’s a more generic way to say that the above applies to everyone who tries to move east and west.

Then I’ll have to repeat for Mom and Granny, for whom persuasion succeeds under the right circumstances, and I guess, not for NPCs for whom persuasion does not succeed.

I’m not giving any of these people free will (if something like that’s even possible), nor am I moving them around randomly or via any means but persuasion. But once I start hacking to this degree I start wondering if it’s going to come back to bite me in the butt later. Maybe there’s something I’m not thinking of?

Should I hack this far, or consider the more advanced moving-the-door-out-of-scope activity, or pursue the hidden door extension? I know it’s largely a matter of opinion, but I’d like to do what will be least likely to cause unexpected bugs.

thanks!

UPDATE: Tests reveal that I need only a set of code for the player, and a set of code for everyone else (not separate for Sis, Granny, and Mom):

[code]Instead of going east when isBarbedWireCut is 0:
say “The barbed wire is in the way, YOU”.

Instead of anyone going east when isBarbedWireCut is 0:
say “The barbed wire is in the way, OTHERPERSON”. [/code]

What I would do is make the barbed wire a backdrop, and then write some instead rules for going back and forth from the Forest to the Army Base depending on the circumstances.

[code]Forest is a room. The Army Base is east of the Forest.

The underbrush is in the Forest. “The underbrush is very thick, especially to the east.”

Instead of going east from the Forest when the barbed wire is not on-stage, say “The underbrush is too thick in that direction.”

Instead of cutting the underbrush:
remove the underbrush from play;
move the barbed wire backdrop to all fenced rooms;
say “You clear the underbrush away, revealing a barbed wire fence.”

Definition: a room is fenced if it is the Forest or it is the Army Base. [This definition is just for moving the barbed wire. Because of the weird way backdrops work. You can’t just say “move the barbed wire to the Forest and the Army Base”.]

The barbed wire is a backdrop. Understand “fence” as the barbed wire. The barbed wire can be clipped or intact.

The barbed wire is not scenery. [We want to mention the barbed wire when it is present. We could tailor each individual room description, but it’s easier to just make the backdrop nonscenery so that the game mentions it automatically whenever it is present, and then then write rules for that.]

Rule for writing a paragraph about the intact barbed wire:
say “A barbed wire fence blocks your way to the [if the location is the Forest]east.[otherwise]west.”

Rule for writing a paragraph about the clipped barbed wire:
say “A hole has been cut in the barbed wire fence to the [if the location is the Forest]east.[otherwise]west.”

Instead of cutting the barbed wire:
say “You clip the barbed wire, creating a hole in the fence that you can walk through easily.”;
now the barbed wire is clipped.

Instead of going east from the Forest when the barbed wire is intact, say “You’ll have to climb over the fence.”
Instead of going west from the Army Base when the barbed wire is intact, say “You’ll have to climb over the fence.”

Instead of climbing the intact barbed wire when the player is wearing the bark cloth:
say “With the bark cloth for protection, you are able to climb over the barbed wire without difficulty.”;
if the player is in the Forest, move the player to the Army Base;
otherwise move the player to the Forest.

Instead of climbing the intact barbed wire:
say “The razor-sharp barbs would badly slash your unprotected hands.”

[Since “climbing the intact barbed wire when the player is wearing the bark cloth” is a more specific condition than “climbing the intact barbed wire”, Inform will automatically check that rule first and follow it if the condition is true. So the player will only be denied if he is not wearing the bark cloth.]

Instead of climbing the clipped barbed wire:
say “There is no need to climb the fence; the barbed wire have been clipped.”

[And here are some props for testing:]

Some clippers are in the Forest. Instead of cutting something when the player does not have the clippers, say “You have nothing to cut with!”

A bark cloth is in the Forest. It is wearable.

Test me with “e / look at barbed wire / cut underbrush / get clippers / cut underbrush / e / climb fence / wear bark cloth / climb fence / cut barbed wire / climb fence / w”.[/code]

Michael, that sounds good. I will try that out.

If I want to use a description of the room that includes the barbed wire when it is there and does not when it is not (which I know how to do), then can I skip the code that says that the barbed wire is not scenery? I’m trying to migrate all my descriptions to a more organic prosey sort of thing instead of allowing stuff to be listed, when it is reasonable to do so.

Another question; when I tried this:

Instead of anyone going east when the person is deep in the Jungle and the barbed wire is in the location: If the barbed wire is clipped begin; move the person to army base; Otherwise; say "The barbed wire is in the way."; end if.

Inform didn’t like “move the person”. Is there a way to write this?

If not, I can always repeat the code for each person who is persuadable.

Thanks!

(PS: I realize that latter snippet of code will need to be rewritten for this new way of doing the barbed wire fence.)

“person” is a kind and you need to refer to a specific character, “the actor”.

Instead of anyone going east when the actor is deep in the Jungle and the barbed wire is in the location of the actor: If the barbed wire is clipped begin; move the actor to army base; Otherwise; say "The barbed wire is in the way."; end if.
(note that I added “location of the actor”, because “location” alone means “location of the player”.)

Awesome Nitku, thank you!

Instead of anyone going east when the actor is deep in the Jungle and the barbed wire is in the location of the actor: If the barbed wire is clipped begin; move the actor to army base; Otherwise; say "The barbed wire is in the way."; end if.

Can I use this to cover the player too? Rather than having two sets of code?

Going off to test that now, but I don’t want to break more stuff than I have to…

Sure, that would work. Backdrops are scenery by default. So take out the statement that says the barbed wire is not scenery, then take out the two rules for writing a paragraph about the barbed wire. Then tailor your room descriptions as you please.

Yes, this rule would catch the player going as well.

However: you don’t need that “move player to army base” line. A more efficient way to write the rule would be to stop the action and print a message if the fence is intact, but simply let the action proceed as normal if the barbed wire is clipped. Like so:

[code]The barbed wire can be clipped or intact.

Instead of an actor going east from the Jungle when the barbed wire is in the location of the actor:
if the barbed wire is intact, say “The barbed wire is in the way.”;
otherwise continue the action.[/code]
If the barbed wire is clipped, the going action proceeds as normal (i.e., the actor moves to the next room). This is a good thing because Inform will automatically print appropriate messages if the player is there to witness someone going (i.e., “Joe leaves to the east.”). That doesn’t happen if you’re moving them “by hand”.

And finally, here’s an even slicker way to write the rule:

Instead of an actor going east from the Jungle when the intact barbed wire is in the location of the actor: say "The barbed wire is in the way."
If you move “intact” to the description of the barbed wire in the rule itself, you can dispense with the if-then statement. The rule will only fire if the barbed wire is present and intact. If either of those conditions do not apply, then the rule does not fire, and the going action proceeds normally.

Yeah, actually that’s an artifact of a way I was trying to do this before I saw your better method.

However I hadn’t actually taken notice of “stop the action” and “continue the action” yet. Those are valuable to know about.