Am i missing something about darkness?

if the player is in the dark, why are objects takeable and examinable? this makes no sense. or am i missing something?

in the example code there is an apple in the dark room that you shouldn’t be able to do anything with.

(intro)
            "Test" 
			(try [look])

#player
(current player *)
(* is #in #test_room)

#test_room
(name *)     It's a room
(room *)
(descr *)    It's an empty room.
(inherently dark *)


#apple
(name *)    apple
(item *)
(descr *)   it's a red apple
(* is #in #test_room)

This behavior is by design, few actions require visibility (look, exits, read). If you want to refuse a specific action in darkness you can use (player can see) rule (usually in negated form).

You can put all objects (except the ones the player is carrying or wearing and #darkness) out of scope if the player can’t see:

~((object $Obj) is in scope)
	~(player can see)
	(current player $Player)
	~($Obj has ancestor $Player)
	~($Obj = #darkness)

But in that case warn your players about dropping that unlit flashlight or lantern, otherwise your game might end up in an unwinnable state.

Edit: Actually, forget about the codeblock above, don’t use it. It can cause unforeseen problems down the line. Refuse specific actions with (player can see) rule instead, that is much more robust.

yeah, i’ve been ‘prevent’ ing specific actions if the player can’t see but that’s kludgy as well since there are all kinds of edge cases.

seems like a lot of work and work arounds for something the library should handle. if it’s behavior by design then it’s bad design. i can’t imagine how allowing the player by default to examine objects in the dark, even objects they’re not holding is good design.

The idea is that a person in the dark should be able to GET LAMP or FLIP SWITCH; otherwise, dropping your lamp in the dark makes the game unwinnable. So unlike Inform, Dialog draws a distinction between “visibility” (requires light) and “scope” (does not).

1 Like

The other way also has edge cases and complaints as well like “why can’t I examine things in the dark by feel?”

If you really want to take some chances, you can use the above code in this fashion:

(*(object $Obj) is in scope)
	~(player can see)
	(current player $Player)
	{
		($Obj has ancestor $Player)
	(or)
		($Obj = $Player)
	(or)
		(current room $Room)
		($Obj = $Room)
	(or)
		($Obj = #darkness)
	}	

~(*(object $Obj) is in scope)
	~(player can see)

I can’t guarantee that it won’t bite you later though.

The rationale is in the release announcement:

4 Likes

yes, i appreciate the kinder gentler darkness. but the player should not be able to ‘examine’ an object across the room in the dark - that seems objectively like a bug.

I imagine the idea is that, if you can reach it (in order to take it), you can reach it (in order to feel it).

But if you want to change that, you can add a (player can see) test to the preconditions for examining.