Keyrings and wallets

Hey there! So I decided to try and write my own IF work. I have past experience in a variety of programming languages, and I’m finding Inform 7 interesting and fun.

However, I cannot figure out how to accomplish two simple tasks.

1.) Since I’m making a modern-day story, you start out in your bedroom, and you need to get your keys and your wallet. This one isn’t that big of a deal, but I’d like to have a “keyring” item that contains multiple keys (“house key,” “car keys,” etc.). However, I don’t want the player to have to do “open keyring ; take house key from keyring ; use house key on front door ; put house key in keyring ; close keyring,” as that’s just silly. Is there any easy way around this (ideally the player would type “use house key on front door” and it would automagically work), or should I just resort to having one “keyring” item (“use keyring on door”)?

2.) Similarly, they player is going to have a wallet which will contain various cards. This part I can get working easily; just make the wallet a container and put a driver’s license, ID card, credit card, etc. inside of it. Then I tried putting the keyring inside of the wallet, and it worked. How can I make the wallet only take certain types of things? I tried a bunch of different ways and none of them seemed to work.

Thanks for the help in advance!

Instead of putting something other than the ID card or the credit card in the wallet: Say "That's not something that will fit easily into the wallet."

I’ll let others handle the other question.

For what it’s worth, the Locksmith extension (included with the Inform download) includes a default keyring implementation. You might have to tweak it a little if you have special plans for it (I don’t think it recognizes “use key…”), but it does let the player automatically try keys on doors when appropriate.

This doesn’t seem to work for me:

I tried “placing” and “inserting” and such, and I tried removing the “-ing” and then the error changes to “it needs an -ing.” :frowning:

The action is actually called “inserting it into” (you can verify this by looking at the verb list in the index tab). For some extra flexibility I suggest that you make “card” a kind and make a more general rule:

[code]A card is a kind of thing. An ID card is a card. A driver’s license is a card. [and so on]

Instead of inserting something other than a card into the wallet:
say “[The noun] doesn’t fit inside the wallet.”[/code]

This still isn’t quite working for me. Here’s what I have so far:[code]The dresser is in the Bedroom.

A card is a kind of thing. An ID card is a card. A driver’s license is a card.

The wallet is a closed opaque openable container on the dresser. “Your wallet sits on top of your dresser.”

In the wallet are a driver’s license and an ID card.

Instead of inserting something other than a card into the wallet:
say “[The noun] doesn’t fit inside the wallet.”[/code]

I’m getting the same error I posted above, only with “inserting something other than a card into the wallet” being the troublesome statement. I am using the latest version (to my knowledge…?) of Inform 7, am I missing something?

Aha! Got it to work. I had to use Instead of inserting something that is not a card into the wallet: and everything works fine. Thanks again for the help, guys! Weird, though, that it didn’t understand the other syntax.

Inform 7 is pretty much packed with weird little syntax gotchas like this. My theory (unconfirmed, I hasten to add) is that during the initial development phase, Graham was improvising rather than working at being rigorously systematic.

Or rather, I suspect he gave a high priority to implementing, in each case, a phrase that seemed clear to him – or something that the compiler could be induced to understand without ambiguity. Phrases that are obviously equivalent to a human reader are quite generally not understood by the compiler.

In addition, there are internal inconsistencies, my favorite being “remove X from play”. You can’t say “now X is nowhere” or “now X is off-stage”, although you can test “if X is nowhere” or “if X is off-stage”, and “play” is not a word that has a meaning in any other context.

The way most of us learn this stuff is by writing games, making mistakes, and posting messages here or in the newsgroup.

Have fun!

–JA

I think that having all of the variant syntaxes covered in a programming language like I7 is quite impossible.
Altho much appreciated, fore-thinking about every possibile combination in a sentence must be a hell of a work.

I fail in those even when producing verbs or responses for easy predictions. I.e.: in a short game I’m writing, I implemented an instead rule in case the player wanted to brake while driving a motorbike. I used a trick: the parser looks for a verb (“slow/down/and ten more”) and when it catches it, says: “But speed is all you want, now.”. Ofc, typing “breathe slowly” will result in the same outcome, which sounds strange. But nontheless…

Too bad, among the verbs, I forgot to put “brake”. Because that’s how you slow down when driving: by braking.
Still, I forgot. Sounds idiot, uh? Well, it is not. :slight_smile:

On the subject, “inserting it into” is a pain in the arse. I spent so much time, on my first attempts (before finding out the “actions” tab in I7) in guessing the exact verb for when i put a coin into a purse. While the rest of the actions are quite easy, this one was not.
Putting in? Putting into? No. Dropping in? No, altho it seems to mean something to the interpreter.
I dont exactly insert a coin into a purse

That said, I never found a programming language so friendly as I7. Kudos to GN and whoever is working on the project.

The wallet is a closed opaque openable container on the dresser. "Your wallet sits on top of your dresser."

I fear that after removing the wallet from the dresser, which I assume can be done, the description of the wallet will still say it’s on the dresser. You can mitigate that by putting an if statement inside the description.

It helps if at least one example of each sort of syntax is in the manual. When I can find it there I can usually muddle through. Unfortunately there’s always something that isn’t in there, that I have to find out here instead.