mirror of
https://repo.or.cz/minetest_hudbars.git
synced 2024-11-28 01:53:46 +01:00
Various fixes and mark as stable
This commit is contained in:
parent
030f30d47e
commit
01e267e99a
@ -1,6 +1,6 @@
|
||||
Minetest mod "Better HUD"
|
||||
=========================
|
||||
version: 0.5 Beta
|
||||
version: 1.0
|
||||
|
||||
License of source code: WTFPL
|
||||
-----------------------------
|
||||
@ -35,8 +35,11 @@ Also it adds hunger to the game and and hunger bar to the HUD.
|
||||
|
||||
You can create a "hud.conf" to costumize the positions of health, hunger and breath bar. Take a look at "hud.conf.example" to get more infos.
|
||||
|
||||
!!NOTICE: Keep in mind if running a server with this mod, that the costum position should be displayed correct on every screen size!!
|
||||
|
||||
|
||||
Hunger:
|
||||
This mod adds hunger to the game. You can disable this by setting "HUD_HUNGER_ENABLE = false" in "hud.conf".
|
||||
This mod adds hunger to the game. You can disable this by setting "HUD_HUNGER_ENABLE = false" in "hud.conf", or "hud_hunger_enable = false" in minetest.conf. In case of conflict hud.conf configuration is dominant.
|
||||
|
||||
Currently supported food:
|
||||
- Apples (default)
|
||||
|
@ -29,5 +29,13 @@
|
||||
0.5 Beta
|
||||
----------
|
||||
- removed the fancy borders of hud inventory bar and moved to new native support
|
||||
- moved crosshair to native support tooo
|
||||
- moved crosshair to native support too
|
||||
|
||||
1.0
|
||||
---
|
||||
- hunger is reset after death
|
||||
- health and hunger bar is shown correct on all screen resolutions now
|
||||
- switched to changed native hotbar image support
|
||||
- fixed revival of player when drown
|
||||
- hunger bar is not shown anymore if hunger is disabled
|
||||
- hunger can be disabled by minetest.conf ("hud_hunger_enable = false")
|
||||
|
34
init.lua
34
init.lua
@ -9,20 +9,25 @@ local inv_hud = {}
|
||||
local SAVE_INTERVAL = 0.5*60--currently useless
|
||||
|
||||
--default settings
|
||||
HUD_ENABLE_HUNGER = minetest.setting_getbool("enable_damage")
|
||||
HUD_ENABLE_HUNGER = minetest.setting_getbool("hud_hunger_enable")
|
||||
if HUD_ENABLE_HUNGER == nil then HUD_ENABLE_HUNGER = minetest.setting_getbool("enable_damage") end
|
||||
HUD_HUNGER_TICK = 300
|
||||
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_AIR_POS = {x=0.5,y=1}
|
||||
HUD_AIR_OFFSET = {x=15,y=-75}
|
||||
HUD_HEALTH_POS = {x=0.5,y=0.9}
|
||||
HUD_HEALTH_OFFSET = {x=-175, y=2}
|
||||
HUD_HUNGER_POS = {x=0.5,y=0.9}
|
||||
HUD_HUNGER_OFFSET = {x=15, y=2}
|
||||
HUD_AIR_POS = {x=0.5,y=0.9}
|
||||
HUD_AIR_OFFSET = {x=15,y=-15}
|
||||
|
||||
--load costum settings
|
||||
local set = io.open(minetest.get_modpath("hud").."/hud.conf", "r")
|
||||
if set then
|
||||
dofile(minetest.get_modpath("hud").."/hud.conf")
|
||||
set:close()
|
||||
else
|
||||
if not HUD_ENABLE_HUNGER then
|
||||
HUD_AIR_OFFSET = {x=15,y=0}
|
||||
end
|
||||
end
|
||||
|
||||
--minetest.after(SAVE_INTERVAL, timer, SAVE_INTERVAL)
|
||||
@ -34,8 +39,13 @@ end
|
||||
|
||||
local function costum_hud(player)
|
||||
|
||||
--fancy hotbar
|
||||
player:hud_set_hotbar_image("hud_hotbar.png")
|
||||
player:hud_set_hotbar_selected_image("hud_hotbar_selected.png")
|
||||
|
||||
if minetest.setting_getbool("enable_damage") then
|
||||
--hunger
|
||||
if HUD_ENABLE_HUNGER then
|
||||
player:hud_add({
|
||||
hud_elem_type = "statbar",
|
||||
position = HUD_HUNGER_POS,
|
||||
@ -55,6 +65,7 @@ local function costum_hud(player)
|
||||
alignment = {x=-1,y=-1},
|
||||
offset = HUD_HUNGER_OFFSET,
|
||||
})
|
||||
end
|
||||
--health
|
||||
player:hud_add({
|
||||
hud_elem_type = "statbar",
|
||||
@ -148,6 +159,13 @@ minetest.register_on_joinplayer(function(player)
|
||||
end)
|
||||
end)
|
||||
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
hud.hunger[player:get_player_name()] = 20
|
||||
minetest.after(0.5, function()
|
||||
hud.save_hunger(player)
|
||||
end)
|
||||
end)
|
||||
|
||||
local timer = 0
|
||||
local timer2 = 0
|
||||
minetest.after(2.5, function()
|
||||
@ -159,7 +177,7 @@ minetest.after(2.5, function()
|
||||
if minetest.setting_getbool("enable_damage") then
|
||||
local h = tonumber(hud.hunger[player:get_player_name()])
|
||||
if HUD_ENABLE_HUNGER and timer > 4 then
|
||||
if h>=16 then
|
||||
if h>=16 and player:get_hp() > 0 then
|
||||
player:set_hp(player:get_hp()+1)
|
||||
elseif h<=1 and minetest.setting_getbool("enable_damage") then
|
||||
if player:get_hp()-1 >= 1 then player:set_hp(player:get_hp()-1) end
|
||||
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 8.9 KiB |
Loading…
Reference in New Issue
Block a user