I would like to propose the event PlayerAction.
This event would be triggered if a player presses the "action" (i.e. "F", or KEY_F) key. The handler would receive :
- the player (lua.wrapper.LuaPlayer), and
- the chest (lua.wrapper.LuaChest), or the door (???), etc.
being activated.
If an object (ex: a chest) is being activated, it would prevent the user from even opening it, thus making it locked.
This event should also be triggered even if no object is being activated. This would enable scripts to handle the action key when the player is in an area, for example.
For example
if (event.objectTypeID == OBJ_TYPE_CHEST and checkPlayerChestAccessRights(event.player, event.object) == false) or
I am aware of the PlayerObjectStatusChange event, however this even if too limited and would not trigger when the action key is pressed. As a fallback, the PlayerAction could get fired if the action key is pressed, but PlayerObjectStatusChange does not apply. Moreoever, if cancelled, this event would even prevent PlayerObjectStatusChange from being fired.