How to make Inform 7 refuse to recognize generic nouns?

I have a system in my story where you can play cards as part of an abstract skill test kind of thing, so you’ll be dealt a hand of cards and you can play the nine or the three or the king or whatever. A couple of months ago I posted a thread trying to get it working right, so you can go read that if you’re curious for details. The main thing is, I have recently come across a bit of a bug: The way the system is set out right now, it teaches the player automatically without their having to read any tutorials, which has been pretty cool. There is one problem, though: When locked into a skill test, the player can “redraw, retreat, or play a card,” but this causes some players to enter the command “PLAY CARD,” at which point they’ll play a random card from their hand. Particularly since the first encounter is really generous with sloppy play, it’s possible to get through the whole intro without realizing that playing a specific card is even possible.

Is there any way to make it so that Inform 7 will reject “PLAY CARD” and instead tell the player to specify a particular card, like “PLAY TWO” or “PLAY JACK” or whatever?

I believe you can use a Rule for supplying a missing noun while playing: (or whatever the action name is) to redirect to an instead response.

Check out §18.32. Supplying a missing noun/second noun and see if that helps!

http://inform7.com/book/WI_18_32.html

Other way if that doesn’t work (I guess “card” is probably a noun now that I think about it, probably a kind?) then perhaps use Understand "play card" as a mistake: ("Specify which card you want to PLAY.") Possibly Understand "play a/-- card" as a mistake... (not sure if you can or need to specify an optional article.)

See §17.21. Understanding mistakes
http://inform7.com/book/WI_17_21.html

1 Like

The source of the issue may depend on the specific way that you’re processing the commands. In the most recent version of the code that I have (that is, the one that is just sitting around on my computer from that last thread), “PLAY CARD” disambiguates, the way your probably want it to.

A common thing that happens here is that if Inform thinks that objects are indistinguishable it will automatically choose something for you.

I can’t find any of the best threads to explain that right now, but roughly, if there isn’t anything the player can type that will distinguish two objects, the parser will decide the difference doesn’t matter and arbitrarily pick one of them. However, sometimes it doesn’t realize the player can distinguish things. In particular, if you are understanding things by relations, the parser won’t realize that that could be used to distinguish the objects. In this code:

Lab is a room. Jack is a man in Lab. Queenie is a woman in Lab. 

A card is a kind of thing. Understand "of [something related by reversed containment]" as a card. The description of a card is usually "A card[if a person encloses the item described] held by [random person enclosing the item described][end if]."

Jack carries a card. Queenie carries a card.

if you type “x card” then Inform will automatically pick Jack’s card, even though you can in fact distinguish them by typing “x card of jack” or “x card of queenie”.

Hanon’s suggestions are also worth looking at. I expect your code is pretty long but if these don’t help, you should post it and maybe we can help!

3 Likes

Huh. After double checking, the version of the story currently on my machine doesn’t even have this bug, but the version I’d sent to beta testers did. I didn’t think I’d changed anything to do with the card code in the meantime, just added some new rooms. This isn’t the first time the card code has had issues appear and disappear seemingly at random. I guess it’s just haunted. Anyway, thank you both for your help!

I have no reason to think this is happening, but you should check to make sure that the version you get when you publish the project doesn’t have the bug. I once had a traumatic experience with a bug that only manifested in the release version, not in the testing version that runs in the IDE, so every time when my testers complained about it I ran it in the IDE and said “Gosh, it must have fixed itself.” But it hadn’t!

Though if this bug is the sort of thing that depends on the issue I mentioned, it might actually fix itself.