mirror of
git://repo.or.cz/minetest_hbhunger.git
synced 2024-12-24 00:40:20 +01:00
Enable builtin drowning
This commit is contained in:
parent
98b1e097b7
commit
bc44390984
16
README.txt
16
README.txt
@ -1,12 +1,9 @@
|
||||
Minetest mod "Better HUD"
|
||||
=========================
|
||||
version: 0.3 Beta
|
||||
version: 0.4 Beta
|
||||
|
||||
License of source code: WTFPL
|
||||
-----------------------------
|
||||
- "Disable Drowning" [no_drowning], PilzAdam
|
||||
|
||||
everything else:
|
||||
(c) Copyright BlockMen (2013)
|
||||
|
||||
|
||||
@ -14,9 +11,10 @@ License of textures:
|
||||
--------------------
|
||||
hud_heart_fg.png - celeron55 (CC BY-SA 3.0), modified by BlockMen
|
||||
hud_heart_bg.png - celeron55 (CC BY-SA 3.0), modified by BlockMen
|
||||
hud_hunger_fg.png - PilzAdam(WTFPL), modified by BlockMen
|
||||
hud_hunger_bg.png - PilzAdam(WTFPL), modified by BlockMen
|
||||
hud_hunger_fg.png - PilzAdam (WTFPL), modified by BlockMen
|
||||
hud_hunger_bg.png - PilzAdam (WTFPL), modified by BlockMen
|
||||
wieldhand.png (from character.png) - Jordach (CC BY-SA 3.0), modified by BlockMen
|
||||
hud_air_fg.png - kaeza (WTFPL), modified by BlockMen
|
||||
|
||||
everything else is WTFPL:
|
||||
(c) Copyright BlockMen (2013)
|
||||
@ -31,13 +29,11 @@ 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 and a more fancy inventory bar.
|
||||
This mod changes the HUD of Minetest. It adds a costum crosshair, a improved health bar, breath 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.
|
||||
|
||||
|
||||
You can create a "hud.conf" to costumize the positions of health and hunger bar. Take a look at "hud.conf.example" to get more infos.
|
||||
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.
|
||||
|
||||
Hunger:
|
||||
This mod adds hunger to the game. You can disable this by setting "HUD_HUNGER_ENABLE = false" in "hud.conf".
|
||||
|
@ -23,3 +23,7 @@
|
||||
----------
|
||||
- added fancy borders of hud inventory bar (only for screenheight <= 1280)
|
||||
|
||||
0.4 Beta
|
||||
----------
|
||||
- enabled drowning
|
||||
|
||||
|
@ -9,8 +9,6 @@
|
||||
HUD_ENABLE_HUNGER = true --enables/disables hunger
|
||||
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)
|
||||
|
||||
|
||||
@ -21,7 +19,7 @@ HUD_CROSSHAIR_POS = {x=0.5, y=0.5} --recommended to be 0.5,0.5 (centered)
|
||||
|
||||
|
||||
--!NOTICE!--
|
||||
-- >>if damage is disabled neither health bar nor hunger bar is shown
|
||||
-- >>if damage is disabled neither health bar nor hunger bar or breath bar is shown
|
||||
|
||||
--
|
||||
-- health bar
|
||||
@ -38,3 +36,6 @@ HUD_HUNGER_OFFSET = {x=-175,y=30} --offset in pixel
|
||||
--
|
||||
-- breath bar
|
||||
--
|
||||
HUD_AIR_POS = {x=0.5,y=1} --min 0, max 1
|
||||
HUD_AIR_OFFSET = {x=15,y=-75} --offset in pixel
|
||||
|
||||
|
38
init.lua
38
init.lua
@ -3,14 +3,12 @@ hud = {}
|
||||
local health_hud = {}
|
||||
hud.hunger = {}
|
||||
local hunger_hud = {}
|
||||
hud.air = {}
|
||||
local air_hud = {}
|
||||
local inv_hud = {}
|
||||
|
||||
local SAVE_INTERVAL = 0.5*60--currently useless
|
||||
|
||||
--default settings
|
||||
HUD_DISABLE_DROWNING = true
|
||||
HUD_ENABLE_HUNGER = minetest.setting_getbool("enable_damage")
|
||||
HUD_HUNGER_TICK = 300
|
||||
HUD_CROSSHAIR_POS = {x=0.5, y=0.5}
|
||||
@ -18,18 +16,23 @@ 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_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")
|
||||
if set then dofile(minetest.get_modpath("hud").."/hud.conf") end
|
||||
if set then
|
||||
dofile(minetest.get_modpath("hud").."/hud.conf")
|
||||
set:close()
|
||||
end
|
||||
|
||||
--minetest.after(SAVE_INTERVAL, timer, SAVE_INTERVAL)
|
||||
|
||||
local function hide_builtin(player)
|
||||
player:hud_set_flags({crosshair = false, hotbar = true, healthbar = false, wielditem = true, breathbar = HUD_DISABLE_DROWNING})
|
||||
player:hud_set_flags({crosshair = false, hotbar = true, healthbar = false, wielditem = true, breathbar = false})
|
||||
end
|
||||
|
||||
|
||||
@ -102,6 +105,17 @@ local function costum_hud(player)
|
||||
alignment = {x=-1,y=-1},
|
||||
offset = HUD_HEALTH_OFFSET,
|
||||
})
|
||||
|
||||
--air
|
||||
air_hud[player:get_player_name()] = player:hud_add({
|
||||
hud_elem_type = "statbar",
|
||||
position = HUD_AIR_POS,
|
||||
scale = {x=1, y=1},
|
||||
text = "hud_air_fg.png",
|
||||
number = 20,
|
||||
alignment = {x=-1,y=-1},
|
||||
offset = HUD_AIR_OFFSET,
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
@ -116,7 +130,13 @@ local function update_hud(player)
|
||||
player:hud_change(hunger_hud[player:get_player_name()], "number", h)
|
||||
end
|
||||
|
||||
local function update_inv(player)
|
||||
local function update_fast(player)
|
||||
--air
|
||||
local air = player:get_breath()*2
|
||||
if player:get_breath() >= 11 then air = 0 end
|
||||
player:hud_change(air_hud[player:get_player_name()], "number", air)
|
||||
--hotbar
|
||||
if HUD_ENABLE_FANCY_INVBAR then
|
||||
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",
|
||||
@ -125,6 +145,7 @@ local function update_inv(player)
|
||||
scale = {x=1, y=1},
|
||||
offset = {x=-127+36*(player:get_wield_index()-1),y=-18},
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -168,19 +189,15 @@ minetest.register_on_joinplayer(function(player)
|
||||
end)
|
||||
end)
|
||||
|
||||
local tick = 0
|
||||
local timer = 0
|
||||
local timer2 = 0
|
||||
minetest.after(2.5, function()
|
||||
if minetest.setting_getbool("enable_damage") then
|
||||
minetest.register_globalstep(function(dtime)
|
||||
tick = tick + dtime
|
||||
--if tick<0.5 then return end
|
||||
--tick = 0
|
||||
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
|
||||
update_fast(player)
|
||||
local h = tonumber(hud.hunger[player:get_player_name()])
|
||||
if HUD_ENABLE_HUNGER and timer > 4 then
|
||||
if h>=16 then
|
||||
@ -205,4 +222,3 @@ end
|
||||
end)
|
||||
|
||||
if HUD_ENABLE_HUNGER then dofile(minetest.get_modpath("hud").."/hunger.lua") end
|
||||
if HUD_DISABLE_DROWNING then dofile(minetest.get_modpath("hud").."/no_drowning.lua") end
|
||||
|
@ -1,15 +0,0 @@
|
||||
local function drwn_overwrite(name)
|
||||
local table = minetest.registered_nodes[name]
|
||||
local table2 = {}
|
||||
for i,v in pairs(table) do
|
||||
table2[i] = v
|
||||
end
|
||||
table2.drowning = false
|
||||
table2.hud_drowning = true
|
||||
minetest.register_node(":"..name, table2)
|
||||
end
|
||||
|
||||
drwn_overwrite("default:water_source")
|
||||
drwn_overwrite("default:water_flowing")
|
||||
drwn_overwrite("default:lava_source")
|
||||
drwn_overwrite("default:lava_flowing")
|
BIN
textures/hud_air_fg.png
Normal file
BIN
textures/hud_air_fg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 579 B |
Loading…
Reference in New Issue
Block a user