mirror of
https://repo.or.cz/minetest_hudbars.git
synced 2024-08-20 05:04:12 +02:00
Add fancy HUD inventory bar
This commit is contained in:
parent
b17dc91da1
commit
98b1e097b7
@ -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.
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
36
init.lua
36
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
|
||||
|
BIN
textures/hud_inv_bar.png
Normal file
BIN
textures/hud_inv_bar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 163 B After Width: | Height: | Size: 1.7 KiB |
Loading…
Reference in New Issue
Block a user