Bug: Leaving locked/closed actor container

I think I found a bug when leaving locked actor containers in the stdlib. When entering a closed/locked actor container there is a before-rule to check if the object is closed and an attempt to open it if that’s the case, but no such rule for leaving a closed container.

Here is small example code with the fix at the end (copied from the before rule) that imo is missing in stdlib.

(current player #player)
(#player is #in #room)
(room #room)

#container
(name *)		container
(actor container *)
(openable *)
(* is unlocked)
(* is #in #room)

(narrate entering *)
	(now) (* is closed)
	%%(now) (* is locked)
	You hear a loud noise, followed by a click as if something just locked up and you find yourself surrounded by darkness.

(before [leave (actor container $Obj)])
	($Obj is closed)
	(first try [open $Obj])

%% Test with: x container, enter container, look, exit
1 Like

Yes, this looks like a bug. Thank you, will fix!

1 Like

Thanks Linus.

Just noticed that in this case you also have the side effect of revealing all contents of the container, here just “yourself”. Imo it makes more sense to leave the player out of this listing.

>exit
(first attempting to open the container)
You open the container, revealing yourself.
1 Like

Right, that part shouldn’t be shown at all when opening the container from the inside, since the contents aren’t revealed as such. Thanks again!

1 Like

Fixed in library 0.41.