From f696cb1a70797c298f3301bc40c0887532d6e8cd Mon Sep 17 00:00:00 2001 From: TeTpaAka Date: Thu, 16 Jul 2015 21:14:24 +0200 Subject: [PATCH] Replace statbar with scaled image to remove deprecation warning --- README | 2 +- hud.lua | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README b/README index 8a0623c..d9ba3c7 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -quests 1.0 +quests 1.1 quests is a simple quest framework for minetest that lets you define your own quests and handels the representation. diff --git a/hud.lua b/hud.lua index 225c7ae..527186b 100644 --- a/hud.lua +++ b/hud.lua @@ -97,7 +97,9 @@ function quests.update_hud(playername) hud_element.value = quests.active_quests[playername][hud_element.name].value player:hud_change(hud_element.id, "text", get_quest_hud_string(hud_element.name, quests.active_quests[playername][hud_element.name])) if (hud_element.id_bar ~= nil) then - player:hud_change(hud_element.id_bar, "number", math.floor(40 * hud_element.value / quests.registered_quests[hud_element.name].max)) + player:hud_change(hud_element.id_bar, "scale", + { x = math.floor(20 * hud_element.value / quests.registered_quests[hud_element.name].max), + y = 1}) end end if (i ~= j) then @@ -155,13 +157,12 @@ function quests.update_hud(playername) position = { x = hud_config.position.x, y = hud_config.position.y }, offset = { x = hud_config.offset.x, y = hud_config.offset.y + counter * 40 + 22 }, text = "quests_questbar_background.png" }) - id_bar = player:hud_add({hud_elem_type = "statbar", - scale = { x = 1, y = 1 }, --- size = { x = 2, y = 4 }, + id_bar = player:hud_add({hud_elem_type = "image", + scale = { x = math.floor(20 * questspecs.value / quests.registered_quests[questname].max), + y = 1 }, alignment = { x = 1, y = 1 }, position = { x = hud_config.position.x, y = hud_config.position.y }, offset = { x = hud_config.offset.x + 2, y = hud_config.offset.y + counter * 40 + 24 }, - number = math.floor(40 * questspecs.value / quests.registered_quests[questname].max), text = "quests_questbar.png" }) end