Here’s some Inform 7 code from my current project (it’s borrowed from some almost identical code I used for Weird City Interloper):
A thing can be known or unknown. A thing is usually unknown.
Understand "[any visible known thing]" as investigating.
To say investigation failure:
say "You don't know about any such thing."
Rule for printing a parser error when the latest parser error is the not a verb I recognise error:
say investigation failure.
Rule for printing a parser error when the latest parser error is the noun did not make sense in that context error:
say investigation failure.
Rule for printing a parser error when the latest parser error is the didn't understand error or the latest parser error is the can't use multiple objects error:
say investigation failure.
Rule for printing a parser error when the latest parser error is the only understood as far as error:
say investigation failure.
Carry out investigating a thing (called the target):
say "[the description of the target][line break]".
That little Understand "[any visible known thing] as"
is doing a lot of heavy lifting here, it makes the game throw an error if you try referring to any object in this context that isn’t “known”. I just have to write an appropriately broad response to all those errors. And, crucially, the game doesn’t suggest any “unknown” objects when disambiguating.
Now, I’ve tried to implement something similar in Dialog… First of all I added some prevent
rules to stop my investigate verb from working unless ($obj is known)
. Easy! But I still need to stop the game from mentioning unknown things when disambiguating. The standard library includes the is hidden
property which almost does that…
But flagging every single object in my game as hidden until I reveal it seems like a big ask. I mean, I could use an exhaust statement, but I’d sooner do something smarter. I’ve tried inverting “is hidden” into “is known” (stdlib-known.dg (153.4 KB)), but it didn’t seem to work… Objects are suggested for disambiguation whether (* is known)
or not.
And the other issue is that if every disambiguation match is for a hidden object, then Dialog suggests them all, when I want it to not suggest any of them…
TLDR: how can I completely hide an object from disambiguation? Ideally, how can I completely hide it from anything until I want to reveal it?
(On a small scale, I’d do this by moving objects in from out of play, but I want almost all objects in my game to be in this state until revealed, while keeping them correctly nested…)
Example game for stdlib.dg
(current player #player)
(#player is #in #room)
(room #room)
#RedFish
(name *) red fish
(* is hidden)
(* is #in #room)
#GreenFish
(name *) green fish
(* is hidden)
(* is #in #room)
#BlueFish
(name *) blue fish
(* is hidden)
(* is #in #room)
> X FISH
Did you want to examine the red fish, the blue fish, or the green fish?
No! Don’t suggest any fish! They’re all hidden!
Example game for stdlib-known.dg
(current player #player)
(#player is #in #room)
(room #room)
#RedFish
(name *) red fish
(* is known)
(* is #in #room)
#GreenFish
(name *) green fish
(* is #in #room)
#BlueFish
(name *) blue fish
(* is #in #room)
> X FISH
Did you want to examine the red fish, the blue fish, or the green fish?
No! Assume I meant the red fish! It’s the only one that’s known!