From 98b1e097b7da747e1f4ec8e2ff04706329722229 Mon Sep 17 00:00:00 2001 From: BlockMen Date: Sat, 20 Jul 2013 14:02:30 +0200 Subject: [PATCH] Add fancy HUD inventory bar --- README.txt | 7 ++++--- changelog.txt | 13 +++++++++++++ hud.conf.example | 2 ++ init.lua | 36 ++++++++++++++++++++++++++++++++++++ textures/hud_inv_bar.png | Bin 0 -> 8568 bytes textures/hud_inv_border.png | Bin 163 -> 1691 bytes 6 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 textures/hud_inv_bar.png diff --git a/README.txt b/README.txt index 6d16a8d..39efab0 100644 --- a/README.txt +++ b/README.txt @@ -1,6 +1,6 @@ Minetest mod "Better HUD" ========================= -version: 0.2.3 Beta +version: 0.3 Beta License of source code: WTFPL ----------------------------- @@ -31,7 +31,7 @@ http://sam.zoy.org/wtfpl/COPYING for more details. Using the mod: -------------- -This mod changes the HUD of Minetest. It adds a costum crosshair, a improved health bar. +This mod changes the HUD of Minetest. It adds a costum crosshair, a improved health bar and a more fancy inventory bar. Also it adds hunger to the game and and hunger bar to the HUD. Furthermore it disables the current way of drowning (credits go to PilzAdam) and it will have an LUA-based drowing next versions. @@ -51,5 +51,6 @@ Currently supported food: - Animalmaterials (mobf modpack) - Fishing - Glooptest +- Bushes -One apple fills up the hunger bar by 1 bread, 1 bread (from farming) 2 breads in bar. +Example: 1 apple fills up the hunger bar by 1 bread, 1 bread (from farming) 2 breads in bar. diff --git a/changelog.txt b/changelog.txt index 9adac52..aac6544 100644 --- a/changelog.txt +++ b/changelog.txt @@ -10,3 +10,16 @@ ---------- - tweaked override of food - added support for food of dwares, moretrees and simple mobs + +0.2.2 Beta +---------- +- added support for food of animalmaterials (mobf modpack),fishing + +0.2.3 Beta +---------- +- added support for food of glooptest and bushes (commit by CheeseKeg) + +0.3 Beta +---------- +- added fancy borders of hud inventory bar (only for screenheight <= 1280) + diff --git a/hud.conf.example b/hud.conf.example index bb4a927..fc8d6eb 100644 --- a/hud.conf.example +++ b/hud.conf.example @@ -11,6 +11,8 @@ HUD_HUNGER_TICK = 300 --sets time for loosing 1/2 bread (of 10) (in seconds) HUD_DISABLE_DROWNING = true --needed for costum breath bar postion +HUD_ENABLE_FANCY_INVBAR = true --enables/disables fancy hud inventory border(s) + -- -- crosshair diff --git a/init.lua b/init.lua index 08d8074..00d65e1 100644 --- a/init.lua +++ b/init.lua @@ -5,6 +5,7 @@ hud.hunger = {} local hunger_hud = {} hud.air = {} local air_hud = {} +local inv_hud = {} local SAVE_INTERVAL = 0.5*60--currently useless @@ -17,6 +18,9 @@ HUD_HEALTH_POS = {x=0.5,y=1} HUD_HEALTH_OFFSET = {x=-175,y=-60} HUD_HUNGER_POS = {x=0.5,y=1} HUD_HUNGER_OFFSET = {x=15,y=-60} +HUD_ENABLE_FANCY_INVBAR = true +HUD_INVBAR_POS = {x=0.5,y=1} +HUD_INVBAR_OFFSET = {x=0,y=-16} --load costum settings local set = io.open(minetest.get_modpath("hud").."/hud.conf", "r") @@ -37,6 +41,26 @@ local function costum_hud(player) position = HUD_CROSSHAIR_POS, scale = {x=1, y=1}, }) + +--invbar + if HUD_ENABLE_FANCY_INVBAR then + player:hud_add({ + hud_elem_type = "image", + text = "hud_inv_bar.png", + position = HUD_INVBAR_POS, + scale = {x=1, y=1}, + offset = HUD_INVBAR_OFFSET, + }) + + inv_hud[player:get_player_name()] = player:hud_add({ + hud_elem_type = "image", + text = "hud_inv_border.png", + position = HUD_INVBAR_POS, + scale = {x=1, y=1}, + offset = {x=-127+36*(player:get_wield_index()-1),y=-18}, + }) + end + if minetest.setting_getbool("enable_damage") then --hunger player:hud_add({ @@ -92,6 +116,17 @@ local function update_hud(player) player:hud_change(hunger_hud[player:get_player_name()], "number", h) end +local function update_inv(player) + if inv_hud[player:get_player_name()] ~= nil then player:hud_remove(inv_hud[player:get_player_name()]) end + inv_hud[player:get_player_name()] = player:hud_add({ + hud_elem_type = "image", + text = "hud_inv_border.png", + position = HUD_INVBAR_POS, + scale = {x=1, y=1}, + offset = {x=-127+36*(player:get_wield_index()-1),y=-18}, + }) +end + function hud.save_hunger(player) local file = io.open(minetest.get_worldpath().."/hud_"..player:get_player_name().."_hunger", "w+") @@ -145,6 +180,7 @@ if minetest.setting_getbool("enable_damage") then timer = timer + dtime timer2 = timer2 + dtime for _,player in ipairs(minetest.get_connected_players()) do + if HUD_ENABLE_FANCY_INVBAR then update_inv(player) end local h = tonumber(hud.hunger[player:get_player_name()]) if HUD_ENABLE_HUNGER and timer > 4 then if h>=16 then diff --git a/textures/hud_inv_bar.png b/textures/hud_inv_bar.png new file mode 100644 index 0000000000000000000000000000000000000000..de6607e1ae7509f0c88b340c84c8084add96961f GIT binary patch literal 8568 zcmV-;A&1_HP)Eu z_w8Yzzn`5i?qdH~jhXs5b2HOS&mN#s9i%og%)a3YJ$t)3bz+ROtJBOc);M`=nwgnt z4o}U~^I8{OFTPCIE4%34@jN}fyLq|mCHnUDQR(SsYM{#G@IGq$_pFwXkKy@F>i&f5@K1h9}!j515oPqvdv$VWGy;kLLy~65m zt}{Pcr|-31UU}ttDg(V7UOLFdH?MQ_*dqJ(?W31JrC zpUS>|UVe2Km5CX;`zpNj(oUY+@eD8Qeu?eBdX~zoJsh5`b7+2n!J!eB77kLMondA5 zH1FMB<^9{|S)4t_*yKFphw99noMPp|1%7+uD7SB2=G2*0PMto%;^A5L_6@MNr;q6a zbxs~z;?l)4jMSqRP+-Hg{N>>KD~vOdIM zwZd4v%9UGhv28~e`}$tx{HZg1@a_$6UO!KLw8rSrZpLbR85yon8y%px`&DW~gUlYC zXRKal|M)c3+9<=O&APmFV6Wu7BP4s&MlGy{Wu z^u4-=-tI0cJ6~X6UmtsVyBHj;QmgbcUmIg)yvFq62(@Y-!vniHd923D=@kylE-*GV z&SZU*+39iS4vsT6HOTaV8iPYsMr-?+o|~aMImChb7{?aoIe-2x*5A3IZZ$I6A{p{`Uqr1C{%D`TxrzTijILwh#OY~N14AiRZ9T?#G z=XbDt;tYTLkN@Pq|LcEf@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