Document rp_locks API

This commit is contained in:
Wuzzy 2022-08-02 18:51:25 +02:00
parent 68abff2f23
commit 9b3a0a47b6
3 changed files with 34 additions and 0 deletions

View File

@ -46,6 +46,7 @@ Mods with documented APIs:
* `rp_goodies`: Fill container nodes with random loot
* `rp_hunger`: Get and set hunger
* `rp_itemshow`: Needed when your item needs a custom appearance in the item frame / item showcase
* `rp_locks`: Get info about lockable nodes
* `rp_partialblocks`: Register partial blocks (slabs, stairs)
* `rp_player_effects`: Add player effects (required if you want to modify player physics)
* `rp_util`: Helper functions for Repixture

31
mods/rp_locks/API.md Normal file
View File

@ -0,0 +1,31 @@
# API for `rp_locks`
This mod only has a few info functions for lockable nodes.
## Function reference
### `locks.is_owner(meta, player)`
Given a NodeMetaRef `meta` of a node, and a `player`,
returns `true` if `player` is considered the owner
of that node (in the context of this mod),
and `false` otherwise.
### `locks.has_owner(meta)`
Given a NodeMetaRef `meta` of a node, returns `true`
is this node has an owner. Returns `false` if the node is
owner-less instead.
### `locks.is_locked(meta, player)`
Given a NodeMetaRef `meta` of a node, and a `player`,
returns `true` if this node is considered to be currently
locked from the perspective of `player`, i.e.
if the player is unable to *currently* access this
node. Returns `false` if the node *is* accessible to the
player.
Note: A node being cracked open with the lockpick by `player`
makes the node temporarily “unlocked” for `player`.

View File

@ -4,6 +4,8 @@ By Kaadmy and Wuzzy, for Repixture.
Adds locked stuff, like locked chests.
Developers: See `API.md` for a few Lua functions to interface with.
Media file license: CC BY-SA 4.0
Source code license: LGPLv2.1