I know the basic way to construct the code for what I want but I’m curious to hear how people would implement the following:
There’s a room called the Sinkhole.
There’s a work tent that I’m going to have acting as a door between it and another room. So basically:
Work Site is a room.
Sinkhole is a room.
A work tent is in Work Site.
The door called the tent door is east of Work Site and west of the Sinkhole.
The tent door is closed and openable.
But now I also want to have an electrified fence that “surrounds” the work tent. If you shut off the fence, you can now access the work tent (opening the door) and getting to the Sinkhole.
So how do you model that? Do you just make the electrical fence a “container”? I can put the work tent in there but that would also mean putting the tent door in there as well. So now the connection is really not between the two rooms but from a container in a room to another room.
Again, I can do a basic implementation that works. I’m just not sure if I’m doing an implementation with hidden gotchas.
Inform’s model doesn’t handle doors in containers, or doors between containers and rooms.
The easiest plan is to just have the fence be in the location, and add a rule like
Before doing anything except examining to the tent door when the fence is electrified:
instead say "Zap, you can't."
This prevents opening, touching, etc.
(It does not prevent going through the door if the door is open. That is, the rule above catches ENTER DOOR but not EAST, if the door is open but the fence is electrified. You’d need a second rule to cover that case.)
There are several ways to do this. I made an extension that is in the Public Library within Inform called “Easy Doors” which allows you to make a direction-less door that leads to another location, and they can be placed as inside containers or lead inside them. I found that it works well to describe the door as an entire enclosure, (which can be permanently “open” without a door-flap if desired) so the player can type ENTER TENT or OPEN FENCE, GO THROUGH FENCE (once it’s de-lectrified in your case).
(Code off the top of my head, but should approximate what works)
[code]A canvas tent is an easydoor in Work Site. It leads to tent-interior. The dooraction is “You raise the tent flap and duck inside.”
Understand “unzip [something]” as opening.
After opening canvas tent, say “The zipper is rusty but you manage to open it.”
An electric fence is an easydoor in Sink Hole. “A fence surrounds the work site. You presume it’s electric due to the wires and a menacing sign.” It leads to Work Site. Electric fence can be charged. Electric fence is charged.
a menacing sign is part of electric fence. The description is “The sign reads ‘DANGER - KEEP OUT - HIGH VOLTAGE’. Yep, that’s a potentially dangerous electric fence all right[if electric fence is charged]. It seems to crackle with energy. You ought to see if you can disable it before touching it[end if].”. Understand “wires/cable/wire/cable/electricity” as menacing sign.
Check touching electric fence:
end the story saying “ZZZAPPPP - You’re dead.”
Before opening electric fence:
if electric fence is charged:
say “You can hear the crackle of energy in the air. That might not be a good idea.” instead.[/code]