I’d like to know what’s the best way to remove an object from scope. My usecase is removing an object from scope when in darkness, but it can apply to other situations.
In this post, the proposed code to prevent sequence-breaking in darkness is:
(prevent [open/search #secretcompartment])
~(player can see)
You can't see well enough to do that in the dark.
But even though opening the compartment will fail, typing “open compartment” will still reveal its presence. (An unrecognised object would produce the response “I only understood you as far as…”). And it’ll still be proposed in disambiguation questions. So I thought about several solutions.
First solution, simply moving the object off-stage. It works quite well for scenery and ($ attracts $)
. Maybe something like that:
(inherently dark #room)
(#room attracts #secretcompartment)
(player can see) %% Only if not in darkness.
Second solution, refuse the action and fake an unrecognised response. But I’m not sur the response will always match the one produced by the parser, and it won’t work with disambiguations questions. Something like:
(refuse $Action)
~(player can see)
(#secretcompartment is one of $Action)
%% We replace the compartment in the action with an empty list.
(collect $Element)
*($Original is one of $Action)
(if)($Original = #secretcompartment)(then)
($Element = [])
(else)
($Element = $Original)
(endif)
(into $ProcessedAction)
%% "open compartment" will produce "I only understood you as far as wanting to open something".
\(I only understood as far as wanting to (describe action $ProcessedAction).\)
Third solution, directly modify the ($ is in scope)
rule to omit certain objects. It may seem obvious, so maybe the standard library should provide something by default? (Maybe with a trait like (out of scope in darkness $)
. Or even just (out of scope $)
with whatever condition in the rule body.) Or is there some performance issue I overlooked?
I’ve got the feeling I’m overthinking it, so any pointers are welcome.