Inventory objects visibility in darkness

The apple in the inventory is visible in the dark while the pear is not. There is surely a logic to all this, but it’s a bit annoying.
The behavior is the same for the standard library. The difference between the two is the use of before(Examine) for the apple.

Darkness                                                           
It is pitch dark here!                                             
                                                                   
> i                                                                
You're carrying a box (which contains a pear and a apple).         
                                                                   
> x apple                                                          
An apple.                                                          
                                                                   
> x pear                                                           
But it's dark.
Object Library "The Library"
	with description "You are in a library.",
   has ~light;

Object -> Box "box"
	with name 'box',
	has container open;

Object ->-> pear "pear"
	with
		name 'pear',
        description "A pear.",
	has edible;

Object ->-> apple "apple"
	with
		name 'apple',
        before [;
           Examine: "An apple.";
        ],
	has edible;

This seems logical as I intercept the action and have to manage it.

2 Likes

I know the solution, but this type of error is difficult to detect and prevent. There are many of these in libraries.
I will award you the solution, but please correct your example. The test of darkness should be for Examine only:

Object ->-> apple "apple"
   with
      name 'apple',
      before [;
         Examine:
            if (location == TheDark) rfalse;
            "An apple.";
      ],
   has edible;

Edit:
Thanks to @r_f for his ephemeral solution.

1 Like

I misinterpreted your post as a request for help, but now I know you know the solution, I’ll just delete what I posted and leave it at that.

1 Like

The pear and the apple are both in scope, since they are in the player’s inventory. This is why the parser doen’t complain that you can’t see any such thing when refering to either object.

Examining something usually means looking at it, and that won’t work in darkness. That’s why the library defaults to this reply when it’s dark. Of course it may be possible to examine something using other senses, in which case you need to capture the action in before.

1 Like

It often happens that I am not very clear, but your answer was satisfactory. To whom shall I attribute the solution? There may be a Nobody here.

1 Like

I often use before(Examine) instead of description to be able to use the before(default), but I will be wary now.

2 Likes