Add API documentation

This commit is contained in:
AFCMS 2021-03-27 23:07:46 +01:00
parent 6a6b5970b3
commit 3ba7a40251
3 changed files with 17 additions and 16 deletions

View file

@ -5,17 +5,17 @@ Add an API to register buckets to mcl
Register a new liquid Register a new liquid
Accept folowing params: Accept folowing params:
* source_place = a string or function. * source_place: a string or function.
* string: name of the node to place * string: name of the node to place
* function(pos): will returns name of the node to place with pos being the placement position * function(pos): will returns name of the node to place with pos being the placement position
* source_take = table of liquid source node names to take * source_take: table of liquid source node names to take
* itemname = itemstring of the new bucket item (or nil if liquid is not takeable) * itemname: itemstring of the new bucket item (or nil if liquid is not takeable)
* inventory_image = texture of the new bucket item (ignored if itemname == nil) * inventory_image: texture of the new bucket item (ignored if itemname == nil)
* name = user-visible bucket description * name: user-visible bucket description
* longdesc = long explanatory description (for help) * longdesc: long explanatory description (for help)
* usagehelp = short usage explanation (for help) * usagehelp: short usage explanation (for help)
* tt_help = very short tooltip help * tt_help: very short tooltip help
* extra_check(pos, placer) = optional function(pos) which can returns false to avoid placing the liquid. Placer is object/player who is placing the liquid, can be nil. * extra_check(pos, placer): (optional) function(pos) which can returns false to avoid placing the liquid. Placer is object/player who is placing the liquid, can be nil.
* groups = optional list of item groups * groups: optional list of item groups
This function can be called from any mod (which depends on this one) This function can be called from any mod (which depends on this one)

View file

@ -2,11 +2,13 @@
Drop registered inventories on player death. Drop registered inventories on player death.
## mcl_death_drop.register_dropped_list(inv, listname, drop) ## mcl_death_drop.register_dropped_list(inv, listname, drop)
* inv: string of function returning a string * inv: can be:
* "PLAYER": player inventory (to avoid multiple calling to get_inventory())
* function: must return inventory
* listname: string * listname: string
* drop: bool * drop: bool
-- if true the entire list will be dropped * true: the entire list will be dropped
-- if false, items with curse_of_vanishing enchantement will be broken. * false: items with curse_of_vanishing enchantement will be broken.
## mcl_death_drop.registered_dropped_lists ## mcl_death_drop.registered_dropped_lists
Table containing dropped list definition. Table containing dropped list inventory, name and drop state.

View file

@ -11,7 +11,7 @@ end
mcl_death_drop.register_dropped_list("PLAYER", "main", true) mcl_death_drop.register_dropped_list("PLAYER", "main", true)
mcl_death_drop.register_dropped_list("PLAYER", "craft", true) mcl_death_drop.register_dropped_list("PLAYER", "craft", true)
mcl_death_drop.register_dropped_list("PLAYER", "armor", true) mcl_death_drop.register_dropped_list("PLAYER", "armor", true)
mcl_death_drop.register_dropped_list(function(player) return minetest.get_inventory({type="detached", name=player:get_player_name().."_armor"}) end , "armor", false) mcl_death_drop.register_dropped_list(function(player) return select(3, armor:get_valid_player(player)) end , "armor", false)
minetest.register_on_dieplayer(function(player) minetest.register_on_dieplayer(function(player)
local keep = minetest.settings:get_bool("mcl_keepInventory", false) local keep = minetest.settings:get_bool("mcl_keepInventory", false)
@ -19,7 +19,6 @@ minetest.register_on_dieplayer(function(player)
-- Drop inventory, crafting grid and armor -- Drop inventory, crafting grid and armor
local playerinv = player:get_inventory() local playerinv = player:get_inventory()
local pos = player:get_pos() local pos = player:get_pos()
local name, player_armor_inv, armor_armor_inv, pos = armor:get_valid_player(player, "[on_dieplayer]")
-- No item drop if in deep void -- No item drop if in deep void
local void, void_deadly = mcl_worlds.is_in_void(pos) local void, void_deadly = mcl_worlds.is_in_void(pos)