Compare commits
No commits in common. "e3db263828cb96f06d848e6dc80d90f21c7f92a0" and "0edeb5599eaacddf6ab8ac163bcf685aefebbb6c" have entirely different histories.
e3db263828
...
0edeb5599e
132
README.md
132
README.md
@ -1,6 +1,6 @@
|
||||
# minetest HUD bars
|
||||
|
||||
HUD mod to display as bars and API for healt, armor, breath, hunger
|
||||
HUD mod to display as bars and API for
|
||||
|
||||
## Information
|
||||
--------------
|
||||
@ -13,125 +13,33 @@ this mod will place them accordingly.
|
||||
|
||||
![](screenshot.png)
|
||||
|
||||
### Features
|
||||
|
||||
* This mod adds a mechanic for hunger, using "satiation" concept
|
||||
* This mod adds information bar for armor status
|
||||
* Eating an apple (from Minetest Game) increases your satiation by 2
|
||||
|
||||
> Warning: Eating food will not directly increase your health anymore, as long as the food
|
||||
item is supported by this mod (see below).
|
||||
|
||||
> Warning: ! Some foods may be poisoned. If you eat a poisoned item, you may still get a satiation
|
||||
boost, but for a brief period you lose health points because of food poisoning. However,
|
||||
food poisoning can never kill you.
|
||||
|
||||
## Technical info
|
||||
## TEchnical info
|
||||
-----------------
|
||||
|
||||
This mod its a simplification of hudbars+hbarmor+hbhunger for performance
|
||||
it provides extra checks for security an backguard compatibility
|
||||
on all minetest engines. TExture media was optimized for low end devices.
|
||||
|
||||
This fusioned hudbars 2.3.4.0 and hbarmor 1.0.1 with hbhunger 1.1.2
|
||||
with aditional patches rejected by upstream that improves performance.
|
||||
|
||||
#### About armor support
|
||||
|
||||
This mod adds a simple HUD bar which displays the current damage
|
||||
of the player's armor (from the 3D Armor [`3d_armor`] mod) as a percentage (rounded).
|
||||
|
||||
100% armor means the armor is in perfect shape. 0% means the armor is almost destroyed
|
||||
or non-existant. Note that to reach 100%, the player must wear at least 4 or 6 different
|
||||
pieces of armor in perfect shape.
|
||||
|
||||
#### About hunger supoort
|
||||
|
||||
This mod adds a hunger buildin mechanic to the game. Players get a new attribute called “satiation”:
|
||||
|
||||
* A new player starts with 20 satiation points out of 30
|
||||
* Actions like digging, placing and walking cause exhaustion, which lower the satiation
|
||||
* Every 800 seconds you lose 1 satiation point without doing anything
|
||||
* At 1 or 0 satiation you will suffer damage and die in case you don't eat something
|
||||
* If your satiation is 16 or higher, you will slowly regenerate health points
|
||||
* Eating food will increase your satiation (Duh!)
|
||||
|
||||
All mods which add food through standard measures (`minetest.item_eat`) are already
|
||||
supported automatically. Poisoned food needs special support.
|
||||
|
||||
#### Dependencies
|
||||
|
||||
* default
|
||||
* 3d_armor
|
||||
* farming
|
||||
|
||||
More mod are optionally supported depending of availability
|
||||
|
||||
#### Known supported food mods
|
||||
|
||||
* Apple and Blueberries from Minetest Game [`default`]
|
||||
* Red and brown mushroom from Minetest Game [`flowers`]
|
||||
* Bread from Minetest Game [`farming`]
|
||||
* [`animalmaterials`] (Mob Framework (`mobf` modpack))
|
||||
* Bushes [`bushes`]
|
||||
* [`bushes_classic`]
|
||||
* Creatures [`creatures`]
|
||||
* [`dwarves`] (beer and such)
|
||||
* Docfarming [`docfarming`]
|
||||
* Ethereal / Ethereal NG [`ethereal`]
|
||||
* Farming Redo [`farming`] by TenPlus1
|
||||
* Farming plus [`farming_plus`]
|
||||
* Ferns [`ferns`]
|
||||
* Fishing [`fishing`]
|
||||
* [`fruit`]
|
||||
* Glooptest [`glooptest`]
|
||||
* JKMod ([`jkanimals`], [`jkfarming`], [`jkwine`])
|
||||
* [`kpgmobs`]
|
||||
* [`mobfcooking`]
|
||||
* [`mooretrees`]
|
||||
* [`mtfoods`]
|
||||
* [`mushroom`]
|
||||
* [`mush45`]
|
||||
* Seaplants [`sea`]
|
||||
* Simple mobs [`mobs`]
|
||||
* Pizza [`pizza`]
|
||||
* Not So Simple Mobs [`nssm`]
|
||||
|
||||
#### Statbar mode
|
||||
|
||||
If you use the statbar mode of the HUD Bars mod, these things are important to know:
|
||||
As with all mods using HUD Bars, the bread statbar symbols represent the rough percentage
|
||||
out of 30 satiation points, in steps of 5%, so the symbols give you an estimate of your
|
||||
satiation. This is different from the hunger mod by BlockMen.
|
||||
|
||||
> **Warning** Keep in mind if running a server with this mod,
|
||||
that the custom position should be displayed correctly on every screen size.
|
||||
|
||||
#### Dependencies
|
||||
|
||||
There's no depends
|
||||
|
||||
#### Current version
|
||||
|
||||
The current version is 2.3.5 its a plus fork from original cos current
|
||||
The current version is 2.3.4.0 its a plus fork from original cos current
|
||||
minetest most close mods developers are not so open to support already working servers.
|
||||
|
||||
It works for Minetest 0.4.16+/5.X+ or later.
|
||||
It works for Minetest 0.4.17+ (maybe 0.4.16 too) or later.
|
||||
|
||||
#### Configurations
|
||||
#### Settings
|
||||
|
||||
This mod can be configured quite a bit. You can change HUD bar appearance, offsets, ordering, and more.
|
||||
Use the advanced settings menu in Minetest for detailed configuration.
|
||||
|
||||
| configuration name | Description | type | values, default/min/max |
|
||||
| configuration name | Description | type | values, min/default/max |
|
||||
| ---------------------------- | ------------------------------------- | ---- | ------------------------ |
|
||||
| hudbars_hp_player_maximun | set the maximun hp of the player healt | int | 10 20 60 |
|
||||
| hudbars_br_player_maximun | set the maximun player breath value | int | 10 10 30 |
|
||||
| hbarmor_autohide | Automatically hide armor HUD bar | bool | false |
|
||||
| hbhunger_satiation_tick | Time in seconds which 1 saturation point is taken | float | 800 |
|
||||
| hbhunger_satiation_sprint_dig | exhaustion increased this value after digged node | float | 3 |
|
||||
| hbhunger_satiation_sprint_place | exhaustion increased this value after placed | float | 1 |
|
||||
| hbhunger_satiation_sprint_move | exhaustion increased this value if player moves | float | 0.2 |
|
||||
| hbhunger_satiation_sprint_lvl | at what exhaustion player satiation gets lowerd | float | 160 |
|
||||
| hudbars_bar_type | HUD bars style | enum | progress_bar (progress_bar,statbar_classic,statbar_modern) |
|
||||
| hudbars_bar_type | HUD bars style | enum | progress_bar progress_bar,statbar_classic,statbar_modern |
|
||||
| hudbars_autohide_breath | Automatically hide breath indicators | bool | true |
|
||||
| hudbars_alignment_pattern | HUD bars alignment pattern | enum | zigzag (zigzag,stack_up,stack_down) |
|
||||
| hudbars_alignment_pattern | HUD bars alignment pattern | enum | zigzag zigzag,stack_up,stack_down |
|
||||
| hudbars_sorting | HUD bars order | string | breath=1, health=0 |
|
||||
| hudbars_pos_left_x | Left HUD bar screen x position | float | 0.5 0.0 1.0 |
|
||||
| hudbars_pos_left_y | Left HUD bar screen y position | float | 1.0 0.0 1.0 |
|
||||
@ -146,7 +54,7 @@ Use the advanced settings menu in Minetest for detailed configuration.
|
||||
| hudbars_start_statbar_offset_right_x | Right HUD statbar x offset | int | 25 |
|
||||
| hudbars_start_statbar_offset_right_y | Right HUD statbar y offset | int | -90 |
|
||||
| hudbars_vmargin | Vertical distance between HUD bars | int | 24 0 |
|
||||
| hudbars_tick | Default HUD bars update interval | float | 0.2 0.0 4.0 |
|
||||
| hudbars_tick | Default HUD bars update interval | float | 0.1 0.0 4.0 |
|
||||
|
||||
#### API
|
||||
|
||||
@ -157,12 +65,9 @@ Documentation for the API of this mod can be found in [`API.md`.](API.md)
|
||||
|
||||
#### License of source code
|
||||
|
||||
Authors:
|
||||
Author: Wuzzy (2015)
|
||||
|
||||
* Wuzzy (2015)
|
||||
* PICCORO Lenz McKAY (2023)
|
||||
|
||||
This mod was forked from the “Better HUD” (and hunger) [hud] mod by BlockMen.
|
||||
Also: This mod was forked from the “Better HUD” [hud] mod by BlockMen.
|
||||
|
||||
Translations:
|
||||
|
||||
@ -182,15 +87,12 @@ and/or modify it under the terms of the MIT License.
|
||||
#### Licenses of textures
|
||||
|
||||
* `hudbars_icon_health.png`—celeron55 (CC BY-SA 3.0), modified by BlockMen
|
||||
* `hudbars_bgicon_health.png`—celeron55 (CC BY-SA 3.0), modified by BlockMen
|
||||
* `hudbars_icon_breath.png`—kaeza (MIT License), modified by BlockMen, modified again by Wuzzy
|
||||
* `hudbars_bgicon_breath.png`—based on previous image, edited by Wuzzy (MIT License)
|
||||
* `hudbars_bar_health.png`—Wuzzy (MIT License)
|
||||
* `hudbars_bar_breath.png`—Wuzzy (MIT License)
|
||||
* `hudbars_bar_background.png`—Wuzzy (MIT License)
|
||||
* `hbarmor_icon.png`—Stu ([CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/)), modified by BlockMen
|
||||
* `hbarmor_bar.png`—Wuzzy (MIT License)
|
||||
* `hbhunger_icon.png`—PilzAdam ([MIT License](https://opensource.org/licenses/MIT)), modified by BlockMen
|
||||
* `hbhunger_bar.png`—Wuzzy (MIT License)
|
||||
* `hbhunger_icon_health_poison.png`—celeron55 ([CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/)), modified by BlockMen, modified again by Wuzzy
|
||||
|
||||
#### License references
|
||||
|
||||
|
@ -25,14 +25,14 @@ else
|
||||
hb.settings.start_offset_right.y = hb.load_setting("hudbars_start_statbar_offset_right_y", "number", -90)
|
||||
end
|
||||
hb.settings.vmargin = hb.load_setting("hudbars_vmargin", "number", 24)
|
||||
hb.settings.tick = hb.load_setting("hudbars_tick", "number", 0.3)
|
||||
hb.settings.tick = hb.load_setting("hudbars_tick", "number", 0.1)
|
||||
|
||||
-- Experimental setting: Changing this setting is not officially supported, do NOT rely on it!
|
||||
hb.settings.forceload_default_hudbars = hb.load_setting("hudbars_forceload_default_hudbars", "bool", true)
|
||||
|
||||
-- Misc. settings
|
||||
hb.settings.alignment_pattern = hb.load_setting("hudbars_alignment_pattern", "string", "zigzag", {"zigzag", "stack_up", "stack_down"})
|
||||
hb.settings.autohide_breath = hb.load_setting("hudbars_autohide_breath", "bool", (true and not hb.settings.forceload_default_hudbars))
|
||||
hb.settings.autohide_breath = hb.load_setting("hudbars_autohide_breath", "bool", true)
|
||||
|
||||
local sorting = minetest.settings:get("hudbars_sorting")
|
||||
if sorting ~= nil then
|
||||
@ -47,33 +47,11 @@ else
|
||||
hb.settings.sorting_reverse = { [0] = "health", [1] = "breath" }
|
||||
end
|
||||
|
||||
hb.settings.hp_player_maximun = hb.load_setting("hudbars_hp_player_maximun", "number", 40)
|
||||
hb.settings.br_player_maximun = hb.load_setting("hudbars_br_player_maximun", "number", 20)
|
||||
hb.settings.hp_player_maximun = hb.load_setting("hudbars_hp_player_maximun", "number", 20)
|
||||
hb.settings.br_player_maximun = hb.load_setting("hudbars_br_player_maximun", "number", 10)
|
||||
|
||||
if minetest.has_feature("object_use_texture_alpha") then
|
||||
core.PLAYER_MAX_HP_DEFAULT = hb.settings.hp_player_maximun
|
||||
else
|
||||
core.PLAYER_MAX_HP = hb.settings.hp_player_maximun
|
||||
end
|
||||
|
||||
hbarmor.autohide = (true and not hb.settings.forceload_default_hudbars)
|
||||
|
||||
hbhunger.HUD_TICK = 0.2
|
||||
|
||||
hbhunger.HUNGER_TICK = 800 -- time in seconds after that 1 hunger point is taken
|
||||
hbhunger.EXHAUST_DIG = 3 -- exhaustion increased this value after digged node
|
||||
hbhunger.EXHAUST_PLACE = 1 -- exhaustion increased this value after placed
|
||||
hbhunger.EXHAUST_MOVE = 0.2 -- exhaustion increased this value if player movement detected
|
||||
hbhunger.EXHAUST_LVL = 160 -- at what exhaustion player satiation gets lowerd
|
||||
hbhunger.SAT_MAX = 30 -- maximum satiation points
|
||||
hbhunger.SAT_INIT = 20 -- initial satiation points
|
||||
hbhunger.SAT_HEAL = 15 -- required satiation points to start healing
|
||||
|
||||
local set
|
||||
|
||||
set = minetest.settings:get_bool("hbarmor_autohide") if set ~= nil then hbarmor.autohide = set end
|
||||
set = minetest.settings:get("hbhunger_satiation_tick") if set ~= nil then hbhunger.HUNGER_TICK = tonumber(set) end
|
||||
set = minetest.settings:get("hbhunger_satiation_dig") if set ~= nil then hbhunger.HUNGER_DIG = tonumber(set) end
|
||||
set = minetest.settings:get("hbhunger_satiation_place") if set ~= nil then hbhunger.HUNGER_PLACE = tonumber(set) end
|
||||
set = minetest.settings:get("hbhunger_satiation_move") if set ~= nil then hbhunger.HUNGER_MOVE = tonumber(set) end
|
||||
set = minetest.settings:get("hbhunger_satiation_lvl") if set ~= nil then hbhunger.HUNGER_LVL = tonumber(set) end
|
||||
|
30
depends.txt
30
depends.txt
@ -1,31 +1 @@
|
||||
default?
|
||||
intllib?
|
||||
3d_armor?
|
||||
flowers?
|
||||
animalmaterials?
|
||||
bucket?
|
||||
bushes?
|
||||
bushes_classic?
|
||||
cooking?
|
||||
creatures?
|
||||
docfarming?
|
||||
dwarves?
|
||||
ethereal?
|
||||
farming?
|
||||
farming_plus?
|
||||
ferns?
|
||||
fishing?
|
||||
fruit?
|
||||
glooptest?
|
||||
jkanimals?
|
||||
jkfarming?
|
||||
jkwine?
|
||||
kpgmobs?
|
||||
mobfcooking?
|
||||
mobs?moretrees?
|
||||
mtfoods?
|
||||
mush45?
|
||||
mushroom?
|
||||
seaplants?
|
||||
pizza?
|
||||
nssm?
|
||||
|
@ -1 +1 @@
|
||||
HUD mod to display as bars and API for satiaton/stamina and armor status features
|
||||
HUD mod to display as bars and API for
|
296
init.lua
296
init.lua
@ -24,13 +24,7 @@ end
|
||||
|
||||
local N = function(s) return s end
|
||||
|
||||
if (not armor) or (not armor.def) then
|
||||
minetest.log("error", "[hbarmor] Outdated 3d_armor version. Please update your version of 3d_armor!")
|
||||
end
|
||||
|
||||
hb = {}
|
||||
hb.version = "2.3.5.0"
|
||||
hb.redo = true
|
||||
|
||||
hb.hudtables = {}
|
||||
|
||||
@ -40,34 +34,8 @@ hb.hudbars_count = 0
|
||||
-- table which records which HUD bar slots have been “registered” so far; used for automatic positioning
|
||||
hb.registered_slots = {}
|
||||
|
||||
-- Table which contains all players with active default HUD bars (only for internal use)
|
||||
hb.players = {}
|
||||
|
||||
hbarmor = {}
|
||||
hbhunger = {}
|
||||
|
||||
-- HUD item ids
|
||||
local hunger_hud = {}
|
||||
|
||||
-- Stores if player's HUD bar has been initialized so far.
|
||||
hbarmor.player_active = {}
|
||||
|
||||
-- HUD statbar values
|
||||
hbarmor.armor = {}
|
||||
hbhunger.food = {}
|
||||
hbhunger.hunger = {}
|
||||
hbhunger.hunger_out = {}
|
||||
hbhunger.poisonings = {}
|
||||
hbhunger.exhaustion = {} -- Exhaustion is experimental!
|
||||
|
||||
-- If true, the armor bar is hidden when the player does not wear any armor
|
||||
hbarmor.autohide = true
|
||||
|
||||
hb.settings = {}
|
||||
|
||||
hb.hba = minetest.get_modpath("hbarmor")
|
||||
hb.hbh = minetest.get_modpath("hbhunger")
|
||||
|
||||
function hb.load_setting(sname, stype, defaultval, valid_values)
|
||||
local sval
|
||||
if stype == "string" then
|
||||
@ -102,56 +70,13 @@ end
|
||||
-- Load default settings
|
||||
dofile(minetest.get_modpath("hudbars").."/default_settings.lua")
|
||||
|
||||
if not hb.hbh then
|
||||
|
||||
-- due lackof global hbhunger these need to be first
|
||||
hbhunger.get_hunger_raw = function(player)
|
||||
local inv = player:get_inventory()
|
||||
if not inv then return nil end
|
||||
local hgp = inv:get_stack("hunger", 1):get_count()
|
||||
if hgp == 0 then
|
||||
hgp = 21
|
||||
inv:set_stack("hunger", 1, ItemStack({name=":", count=hgp}))
|
||||
else
|
||||
hgp = hgp
|
||||
end
|
||||
return hgp-1
|
||||
end
|
||||
|
||||
hbhunger.set_hunger_raw = function(player)
|
||||
local inv = player:get_inventory()
|
||||
local name = player:get_player_name()
|
||||
local value = hbhunger.hunger[name]
|
||||
if not inv or not value then return nil end
|
||||
if value > hbhunger.SAT_MAX then value = hbhunger.SAT_MAX end
|
||||
if value < 0 then value = 0 end
|
||||
|
||||
inv:set_stack("hunger", 1, ItemStack({name=":", count=value+1}))
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
-- Load hunger management function for food and mod handling
|
||||
dofile(minetest.get_modpath("hudbars").."/hunger.lua")
|
||||
dofile(minetest.get_modpath("hudbars").."/register_foods.lua")
|
||||
|
||||
end
|
||||
|
||||
local function player_exists(player)
|
||||
return player ~= nil and (type(player) == "userdata")
|
||||
end
|
||||
|
||||
local must_hide = function(playername, arm)
|
||||
return ((not armor.def[playername].count or armor.def[playername].count == 0 or not hb.settings.forceload_default_hudbars) and arm == 0)
|
||||
end
|
||||
|
||||
local arm_printable = function(arm)
|
||||
return math.ceil(math.floor(arm+0.5))
|
||||
return player ~= nil and player:is_player()
|
||||
end
|
||||
|
||||
local function checksupportmax(player)
|
||||
local statusinfo = minetest.get_server_status()
|
||||
if string.find(statusinfo,"0.4.1") and not string.find(statusinfo,"0.4.18") and not string.find(statusinfo,"0.4.17.3") then
|
||||
if string.find(statusinfo,"0.4.1") and not string.find(statusinfo,"0.4.18") and not string.find(statusinfo,"0.4.17.5") then
|
||||
hb.settings.hp_player_maximun = 20
|
||||
hb.settings.br_player_maximun = 10
|
||||
if player_exists(player) then
|
||||
@ -191,6 +116,9 @@ local function make_label(format_string, format_string_config, label, start_valu
|
||||
return ret
|
||||
end
|
||||
|
||||
-- Table which contains all players with active default HUD bars (only for internal use)
|
||||
hb.players = {}
|
||||
|
||||
function hb.value_to_barlength(value, max)
|
||||
if max == 0 then
|
||||
return 0
|
||||
@ -306,7 +234,7 @@ function hb.register_hudbar(identifier, text_color, label, textures, default_sta
|
||||
hud_elem_type = "image",
|
||||
position = pos,
|
||||
scale = bgscale,
|
||||
text = "",
|
||||
text = "hudbars_bar_background.png",
|
||||
alignment = {x=1,y=1},
|
||||
offset = { x = offset.x - 1, y = offset.y - 1 },
|
||||
z_index = 0,
|
||||
@ -528,8 +456,6 @@ function hb.hide_hudbar(player, identifier)
|
||||
local name = player:get_player_name()
|
||||
local hudtable = hb.get_hudtable(identifier)
|
||||
if hudtable == nil then return false end
|
||||
if not hudtable.hudstate[name] then return false end
|
||||
if not hudtable.hudstate[name].hidden then return false end
|
||||
if hudtable.hudstate[name].hidden == true then return true end
|
||||
if hb.settings.bar_type == "progress_bar" then
|
||||
if hudtable.hudids[name].icon ~= nil then
|
||||
@ -549,8 +475,7 @@ function hb.unhide_hudbar(player, identifier)
|
||||
local name = player:get_player_name()
|
||||
local hudtable = hb.get_hudtable(identifier)
|
||||
if hudtable == nil then return false end
|
||||
if not hudtable.hudstate[name] then return false end
|
||||
if not hudtable.hudstate[name].hidden then return false end
|
||||
if hudtable.hudstate[name].hidden == false then return true end
|
||||
local value = hudtable.hudstate[name].value
|
||||
local max = hudtable.hudstate[name].max
|
||||
if hb.settings.bar_type == "progress_bar" then
|
||||
@ -593,20 +518,10 @@ function hb.get_hudbar_identifiers()
|
||||
return ids
|
||||
end
|
||||
|
||||
--register built-in HUD bars and armor HUD bar
|
||||
--register built-in HUD bars
|
||||
if minetest.settings:get_bool("enable_damage") or hb.settings.forceload_default_hudbars then
|
||||
local hicon = "hudbars_icon_health.png"
|
||||
local bicon = "hudbars_icon_breath.png"
|
||||
local aicon = "hbarmor_icon.png"
|
||||
local sicon = "hbhunger_icon.png"
|
||||
hb.register_hudbar("health", 0xFFFFFF, S("Health"), { bar = "hudbars_bar_health.png", icon = hicon, bgicon = nil }, hb.settings.hp_player_maximun, hb.settings.hp_player_maximun, false)
|
||||
hb.register_hudbar("breath", 0xFFFFFF, S("Breath"), { bar = "hudbars_bar_breath.png", icon = bicon, bgicon = nil }, hb.settings.br_player_maximun, hb.settings.br_player_maximun, false)
|
||||
if not hb.hba then
|
||||
hb.register_hudbar("armor", 0xFFFFFF, S("Armor"), { bar = "hbarmor_bar.png", icon = aicon, bgicon = nil }, 0, 100, hbarmor.autohide, N("@1: @2%"), { order = { "label", "value" } } )
|
||||
end
|
||||
if not hb.hbh then
|
||||
hb.register_hudbar("satiation", 0xFFFFFF, S("Satiation"), { bar = "hbhunger_bar.png", icon = sicon, bgicon = nil }, hbhunger.SAT_INIT, hbhunger.SAT_MAX, false, nil, { format_value = "%02.0f", format_max_value = "%02.0f" })
|
||||
end
|
||||
hb.register_hudbar("health", 0xFFFFFF, S("Health"), { bar = "hudbars_bar_health.png", icon = "hudbars_icon_health.png", bgicon = "hudbars_bgicon_health.png" }, hb.settings.hp_player_maximun, hb.settings.hp_player_maximun, false)
|
||||
hb.register_hudbar("breath", 0xFFFFFF, S("Breath"), { bar = "hudbars_bar_breath.png", icon = "hudbars_icon_breath.png", bgicon = "hudbars_bgicon_breath.png" }, hb.settings.br_player_maximun, hb.settings.br_player_maximun, true)
|
||||
end
|
||||
|
||||
local function hide_builtin(player)
|
||||
@ -616,66 +531,27 @@ local function hide_builtin(player)
|
||||
player:hud_set_flags(flags)
|
||||
end
|
||||
|
||||
if not hb.hba then
|
||||
|
||||
function hbarmor.get_armor(player)
|
||||
if not player or not armor.def then
|
||||
return false
|
||||
end
|
||||
local name = player:get_player_name()
|
||||
local def = armor.def[name] or nil
|
||||
if def and def.state and def.count then
|
||||
hbarmor.set_armor(name, def.state, def.count)
|
||||
else
|
||||
minetest.log("error", "[hudbars] Call to hbarmor.get_armor returned with false!")
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function hbarmor.set_armor(player_name, ges_state, items)
|
||||
local max_items = 4
|
||||
if items == 5 then max_items = items end
|
||||
local max = max_items * 65535
|
||||
local lvl = max - ges_state
|
||||
lvl = lvl/max
|
||||
if ges_state == 0 and items == 0 then lvl = 0 end
|
||||
|
||||
hbarmor.armor[player_name] = math.max(0, math.min(lvl* (items * (100 / max_items)), 100))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local function custom_hud(player)
|
||||
local name = player:get_player_name()
|
||||
|
||||
if minetest.settings:get_bool("enable_damage") or hb.settings.forceload_default_hudbars then
|
||||
|
||||
local hide
|
||||
if minetest.settings:get_bool("enable_damage") then
|
||||
hide = false
|
||||
else
|
||||
hide = true
|
||||
end
|
||||
local hp = player:get_hp()
|
||||
local hp_max = hb.settings.hp_player_maximun
|
||||
local hide_hp = not minetest.settings:get_bool("enable_damage") or true
|
||||
if player:get_properties().hp_max then player:set_properties({hp_max = hb.settings.hp_player_maximun}) end
|
||||
hb.init_hudbar(player, "health", math.min(hp, hp_max), hp_max, hide_hp)
|
||||
|
||||
hb.init_hudbar(player, "health", math.min(hp, hp_max), hp_max, hide)
|
||||
local breath = player:get_breath()
|
||||
local breath_max = hb.settings.br_player_maximun
|
||||
local hide_breath
|
||||
-- real honoring to configuration of max hp custom heal and breath
|
||||
if player:get_properties().hp_max then player:set_properties({hp_max = hb.settings.hp_player_maximun}) end
|
||||
if player:get_properties().breath_max then player:set_properties({breath_max = hb.settings.br_player_maximun}) end
|
||||
-- workaround bug https://github.com/minetest/minetest/issues/12350
|
||||
if breath >= breath_max and hb.settings.autohide_breath == true then hide_breath = true else hide_breath = false end
|
||||
hb.init_hudbar(player, "breath", math.min(breath, breath_max), breath_max, hide_breath)
|
||||
|
||||
if not hb.hba then
|
||||
local arm = tonumber(hbarmor.armor[name])
|
||||
if not arm then arm = 0 end
|
||||
local hide_ar = hbarmor.autohide and must_hide(name, arm)
|
||||
hbarmor.get_armor(player)
|
||||
arm = tonumber(hbarmor.armor[name])
|
||||
hb.init_hudbar(player, "armor", arm_printable(arm), 100, hide_ar)
|
||||
end
|
||||
|
||||
if not hb.hbh then
|
||||
hb.init_hudbar(player, "satiation", hbhunger.get_hunger_raw(player), nil, (not hb.settings.forceload_default_hudbars) )
|
||||
end
|
||||
hb.init_hudbar(player, "breath", math.min(breath, breath_max), breath_max, hide_breath or hide)
|
||||
end
|
||||
end
|
||||
|
||||
@ -687,18 +563,16 @@ end
|
||||
|
||||
-- update built-in HUD bars
|
||||
local function update_hud(player)
|
||||
|
||||
local name = player:get_player_name() -- player checks are already made before call this function
|
||||
if not name then return end
|
||||
|
||||
-- loading only if need or force loading
|
||||
if not player_exists(player) then return end
|
||||
if minetest.settings:get_bool("enable_damage") then
|
||||
if hb.settings.forceload_default_hudbars then
|
||||
hb.unhide_hudbar(player, "health")
|
||||
end
|
||||
--air
|
||||
local breath_max = player:get_properties().breath_max or hb.settings.br_player_maximun
|
||||
-- workaround bug https://github.com/minetest/minetest/issues/12350
|
||||
local breath = player:get_breath()
|
||||
|
||||
if breath >= breath_max and hb.settings.autohide_breath == true then
|
||||
hb.hide_hudbar(player, "breath")
|
||||
else
|
||||
@ -707,38 +581,10 @@ local function update_hud(player)
|
||||
end
|
||||
--health
|
||||
update_health(player)
|
||||
-- armor
|
||||
if not hb.hba then
|
||||
local larmor = hbarmor.armor[name]
|
||||
local arm = tonumber(larmor)
|
||||
if not arm then arm = 0; hbarmor.armor[name] = 0 end
|
||||
if hbarmor.autohide then
|
||||
if must_hide(name, arm) then
|
||||
hb.hide_hudbar(player, "armor")
|
||||
else
|
||||
hb.change_hudbar(player, "armor", arm_printable(arm))
|
||||
hb.unhide_hudbar(player, "armor")
|
||||
end
|
||||
else
|
||||
hb.change_hudbar(player, "armor", arm_printable(arm))
|
||||
hb.unhide_hudbar(player, "armor")
|
||||
end
|
||||
end
|
||||
-- hunger
|
||||
if not hb.hbh then
|
||||
local h_out = tonumber(hbhunger.hunger_out[name])
|
||||
local h = tonumber(hbhunger.hunger[name])
|
||||
if h_out ~= h then
|
||||
hbhunger.hunger_out[name] = h
|
||||
hb.change_hudbar(player, "satiation", h)
|
||||
end
|
||||
end
|
||||
elseif hb.settings.forceload_default_hudbars then
|
||||
update_health(player)
|
||||
hb.hide_hudbar(player, "health")
|
||||
hb.hide_hudbar(player, "breath")
|
||||
hb.hide_hudbar(player, "armor")
|
||||
hb.hide_hudbar(player, "satiation")
|
||||
end
|
||||
end
|
||||
|
||||
@ -749,122 +595,34 @@ minetest.register_on_player_hpchange(function(player)
|
||||
end)
|
||||
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
if not player_exists(player) then return end
|
||||
|
||||
local name = player:get_player_name()
|
||||
update_health(player)
|
||||
if not hb.hbh then
|
||||
hbhunger.hunger[name] = hbhunger.SAT_INIT
|
||||
hbhunger.set_hunger_raw(player)
|
||||
hbhunger.exhaustion[name] = 0
|
||||
end
|
||||
hb.hide_hudbar(player, "breath")
|
||||
end)
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
if not player_exists(player) then return end
|
||||
|
||||
local name = player:get_player_name()
|
||||
local inv = player:get_inventory()
|
||||
if not hb.hbh then
|
||||
inv:set_size("hunger",1)
|
||||
hbhunger.hunger[name] = hbhunger.get_hunger_raw(player)
|
||||
hbhunger.hunger_out[name] = hbhunger.hunger[name]
|
||||
hbhunger.exhaustion[name] = 0
|
||||
hbhunger.poisonings[name] = 0
|
||||
end
|
||||
hide_builtin(player)
|
||||
custom_hud(player)
|
||||
hb.players[name] = player
|
||||
if not hb.hba then
|
||||
hbarmor.player_active[name] = true
|
||||
end
|
||||
if not hb.hbh then
|
||||
hbhunger.set_hunger_raw(player)
|
||||
end
|
||||
hb.players[player:get_player_name()] = player
|
||||
end)
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
if not player_exists(player) then return end
|
||||
|
||||
local name = player:get_player_name()
|
||||
hb.players[name] = nil
|
||||
if not hb.hba then
|
||||
hbarmor.player_active[name] = false
|
||||
end
|
||||
hb.players[player:get_player_name()] = nil
|
||||
end)
|
||||
|
||||
local modresult = ""
|
||||
|
||||
if hb.hba then modresult = modresult .. " without build-in hbarmor" end
|
||||
if hb.hbh then modresult = modresult .. " without build-in hbhunger" end
|
||||
|
||||
minetest.log("[MOD] hudbars"..modresult.." loaded" )
|
||||
|
||||
|
||||
local main_timer = 0
|
||||
local timer = 0
|
||||
local timer2 = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
main_timer = main_timer + dtime
|
||||
timer = timer + dtime
|
||||
timer2 = timer2 + dtime
|
||||
-- main timer are for healt and breath, separate satiation cos needs aditional timers
|
||||
if main_timer > hb.settings.tick or timer > 4 then
|
||||
if main_timer > hb.settings.tick then main_timer = 0 end
|
||||
-- only proceed if damage is enabled
|
||||
if minetest.settings:get_bool("enable_damage") or hb.settings.forceload_default_hudbars then
|
||||
-- update hud for healt
|
||||
for _, player in pairs(hb.players) do
|
||||
update_hud(player)
|
||||
end
|
||||
if not hb.hba then
|
||||
-- update all hud elements
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
if player_exists(player) then
|
||||
local name = player:get_player_name()
|
||||
if hbarmor.player_active[name] == true then
|
||||
hbarmor.get_armor(player)
|
||||
update_hud(player)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if not hb.hbh then
|
||||
-- satiaton are internal properties, so update live (not hb) player properties
|
||||
if timer > 4 or timer2 > hbhunger.HUNGER_TICK then
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
if player_exists(player) then
|
||||
local name = player:get_player_name()
|
||||
local h = tonumber(hbhunger.hunger[name])
|
||||
local hp = player:get_hp()
|
||||
if timer > 4 then
|
||||
if h > hbhunger.SAT_HEAL and hp > 0 and player:get_breath() > 0 then
|
||||
player:set_hp(hp+1) -- heal player by 1 hp if not dead and satiation is > hbhunger.SAT_HEAL
|
||||
elseif h <= 1 then
|
||||
if hp-1 >= 0 then player:set_hp(hp-1) end -- or damage player by 1 hp if satiation is < 2
|
||||
end
|
||||
end
|
||||
if timer2 > hbhunger.HUNGER_TICK then
|
||||
if h > 0 then
|
||||
h = h-1 -- lower satiation by 1 point after xx seconds
|
||||
hbhunger.hunger[name] = h
|
||||
hbhunger.set_hunger_raw(player)
|
||||
end
|
||||
end
|
||||
-- still do not update all hud elements cos we have 2 loops
|
||||
local controls = player:get_player_control()
|
||||
if controls.up or controls.down or controls.left or controls.right then
|
||||
hbhunger.handle_node_actions(nil, nil, player) -- Determine if the player is walking
|
||||
end
|
||||
end
|
||||
update_hud(player)
|
||||
end
|
||||
end
|
||||
end
|
||||
if timer > 4 then timer = 0 end
|
||||
if timer2 > hbhunger.HUNGER_TICK then timer2 = 0 end
|
||||
end)
|
||||
|
||||
|
||||
|
@ -2,11 +2,3 @@
|
||||
Health=Leben
|
||||
Breath=Atem
|
||||
@1: @2/@3=@1: @2/@3
|
||||
Armor=Panzerung
|
||||
@1: @2%=@1: @2%
|
||||
Satiation=Sättigung
|
||||
Set satiation of player or yourself=Sättigung von Spieler oder Ihnen selbst setzen
|
||||
Not possible, damage is disabled.=Nicht möglich, Schaden ist deaktiviert.
|
||||
Invalid satiation!=Ungültige Sättigung!
|
||||
Player @1 does not exist.=Spieler @1 existiert nicht.
|
||||
[<player>] <satiation>=[<Spieler>] <Sättigung>
|
||||
|
@ -2,10 +2,3 @@
|
||||
Health=Salud
|
||||
Breath=Aliento
|
||||
@1: @2/@3=@1: @2/@3
|
||||
Armor=Armado
|
||||
@1: @2%=@1:@2%
|
||||
Satiation=Saciado
|
||||
Set satiation of player or yourself=Establece la saciedad en el jugador o en si mismo
|
||||
Not possible, damage is disabled.=No es posible, daño esta desactivado.
|
||||
Invalid satiation!=Satisfaccion invalida!
|
||||
Player @1 does not exist.=El jugador @1 no existe.
|
||||
|
@ -1,7 +1,6 @@
|
||||
# textdomain: hudbars
|
||||
Health=Salute
|
||||
Breath=Ossigeno
|
||||
|
||||
# Default format string for progress bar-style HUD bars, e.g. “Health 5/20”
|
||||
@1: @2/@3=@1: @2/@3
|
||||
Armor=Armatura
|
||||
@1: @2%=@1:@2%
|
||||
Satiation=Sazietà
|
||||
|
@ -2,4 +2,3 @@
|
||||
Health=Kesihatan
|
||||
Breath=Nafas
|
||||
@1: @2/@3=@1: @2/@3
|
||||
Satiation=Kekenyangan
|
||||
|
@ -1,7 +1,6 @@
|
||||
# textdomain: hudbars
|
||||
Health=Saude
|
||||
Breath=Folego
|
||||
|
||||
# Formato de string padrão para progresso bar-style de barras do HUD, por exemplo “Saude 5/20”
|
||||
@1: @2/@3=@1: @2/@3
|
||||
Armor=Armado
|
||||
@1: @2%=@1: @2%
|
||||
Satiation=Saciedade
|
||||
|
@ -1,7 +1,4 @@
|
||||
# textdomain: hudbars
|
||||
Health=Здоровье
|
||||
Health=HP
|
||||
Breath=дыхание
|
||||
@1: @2/@3=@1: @2/@3
|
||||
Armor=Доспехи
|
||||
@1: @2%=@1: @2%
|
||||
Satiation=голод
|
||||
|
@ -1,10 +1,6 @@
|
||||
# textdomain: hudbars
|
||||
Health=
|
||||
Breath=
|
||||
Armor=
|
||||
|
||||
# Default format string for progress bar-style HUD bars, e.g. “Health 05/20”
|
||||
# Default format string for progress bar-style HUD bars, e.g. “Health 5/20”
|
||||
@1: @2/@3=
|
||||
|
||||
# Format string for displaying the armor. E.g. "Armor: 100%"
|
||||
@1: @2%=
|
||||
|
3
mod.conf
3
mod.conf
@ -1,3 +1,2 @@
|
||||
name = hudbars
|
||||
description = HUD mod to display as bars and API for with satiaton/stamina features and armor status
|
||||
optional_depends = 3d_armor, default, flowers, animalmaterials, bucket, bushes, bushes_classic, cooking, creatures, docfarming, dwarves, ethereal, farming, farming_plus, ferns, fishing, fruit, glooptest, jkanimals, jkfarming, jkwine, kpgmobs, mobfcooking, mobs, moretrees, mtfoods, mush45, mushroom, seaplants, pizza, nssm
|
||||
description = HUD mod to display as bars and API for
|
||||
|
BIN
screenshot.png
BIN
screenshot.png
Binary file not shown.
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 9.3 KiB |
@ -19,7 +19,7 @@ hudbars_bar_type (HUD bars style) enum progress_bar progress_bar,statbar_classic
|
||||
|
||||
# If enabled (default), the breath indicators in the HUD will be automatically hidden shortly
|
||||
# after the breath has been filled up. Otherwise, the breath will always be displayed.
|
||||
hudbars_autohide_breath (Automatically hide breath indicators) bool false
|
||||
hudbars_autohide_breath (Automatically hide breath indicators) bool true
|
||||
|
||||
# This setting changes the way the HUD bars are ordered on the display. You can choose
|
||||
# between a zig-zag pattern (default) or a vertically stacked pattern.
|
||||
@ -120,21 +120,8 @@ hudbars_tick (Default HUD bars update interval) float 0.3 0.0 4.0
|
||||
|
||||
[player values defaults]
|
||||
# set a default value for max hp healt of player, if you customized and need on older engines
|
||||
hudbars_hp_player_maximun (maximun value of heal of player) int 40
|
||||
hudbars_hp_player_maximun (maximun value of heal of player) int 20
|
||||
# set a default value for max breath of player, if you customized and need on older engines
|
||||
hudbars_br_player_maximun (maximun value of braeth of player) int 20
|
||||
hudbars_br_player_maximun (maximun value of braeth of player) int 10
|
||||
|
||||
#If true, automatically hides the armor HUD bar when the player wears no
|
||||
#armor. Otherwise, the armor bar shows “0%”.
|
||||
hbarmor_autohide (Automatically hide armor HUD bar) bool false
|
||||
|
||||
hbhunger_satiation_tick (Time in seconds after which 1 saturation point is taken) float 800
|
||||
|
||||
hbhunger_satiation_sprint_dig (exhaustion increased this value after digged node) float 3
|
||||
|
||||
hbhunger_satiation_sprint_place (exhaustion increased this value after placed) float 1
|
||||
|
||||
hbhunger_satiation_sprint_move (exhaustion increased this value if player movement detected) float 0.3
|
||||
|
||||
hbhunger_satiation_sprint_lvl (at what exhaustion player satiation gets lowerd) float 160
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 153 B After Width: | Height: | Size: 207 B |
Binary file not shown.
Before Width: | Height: | Size: 143 B After Width: | Height: | Size: 172 B |
Loading…
x
Reference in New Issue
Block a user