From 9831f2c25be98dfa5cf371a14c9c25d671ca703a Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sat, 8 Oct 2022 00:15:38 +0200 Subject: [PATCH] Document `mcl_formspec` API --- mods/HUD/mcl_formspec/API.md | 40 ++++++++++++++++++++++++++++++++++ mods/HUD/mcl_formspec/init.lua | 2 ++ 2 files changed, 42 insertions(+) diff --git a/mods/HUD/mcl_formspec/API.md b/mods/HUD/mcl_formspec/API.md index e69de29bb..64795f8c3 100644 --- a/mods/HUD/mcl_formspec/API.md +++ b/mods/HUD/mcl_formspec/API.md @@ -0,0 +1,40 @@ +# MineClone2 Formspec API + +## `mcl_formspec.label_color` + +Contains the color used for formspec labels, currently `#313131`. + +## `mcl_formspec.get_itemslot_bg(x, y, w, h)` + +Get the background of inventory slots (formspec version = 1) + +ex: + +```lua +local formspec = table.concat({ + mcl_formspec.get_itemslot_bg(0, 0, 5, 2), + "list[current_player;super_inventory;0,0;5,2;]", +}) +``` + +## `mcl_formspec.get_itemslot_bg_v4(x, y, w, h, size, texture)` + +Get the background of inventory slots (formspec version > 1) + +Works basically the same as `mcl_formspec.get_itemslot_bg(x, y, w, h)` but have more customisation options: + +- `size`: allow you to customize the size of the slot borders, default is 0.05 +- `texture`: allow you to specify a custom texture tu use instead of the default one + +ex: + +```lua +local formspec = table.concat({ + mcl_formspec.get_itemslot_bg_v4(0.375, 0.375, 5, 2, 0.1, "super_slot_background.png"), + "list[current_player;super_inventory;0.375,0.375;5,2;]", +}) +``` + +## `mcl_formspec.itemslot_border_size` + +Contains the default item slot border size used by `mcl_formspec.get_itemslot_bg_v4`, currently 0.05 diff --git a/mods/HUD/mcl_formspec/init.lua b/mods/HUD/mcl_formspec/init.lua index 69ef23e08..d449e937f 100644 --- a/mods/HUD/mcl_formspec/init.lua +++ b/mods/HUD/mcl_formspec/init.lua @@ -2,6 +2,7 @@ mcl_formspec = {} mcl_formspec.label_color = "#313131" +---Get the background of inventory slots (formspec version = 1) ---@param x number ---@param y number ---@param w number @@ -32,6 +33,7 @@ end mcl_formspec.itemslot_border_size = 0.05 +---Get the background of inventory slots (formspec version > 1) ---@param x number ---@param y number ---@param w integer