From da5289d977550871900299a86c77f34071759425 Mon Sep 17 00:00:00 2001 From: marco_a <4279489-marco_a@users.noreply.gitlab.com> Date: Mon, 2 Sep 2024 01:02:11 +0200 Subject: [PATCH] Avoid `hud_elem_type` deprecation warnings if MT 5.9+ --- init.lua | 2 +- src/api.lua | 37 +++++++++++++++++++------------------ 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/init.lua b/init.lua index f134f26..568b09f 100644 --- a/init.lua +++ b/init.lua @@ -1,5 +1,5 @@ panel_lib = {} -local version = "3.2.0" +local version = "3.2.1" local srcpath = minetest.get_modpath("panel_lib") .. "/src" dofile(srcpath .. "/api.lua") diff --git a/src/api.lua b/src/api.lua index b91861c..939826c 100644 --- a/src/api.lua +++ b/src/api.lua @@ -1,9 +1,10 @@ -local panels = {} -- KEY: p_name; VALUE: {{"panel name" = panel}, {"panel name 2" = panel2}, ...} - local function clone_table() end local function add_sub_elem() end local function update_sub_elems() end +local panels = {} -- KEY: p_name; VALUE: {{"panel name" = panel}, {"panel name 2" = panel2}, ...} +local hud_type = minetest.features.hud_def_type_field and "type" or "hud_elem_type" + Panel = { name = "", -- player to show the panel to @@ -15,24 +16,24 @@ Panel = { -- because the panel is composed by a background and a text we need to -- define the two HUD to use later background_def = { - hud_elem_type = "image", - position = { x = 0.5, y = 0.5 }, - scale = { x = 1, y = 1 }, - alignment = { x = 0, y = 0 }, - offset = {x = 0, y = 0}, - text = "panel_bg.png", - z_index = 0 + [hud_type] = "image", + position = { x = 0.5, y = 0.5 }, + scale = { x = 1, y = 1 }, + alignment = { x = 0, y = 0 }, + offset = {x = 0, y = 0}, + text = "panel_bg.png", + z_index = 0 }, title_def = { - hud_elem_type = "text", - position = {x = 0.5, y = 0.5}, - alignment = {x = 0, y = 0}, - offset = {x = 0, y = 0}, - size = { x = 1 }, - number = 0xFFFFFF, - text = "", - style = 0, - z_index = 0 + [hud_type] = "text", + position = {x = 0.5, y = 0.5}, + alignment = {x = 0, y = 0}, + offset = {x = 0, y = 0}, + size = { x = 1 }, + number = 0xFFFFFF, + text = "", + style = 0, + z_index = 0 }, sub_img_elems = {}, -- KEY: ID, VALUE: name