Hey there, two more places where I’m stuck, both involving doors and the opening thereof.
1.) I’d like to have a garage door that opens and closes when you press the garage door button. I can make the button, but I can’t figure out how to make it open the door.
2.) Similarly, I’m trying to make a bunch of “security doors” in this office-complex-type thing. These doors are automated, and have a slot that you can slide your ID card through to open them. After you go through, it should close.
The second one is probably quite a bit more complex than the first, so if I only get an answer for the first one, that’s okay, I can work my way around it. And I’d just like to let you all know that I’m not just typing in cool ideas I have into the forums and trying to get someone else to do all the work for me… I actually spent quite awhile trying to make (and failing) both of these things. I guess I just need more time with Inform =D
Alright I finally solved the problem of remotely opening doors. Here’s my complete solution:[code]The Driveway is north of the Front Yard, and in Outdoors.
The Garage is north of the Kitchen, and in the House.
The garage door is a door. It is east of the Garage and west of the Driveway. “[if open]The garage door is wide open.[otherwise]The garage door is closed.”
The garage button is a device inside the Garage.
Instead of pushing the garage button: if the garage button is switched off, try switching on the garage button; otherwise try switching off the garage button.
Instead of opening or closing the garage door, say “You need a garage door opener to do that.”
After switching on the garage button:
say “The garage door slides open.”;
change the the garage door to open.
After switching off the garage button:
say “The garage door slides shut.”;
change the garage door to closed.[/code]Now to try and tackle the second problem…
Thank you so much! This is pretty much exactly what I need, but with a different implementation. It also provides great insight as to some things I didn’t understand about Inform before (such as semicolons).
I had a go at this. Here’s a kind of door that automatically closes in two turns (and just for fun, I also made it possible to have some cards open more doors than others).
Security level is a kind of value. The security levels are low, medium and high.
A security door is a kind of door. Every security door has a security level. Every security door has a time called the closing time. After examining a security door: say "There is a small slot on the wall next to it."
A slot is a kind of thing. One slot is part of every security door.
A security card is a kind of thing. Every security card has a security level.
Instead of opening a closed security door, say "You will have to use the slot next to [the noun]."
Instead of closing an open security door, say "There's no way to close [the noun] manually."
Instead of unlocking a security door with a security card:
let slit be a random slot which is part of the noun;
try inserting the second noun into the slit.
Instead of inserting something into a slot:
unless the noun is a security card, say "[The noun] is too thick to fit in the slot." instead;
let relevant door be the holder of the second noun;
if the security level of the noun is less than the security level of the relevant door, say "You slide [the noun] through [the second noun], which blinks red in response. The door stays closed." instead;
say "[The second noun] blinks green as you slide [the noun] through it";
now the closing time of the relevant door is two minutes after the time of day;
if the relevant door is closed:
now the relevant door is open;
say ", and the door immediately opens.";
repeat with relevant door running through open security doors:
if the closing time of the relevant door is the time of day:
now the relevant door is closed;
if the player can see the relevant door, say "[The relevant door] slides shut again."
[To help the parser a bit:]
Understand "insert [security card] in/into [slot]", "put [security card] in/into [slot]" or "slide [security card] through [slot]" as inserting it into.
Understand "open [security door] with [security card]" or "unlock [security door] with [security card]" as unlocking it with.
The Corridor, the Office, the Bathroom and the Lab are rooms. The office door is a security door. It is east of the corridor and west of the office. The lab door is a security door. It is north of the corridor and south of the lab. The bathroom door is a security door. It is west of the corridor and east of the bathroom.
The security level of the lab door is high. The security level of the office door is medium.
The player carries a security card called the ID card. The security level of the card is medium.
Test me with "open office with card / open lab door / open lab with card".