diff --git a/README.md b/README.md index 366af63..7f7a8d7 100644 --- a/README.md +++ b/README.md @@ -62,8 +62,8 @@ To download you can play this game with the following minetest engines: * Wilhelmines Marinara as `marinara` [mods/marinara](mods/marinara) https://git.minetest.io/minenux/minetest-mod-marinara forked compatible version * Wuzzy * Hudbars as `hudbars` [mods/hudbars](mods/hudbars) https://codeberg.org/minenux/minetest-mod-hudbars - * Hudbar Armor as `hbarmor` [mods/hbarmor](mods/hbarmor) https://codeberg.org/Wuzzy/minetest_hbarmor/ - * Hudbar Hunger as `hbhunger` [mods/hbhunger](mods/hbhunger) https://codeberg.org/Wuzzy/minetest_hbhunger/ + * Hudbar Armor as `hudbars` [mods/hudbars](mods/hudbars) https://codeberg.org/minenux/minetest-game-nssg/commit/39c56ecd26ef559f063bf9effa0b1c58cc6bf969 + * Hudbar Hunger as `hudbars` [mods/hbhunger](mods/hbhunger) https://codeberg.org/minenux/minetest-game-nssg/commit/39c56ecd26ef559f063bf9effa0b1c58cc6bf969 ## Licensing diff --git a/mods/hbarmor/README.md b/mods/hbarmor/README.md deleted file mode 100644 index a6af08b..0000000 --- a/mods/hbarmor/README.md +++ /dev/null @@ -1,42 +0,0 @@ -# HUD bar for `3d_armor` [`hbarmor`] - -* Version: 1.0.0 - -## Description -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 different -pieces of armor in perfect shape. - -The armor bar also does not tell anything about the armor's strength, -only how worn out it already is. - -By default, the armor bar is hidden if the player wears no armor. - -## Dependencies -* HUD bars [`hudbars`], major version 2 -* 3D Armor [`3d_armor`] (tested with Minetest 5.0.0) - -## Licensing -This mod is entirly free softare. - -### Source code - -* License: MIT License (see below) -* Authors: Wuzzy, forked from the mod “Better HUD (and hunger)” [`hud`] by BlockMen (2013-2014) - -### Textures - -* `hbarmor_icon.png`—Stu ([CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/)), modified by BlockMen -* `hbarmor_bgicon.png`—Stu (CC BY-SA 3.0), modified by BlockMen -* `hbarmor_bar.png`—Wuzzy (MIT License) - -Everything else is under the MIT License: -© Copyright BlockMen (2013-2014) - -This program is free software. It comes without any warranty, to -the extent permitted by applicable law. You can redistribute it -and/or modify it under the terms of the MIT License. -See for more details. diff --git a/mods/hbarmor/depends.txt b/mods/hbarmor/depends.txt deleted file mode 100644 index 579f7fb..0000000 --- a/mods/hbarmor/depends.txt +++ /dev/null @@ -1,2 +0,0 @@ -hudbars -3d_armor diff --git a/mods/hbarmor/init.lua b/mods/hbarmor/init.lua deleted file mode 100644 index a98ed90..0000000 --- a/mods/hbarmor/init.lua +++ /dev/null @@ -1,174 +0,0 @@ --- Intllib -local S -if minetest.get_translator ~= nil then - S = minetest.get_translator("ethereal") -- 5.x translation function -else - if minetest.get_modpath("intllib") then - dofile(minetest.get_modpath("intllib") .. "/init.lua") - if intllib.make_gettext_pair then - gettext, ngettext = intllib.make_gettext_pair() -- new gettext method - else - gettext = intllib.Getter() -- old text file method - end - S = gettext - else -- boilerplate function - S = function(str, ...) - local args = {...} - return str:gsub("@%d+", function(match) - return args[tonumber(match:sub(2))] - end) - end - end -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 - -local hbarmor = {} - --- HUD statbar values -hbarmor.armor = {} - --- Stores if player's HUD bar has been initialized so far. -hbarmor.player_active = {} - --- Time difference in seconds between updates to the HUD armor bar. --- Increase this number for slow servers. -hbarmor.tick = 0.3 - --- If true, the armor bar is hidden when the player does not wear any armor -hbarmor.autohide = false - ---load custom settings -local set = minetest.settings:get_bool("hbarmor_autohide") -if set ~= nil then - hbarmor.autohide = set -end - -set = minetest.settings:get("hbarmor_tick") -if tonumber(set) ~= nil then - hbarmor.tick = tonumber(set) -end - - -local must_hide = function(playername, arm) - return ((not armor.def[playername].count or armor.def[playername].count == 0) and arm == 0) -end - -local arm_printable = function(arm) - return math.ceil(math.floor(arm+0.5)) -end - -local function custom_hud(player) - local name = player:get_player_name() - - if minetest.settings:get_bool("enable_damage") then - local ret = hbarmor.get_armor(player) - if ret == false then - minetest.log("error", "[hbarmor] Call to hbarmor.get_armor in custom_hud returned with false!") - end - local arm = tonumber(hbarmor.armor[name]) - if not arm then arm = 0 end - local hide - if hbarmor.autohide then - hide = must_hide(name, arm) - else - hide = false - end - hb.init_hudbar(player, "armor", arm_printable(arm), nil, hide) - end -end - ---register and define armor HUD bar -local hicon = "hbarmor_icon.png" -if hb.settings.bar_type == "progress_bar" then hicon = nil end -hb.register_hudbar("armor", 0xFFFFFF, S("Armor"), { icon = hicon, bgicon = nil, bar = "hbarmor_bar.png" }, 0, 100, hbarmor.autohide, N("@1: @2%"), { order = { "label", "value" }, textdomain = "hbarmor" } ) - -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 - 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 - --- update hud elemtens if value has changed -local function update_hud(player) - local name = player:get_player_name() - --armor - local arm = tonumber(hbarmor.armor[name]) - if not arm then - arm = 0 - hbarmor.armor[name] = 0 - end - if hbarmor.autohide then - -- hide armor bar completely when there is none - 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)) - end -end - -minetest.register_on_joinplayer(function(player) - local name = player:get_player_name() - custom_hud(player) - hbarmor.player_active[name] = true -end) - -minetest.register_on_leaveplayer(function(player) - local name = player:get_player_name() - hbarmor.player_active[name] = false -end) - -local main_timer = 0 -local timer = 0 -minetest.register_globalstep(function(dtime) - main_timer = main_timer + dtime - timer = timer + dtime - if main_timer > hbarmor.tick or timer > 4 then - if minetest.settings:get_bool("enable_damage") then - if main_timer > hbarmor.tick then main_timer = 0 end - for _,player in ipairs(minetest.get_connected_players()) do - local name = player:get_player_name() - if hbarmor.player_active[name] == true then - local ret = hbarmor.get_armor(player) - if ret == false then - minetest.log("error", "[hbarmor] Call to hbarmor.get_armor in globalstep returned with false!") - end - -- update all hud elements - update_hud(player) - end - end - end - end - if timer > 4 then timer = 0 end -end) diff --git a/mods/hbarmor/locale/hbarmor.de.tr b/mods/hbarmor/locale/hbarmor.de.tr deleted file mode 100644 index 1649802..0000000 --- a/mods/hbarmor/locale/hbarmor.de.tr +++ /dev/null @@ -1,3 +0,0 @@ -# textdomain:hbarmor -Armor=Panzerung -@1: @2%=@1: @2% diff --git a/mods/hbarmor/locale/hbarmor.es.tr b/mods/hbarmor/locale/hbarmor.es.tr deleted file mode 100644 index 146b017..0000000 --- a/mods/hbarmor/locale/hbarmor.es.tr +++ /dev/null @@ -1,3 +0,0 @@ -# textdomain:hbarmor -Armor=Armadura -@1: @2%=@1:@2% diff --git a/mods/hbarmor/locale/hbarmor.it.tr b/mods/hbarmor/locale/hbarmor.it.tr deleted file mode 100644 index 54601d5..0000000 --- a/mods/hbarmor/locale/hbarmor.it.tr +++ /dev/null @@ -1,3 +0,0 @@ -# textdomain:hbarmor -Armor=Armatura -@1: @2%=@1:@2% diff --git a/mods/hbarmor/locale/template.txt b/mods/hbarmor/locale/template.txt deleted file mode 100644 index 0f22286..0000000 --- a/mods/hbarmor/locale/template.txt +++ /dev/null @@ -1,5 +0,0 @@ -# textdomain:hbarmor -Armor= - -# Format string for displaying the armor. E.g. "Armor: 100%" -@1: @2%= diff --git a/mods/hbarmor/mod.conf b/mods/hbarmor/mod.conf deleted file mode 100644 index 820500e..0000000 --- a/mods/hbarmor/mod.conf +++ /dev/null @@ -1,3 +0,0 @@ -name = hbarmor -description = Adds a HUD bar displaying the current damage of the player's armor. -depends = hudbars, 3d_armor diff --git a/mods/hbarmor/screenshot.png b/mods/hbarmor/screenshot.png deleted file mode 100644 index 907cf90..0000000 Binary files a/mods/hbarmor/screenshot.png and /dev/null differ diff --git a/mods/hbarmor/settingtypes.txt b/mods/hbarmor/settingtypes.txt deleted file mode 100644 index 263a6f4..0000000 --- a/mods/hbarmor/settingtypes.txt +++ /dev/null @@ -1,7 +0,0 @@ -#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 - -#Time difference in seconds between updates to the armor HUD bar. -#Increase this number for slow servers. -hbarmor_tick (Armor HUD bar update frequency) float 0.3 0.0 4.0 diff --git a/mods/hbarmor/textures/hbarmor_icon.png b/mods/hbarmor/textures/hbarmor_icon.png deleted file mode 100644 index f76e9c3..0000000 Binary files a/mods/hbarmor/textures/hbarmor_icon.png and /dev/null differ diff --git a/mods/hbhunger/.mailmap b/mods/hbhunger/.mailmap deleted file mode 100644 index 3d78b58..0000000 --- a/mods/hbhunger/.mailmap +++ /dev/null @@ -1,2 +0,0 @@ -Wuzzy -Wuzzy diff --git a/mods/hbhunger/README.md b/mods/hbhunger/README.md deleted file mode 100644 index c8e3ffc..0000000 --- a/mods/hbhunger/README.md +++ /dev/null @@ -1,96 +0,0 @@ -# Hunger with HUD bar [`hbhunger`] - -* Version: 1.1.2 - -## Using the mod - -This mod adds a mechanic for hunger. -This mod depends on the HUD bars mod [`hudbars`], version 1.4.1 or any later version -starting with “1.” or “2.”. - -## About hunger -This mod adds a hunger 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!) - -Important: Eating food will not directly increase your health anymore, as long as the food -item is supported by this mod (see below). - -Careful! 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. - -## 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. - -You gain health at 5.5 symbols or more, as 5.5 symbols correspond to 16 satiation points. -You *may* lose health at exactly 0.5 symbols, as 0.5 symbols correspond to 1-2 satiation points. - -## Supported food -All mods which add food through standard measures (`minetest.item_eat`) are already -supported automatically. Poisoned food needs special support. - -### 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`] - -### Supported mods without optional dependency (mods provide their own support) - -* Food ([`food`], [`food_basic`]) -* Sweet Foods [`food_sweet`] - -### Example - -* Eating an apple (from Minetest Game) increases your satiation by 2; - -## Licensing -This mod is free software. - -### Source code - -* License: [LGPL v2.1](https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html) -* Author: by Wuzzy (2015-2016) -* Forked from the “Better HUD (and hunger)” mod by BlockMen (2013-2015), - most code comes from this mod. - -### Textures - -* `hbhunger_icon.png`—PilzAdam ([MIT License](https://opensource.org/licenses/MIT)), modified by BlockMen -* `hbhunger_bgicon.png`—PilzAdam (MIT License), 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 -* Everything else: MIT License, by BlockMen and Wuzzy - diff --git a/mods/hbhunger/depends.txt b/mods/hbhunger/depends.txt deleted file mode 100644 index 1cc6acf..0000000 --- a/mods/hbhunger/depends.txt +++ /dev/null @@ -1,30 +0,0 @@ -hudbars -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? diff --git a/mods/hbhunger/init.lua b/mods/hbhunger/init.lua deleted file mode 100644 index f9c1e6b..0000000 --- a/mods/hbhunger/init.lua +++ /dev/null @@ -1,225 +0,0 @@ -local S - -if minetest.get_translator ~= nil then - S = minetest.get_translator("hbhunger") -- 5.x translation function -else - if minetest.get_modpath("intllib") then - dofile(minetest.get_modpath("intllib") .. "/init.lua") - if intllib.make_gettext_pair then - gettext, ngettext = intllib.make_gettext_pair() -- new gettext method - else - gettext = intllib.Getter() -- old text file method - end - S = gettext - else -- boilerplate function - S = function(str, ...) - local args = {...} - return str:gsub("@%d+", function(match) - return args[tonumber(match:sub(2))] - end) - end - end -end - -local N = function(s) return s end - -if minetest.settings:get_bool("enable_damage") then - -hbhunger = {} -hbhunger.food = {} - --- HUD statbar values -hbhunger.hunger = {} -hbhunger.hunger_out = {} - --- Count number of poisonings a player has at once -hbhunger.poisonings = {} - --- HUD item ids -local hunger_hud = {} - -hbhunger.HUD_TICK = 0.1 - ---Some hunger settings -hbhunger.exhaustion = {} -- Exhaustion is experimental! - -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.3 -- 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("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 - ---load custom settings -local set = io.open(minetest.get_modpath("hbhunger").."/hbhunger.conf", "r") -if set then - dofile(minetest.get_modpath("hbhunger").."/hbhunger.conf") - set:close() -end - -local function custom_hud(player) - hb.init_hudbar(player, "satiation", hbhunger.get_hunger_raw(player)) -end - -dofile(minetest.get_modpath("hbhunger").."/hunger.lua") -dofile(minetest.get_modpath("hbhunger").."/register_foods.lua") - --- register satiation hudbar -local sicon = "hbhunger_icon.png" -if hb.settings.bar_type == "progress_bar" then - sicon = nil -end -hb.register_hudbar("satiation", 0xFFFFFF, S("Satiation"), { icon = sicon, bgicon = nil, bar = "hbhunger_bar.png" }, hbhunger.SAT_INIT, hbhunger.SAT_MAX, false, nil, { format_value = "%02d", format_max_value = "%02d" }) - --- update hud elemtens if value has changed -local function update_hud(player) - local name = player:get_player_name() - --hunger - 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 - -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 - -minetest.register_on_joinplayer(function(player) - if minetest.is_player(player) then - local name = player:get_player_name() - local inv = player:get_inventory() - 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 - custom_hud(player) - hbhunger.set_hunger_raw(player) - end -end) - -minetest.register_on_respawnplayer(function(player) - local name = player:get_player_name() - if minetest.is_player(player) and name then - hbhunger.hunger[name] = hbhunger.SAT_INIT - hbhunger.set_hunger_raw(player) - hbhunger.exhaustion[name] = 0 - end -end) - -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 - if main_timer > hbhunger.HUD_TICK or timer > 4 or timer2 > hbhunger.HUNGER_TICK then - if main_timer > hbhunger.HUD_TICK then main_timer = 0 end - for _,player in ipairs(minetest.get_connected_players()) do - local name = player:get_player_name() - - local h = tonumber(hbhunger.hunger[name]) - local hp = player:get_hp() - if timer > 4 then - -- heal player by 1 hp if not dead and satiation is > hbhunger.SAT_HEAL - if h > hbhunger.SAT_HEAL and hp > 0 and player:get_breath() > 0 then - player:set_hp(hp+1) - -- or damage player by 1 hp if satiation is < 2 - elseif h <= 1 then - if hp-1 >= 0 then player:set_hp(hp-1) end - end - end - -- lower satiation by 1 point after xx seconds - if timer2 > hbhunger.HUNGER_TICK then - if h > 0 then - h = h-1 - hbhunger.hunger[name] = h - hbhunger.set_hunger_raw(player) - end - end - - -- update all hud elements - update_hud(player) - - local controls = player:get_player_control() - -- Determine if the player is walking - if controls.up or controls.down or controls.left or controls.right then - hbhunger.handle_node_actions(nil, nil, player) - end - end - end - if timer > 4 then timer = 0 end - if timer2 > hbhunger.HUNGER_TICK then timer2 = 0 end -end) - -minetest.register_chatcommand("satiation", { - privs = {["server"]=true}, - params = S("[] "), - description = S("Set satiation of player or yourself"), - func = function(name, param) - if minetest.settings:get_bool("enable_damage") == false then - return false, S("Not possible, damage is disabled.") - end - local targetname, satiation = string.match(param, "(%S+) (%S+)") - if not targetname then - satiation = param - end - satiation = tonumber(satiation) - if not satiation then - return false, S("Invalid satiation!") - end - if not targetname then - targetname = name - end - local target = minetest.get_player_by_name(targetname) - if target == nil then - return false, S("Player @1 does not exist.", targetname) - end - if satiation > hbhunger.SAT_MAX then - satiation = hbhunger.SAT_MAX - elseif satiation < 0 then - satiation = 0 - end - hbhunger.hunger[targetname] = satiation - hbhunger.set_hunger_raw(target) - return true - end, -}) - -end diff --git a/mods/hbhunger/locale/hbhunger.de.tr b/mods/hbhunger/locale/hbhunger.de.tr deleted file mode 100644 index 988b457..0000000 --- a/mods/hbhunger/locale/hbhunger.de.tr +++ /dev/null @@ -1,7 +0,0 @@ -# textdomain:hbhunger -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. -[] =[] diff --git a/mods/hbhunger/locale/hbhunger.es.tr b/mods/hbhunger/locale/hbhunger.es.tr deleted file mode 100644 index 0ec642c..0000000 --- a/mods/hbhunger/locale/hbhunger.es.tr +++ /dev/null @@ -1,2 +0,0 @@ -# textdomain:hbhunger -Satiation=Saciado diff --git a/mods/hbhunger/locale/hbhunger.it.tr b/mods/hbhunger/locale/hbhunger.it.tr deleted file mode 100644 index b99dc61..0000000 --- a/mods/hbhunger/locale/hbhunger.it.tr +++ /dev/null @@ -1,2 +0,0 @@ -# textdomain:hbhunger -Satiation=Sazietà diff --git a/mods/hbhunger/locale/hbhunger.ms.tr b/mods/hbhunger/locale/hbhunger.ms.tr deleted file mode 100644 index 67f08f7..0000000 --- a/mods/hbhunger/locale/hbhunger.ms.tr +++ /dev/null @@ -1,2 +0,0 @@ -# textdomain:hbhunger -Satiation=Kekenyangan diff --git a/mods/hbhunger/locale/hbhunger.pt.tr b/mods/hbhunger/locale/hbhunger.pt.tr deleted file mode 100644 index 82be594..0000000 --- a/mods/hbhunger/locale/hbhunger.pt.tr +++ /dev/null @@ -1,2 +0,0 @@ -# textdomain:hbhunger -Satiation=Saciedade diff --git a/mods/hbhunger/locale/hbhunger.ru.tr b/mods/hbhunger/locale/hbhunger.ru.tr deleted file mode 100644 index afd6e66..0000000 --- a/mods/hbhunger/locale/hbhunger.ru.tr +++ /dev/null @@ -1,2 +0,0 @@ -# textdomain:hbhunger -Satiation=голод diff --git a/mods/hbhunger/locale/template.txt b/mods/hbhunger/locale/template.txt deleted file mode 100644 index 507e005..0000000 --- a/mods/hbhunger/locale/template.txt +++ /dev/null @@ -1,7 +0,0 @@ -# textdomain:hbhunger -Satiation= -Set satiation of player or yourself= -Not possible, damage is disabled.= -Invalid satiation!= -Player @1 does not exist.= -[] = diff --git a/mods/hbhunger/mod.conf b/mods/hbhunger/mod.conf deleted file mode 100644 index da6c465..0000000 --- a/mods/hbhunger/mod.conf +++ /dev/null @@ -1,4 +0,0 @@ -name = hbhunger -description = Adds a simple hunger meachanic with satiation, food poisoning and different healing. -depends = hudbars -optional_depends = 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 diff --git a/mods/hbhunger/screenshot.png b/mods/hbhunger/screenshot.png deleted file mode 100644 index 5af6583..0000000 Binary files a/mods/hbhunger/screenshot.png and /dev/null differ diff --git a/mods/hbhunger/settingtypes.txt b/mods/hbhunger/settingtypes.txt deleted file mode 100644 index 9a0d830..0000000 --- a/mods/hbhunger/settingtypes.txt +++ /dev/null @@ -1,9 +0,0 @@ -hbhunger_satiation_tick (Time in seconds after which 1 saturation point is taken) float 1600 - -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 diff --git a/mods/hudbars/README.md b/mods/hudbars/README.md index 25d5d72..98b4ad9 100644 --- a/mods/hudbars/README.md +++ b/mods/hudbars/README.md @@ -1,6 +1,6 @@ # minetest HUD bars -HUD mod to display as bars and API for +HUD mod to display as bars and API for healt, armor, breath, hunger ## Information -------------- @@ -13,33 +13,125 @@ this mod will place them accordingly. ![](screenshot.png) -## TEchnical info +### 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 ----------------- +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.4.0 its a plus fork from original cos current +The current version is 2.3.5 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.17+ (maybe 0.4.16 too) or later. +It works for Minetest 0.4.16+/5.X+ or later. -#### Settings +#### Configurations 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, min/default/max | +| configuration name | Description | type | values, default/min/max | | ---------------------------- | ------------------------------------- | ---- | ------------------------ | -| hudbars_bar_type | HUD bars style | enum | progress_bar progress_bar,statbar_classic,statbar_modern | +| 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_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 | @@ -54,7 +146,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.1 0.0 4.0 | +| hudbars_tick | Default HUD bars update interval | float | 0.2 0.0 4.0 | #### API @@ -65,9 +157,12 @@ Documentation for the API of this mod can be found in [`API.md`.](API.md) #### License of source code -Author: Wuzzy (2015) +Authors: -Also: This mod was forked from the “Better HUD” [hud] mod by BlockMen. +* Wuzzy (2015) +* PICCORO Lenz McKAY (2023) + +This mod was forked from the “Better HUD” (and hunger) [hud] mod by BlockMen. Translations: @@ -87,12 +182,15 @@ 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 diff --git a/mods/hudbars/default_settings.lua b/mods/hudbars/default_settings.lua index f720c7e..75ec2e6 100644 --- a/mods/hudbars/default_settings.lua +++ b/mods/hudbars/default_settings.lua @@ -32,7 +32,7 @@ hb.settings.forceload_default_hudbars = hb.load_setting("hudbars_forceload_defau -- 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", false) +hb.settings.autohide_breath = hb.load_setting("hudbars_autohide_breath", "bool", (true and not hb.settings.forceload_default_hudbars)) local sorting = minetest.settings:get("hudbars_sorting") if sorting ~= nil then @@ -55,3 +55,25 @@ 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 diff --git a/mods/hudbars/depends.txt b/mods/hudbars/depends.txt index d9b8b81..afc33be 100644 --- a/mods/hudbars/depends.txt +++ b/mods/hudbars/depends.txt @@ -1 +1,31 @@ -intllib? \ No newline at end of file +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? diff --git a/mods/hudbars/description.txt b/mods/hudbars/description.txt index 726453c..3b178c7 100644 --- a/mods/hudbars/description.txt +++ b/mods/hudbars/description.txt @@ -1 +1 @@ -HUD mod to display as bars and API for \ No newline at end of file +HUD mod to display as bars and API for satiaton/stamina and armor status features diff --git a/mods/hbhunger/hunger.lua b/mods/hudbars/hunger.lua similarity index 98% rename from mods/hbhunger/hunger.lua rename to mods/hudbars/hunger.lua index ed6f229..0387581 100644 --- a/mods/hbhunger/hunger.lua +++ b/mods/hudbars/hunger.lua @@ -106,13 +106,13 @@ function hbhunger.item_eat(hunger_change, replace_with_item, poisen, heal, sound hbhunger.set_hunger_raw(user) end -- we must respect the real maximun hp of the player already set - max_hp = user:get_properties().hp_max + local max_hp = user:get_properties().hp_max -- Healing if hp < max_hp then -- heal is not defines due way of hbhunger.register_food if not heal then heal = 1 end -- eating something not give you inmediate life, give you statiation to get recovery - if hp < 3 and heal > 0 then hp = hp + heal end + if hp < 6 and heal > 0 then hp = hp + heal end -- so do not hardcoded hp to 20 when eating if hp > max_hp then hp = max_hp end -- this will work only when valid then diff --git a/mods/hudbars/init.lua b/mods/hudbars/init.lua index 9fff093..9987ea9 100644 --- a/mods/hudbars/init.lua +++ b/mods/hudbars/init.lua @@ -24,7 +24,13 @@ 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 = {} @@ -34,6 +40,29 @@ 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 = {} function hb.load_setting(sname, stype, defaultval, valid_values) @@ -70,13 +99,52 @@ end -- Load default settings dofile(minetest.get_modpath("hudbars").."/default_settings.lua") +-- 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") + local function player_exists(player) - return player ~= nil and player:is_player() + return player ~= nil and minetest.is_player(player) +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)) 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.5") then + 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 hb.settings.hp_player_maximun = 20 hb.settings.br_player_maximun = 10 if player_exists(player) then @@ -116,9 +184,6 @@ 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 @@ -456,6 +521,8 @@ 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 @@ -475,7 +542,8 @@ 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 hudtable.hudstate[name].hidden == false then return true end + if not hudtable.hudstate[name] then return false end + if not hudtable.hudstate[name].hidden then return false end local value = hudtable.hudstate[name].value local max = hudtable.hudstate[name].max if hb.settings.bar_type == "progress_bar" then @@ -518,16 +586,22 @@ function hb.get_hudbar_identifiers() return ids end ---register built-in HUD bars +--register built-in HUD bars and armor HUD bar 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" if hb.settings.bar_type == "progress_bar" then hicon = nil bicon = nil + aicon = nil + sicon = nil end - 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, true) + 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) + 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" } } ) + 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 = "%02d", format_max_value = "%02d" }) end local function hide_builtin(player) @@ -537,27 +611,71 @@ local function hide_builtin(player) player:hud_set_flags(flags) end +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 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 + local arm = tonumber(hbarmor.armor[name]) + if not arm then arm = 0 end + + local hbhide if minetest.settings:get_bool("enable_damage") then - hide = false + hbhide = false else - hide = true + hbhide = true end + local hahide + if hbarmor.autohide then + hahide = must_hide(name, arm) + else + hahide = false + end + local sahide = true + local hp = player:get_hp() local hp_max = hb.settings.hp_player_maximun - hb.init_hudbar(player, "health", math.min(hp, hp_max), hp_max, hide) + 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, hbhide) + 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 or hide) + hb.init_hudbar(player, "breath", math.min(breath, breath_max), breath_max, hide_breath or hbhide) + + hbarmor.get_armor(player) + arm = tonumber(hbarmor.armor[name]) + hb.init_hudbar(player, "armor", arm_printable(arm), 100, hahide) + + if hb.settings.forceload_default_hudbars then sahide = false end + hb.init_hudbar(player, "satiation", hbhunger.get_hunger_raw(player), nil, sahide) end end @@ -569,16 +687,24 @@ end -- update built-in HUD bars local function update_hud(player) - if not player_exists(player) then return end + + local lplayer = player_exists(player) + if not lplayer then return end + local name = player:get_player_name() + if not name then return end + local larmor = hbarmor.armor[name] + if not larmor then return end + local arm = tonumber(larmor) + if not arm then arm = 0; hbarmor.armor[name] = 0 end + + -- loading only if need or force loading 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 @@ -587,10 +713,31 @@ local function update_hud(player) end --health update_health(player) + -- armor + 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 + -- hunger + 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 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 @@ -602,33 +749,88 @@ end) minetest.register_on_respawnplayer(function(player) update_health(player) + local name = player:get_player_name() + hbhunger.hunger[name] = hbhunger.SAT_INIT + hbhunger.set_hunger_raw(player) + hbhunger.exhaustion[name] = 0 hb.hide_hudbar(player, "breath") end) minetest.register_on_joinplayer(function(player) + local name = player:get_player_name() + local inv = player:get_inventory() + 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 hide_builtin(player) custom_hud(player) - hb.players[player:get_player_name()] = player + hb.players[name] = player + hbarmor.player_active[name] = true + hbhunger.set_hunger_raw(player) end) minetest.register_on_leaveplayer(function(player) - hb.players[player:get_player_name()] = nil + local name = player:get_player_name() + hb.players[name] = nil + hbarmor.player_active[name] = false end) 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 all hud elements update_hud(player) end + -- update all hud elements + for _,player in ipairs(minetest.get_connected_players()) do + local name = player:get_player_name() + if hbarmor.player_active[name] == true then + hbarmor.get_armor(player) + update_hud(player) + end + end + + end + end + -- 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 + 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 end if timer > 4 then timer = 0 end + if timer2 > hbhunger.HUNGER_TICK then timer2 = 0 end end) diff --git a/mods/hudbars/locale/hudbars.de.tr b/mods/hudbars/locale/hudbars.de.tr index 3d1e697..2c4c0c1 100644 --- a/mods/hudbars/locale/hudbars.de.tr +++ b/mods/hudbars/locale/hudbars.de.tr @@ -2,3 +2,11 @@ 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. +[] =[] diff --git a/mods/hudbars/locale/hudbars.es.tr b/mods/hudbars/locale/hudbars.es.tr index bbf0279..288d2e7 100644 --- a/mods/hudbars/locale/hudbars.es.tr +++ b/mods/hudbars/locale/hudbars.es.tr @@ -2,3 +2,10 @@ 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. diff --git a/mods/hbhunger/locale/hbhunger.fr.tr b/mods/hudbars/locale/hudbars.fr.tr similarity index 100% rename from mods/hbhunger/locale/hbhunger.fr.tr rename to mods/hudbars/locale/hudbars.fr.tr diff --git a/mods/hudbars/locale/hudbars.it.tr b/mods/hudbars/locale/hudbars.it.tr index 3ada5b6..c974141 100644 --- a/mods/hudbars/locale/hudbars.it.tr +++ b/mods/hudbars/locale/hudbars.it.tr @@ -1,6 +1,7 @@ # 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à diff --git a/mods/hudbars/locale/hudbars.ms.tr b/mods/hudbars/locale/hudbars.ms.tr index eb811ab..a0f4b5a 100644 --- a/mods/hudbars/locale/hudbars.ms.tr +++ b/mods/hudbars/locale/hudbars.ms.tr @@ -2,3 +2,4 @@ Health=Kesihatan Breath=Nafas @1: @2/@3=@1: @2/@3 +Satiation=Kekenyangan diff --git a/mods/hudbars/locale/hudbars.pt.tr b/mods/hudbars/locale/hudbars.pt.tr index a818f09..e57a8b2 100644 --- a/mods/hudbars/locale/hudbars.pt.tr +++ b/mods/hudbars/locale/hudbars.pt.tr @@ -1,6 +1,7 @@ # 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 diff --git a/mods/hudbars/locale/hudbars.ru.tr b/mods/hudbars/locale/hudbars.ru.tr index 2d278e3..cc39433 100644 --- a/mods/hudbars/locale/hudbars.ru.tr +++ b/mods/hudbars/locale/hudbars.ru.tr @@ -1,4 +1,7 @@ # textdomain: hudbars -Health=HP +Health=Здоровье Breath=дыхание @1: @2/@3=@1: @2/@3 +Armor=Доспехи +@1: @2%=@1: @2% +Satiation=голод diff --git a/mods/hudbars/locale/template.txt b/mods/hudbars/locale/template.txt index 37b0559..253d574 100644 --- a/mods/hudbars/locale/template.txt +++ b/mods/hudbars/locale/template.txt @@ -1,6 +1,10 @@ # textdomain: hudbars Health= Breath= +Armor= -# Default format string for progress bar-style HUD bars, e.g. “Health 5/20” +# Default format string for progress bar-style HUD bars, e.g. “Health 05/20” @1: @2/@3= + +# Format string for displaying the armor. E.g. "Armor: 100%" +@1: @2%= diff --git a/mods/hudbars/mod.conf b/mods/hudbars/mod.conf index d6a0571..e07285d 100644 --- a/mods/hudbars/mod.conf +++ b/mods/hudbars/mod.conf @@ -1,2 +1,3 @@ name = hudbars -description = HUD mod to display as bars and API for +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 diff --git a/mods/hbhunger/register_foods.lua b/mods/hudbars/register_foods.lua similarity index 100% rename from mods/hbhunger/register_foods.lua rename to mods/hudbars/register_foods.lua diff --git a/mods/hudbars/screenshot.png b/mods/hudbars/screenshot.png index 88ee323..fcc1dd1 100644 Binary files a/mods/hudbars/screenshot.png and b/mods/hudbars/screenshot.png differ diff --git a/mods/hudbars/settingtypes.txt b/mods/hudbars/settingtypes.txt index 87f1006..4a491ad 100644 --- a/mods/hudbars/settingtypes.txt +++ b/mods/hudbars/settingtypes.txt @@ -124,4 +124,17 @@ hudbars_hp_player_maximun (maximun value of heal of player) int 40 # 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 +#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 diff --git a/mods/hbhunger/sounds/hbhunger_eat_generic.ogg b/mods/hudbars/sounds/hbhunger_eat_generic.ogg similarity index 100% rename from mods/hbhunger/sounds/hbhunger_eat_generic.ogg rename to mods/hudbars/sounds/hbhunger_eat_generic.ogg diff --git a/mods/hbarmor/textures/hbarmor_bar.png b/mods/hudbars/textures/hbarmor_bar.png similarity index 100% rename from mods/hbarmor/textures/hbarmor_bar.png rename to mods/hudbars/textures/hbarmor_bar.png diff --git a/mods/hudbars/textures/hbarmor_icon.png b/mods/hudbars/textures/hbarmor_icon.png new file mode 100644 index 0000000..c666138 Binary files /dev/null and b/mods/hudbars/textures/hbarmor_icon.png differ diff --git a/mods/hbhunger/textures/hbhunger_bar.png b/mods/hudbars/textures/hbhunger_bar.png similarity index 100% rename from mods/hbhunger/textures/hbhunger_bar.png rename to mods/hudbars/textures/hbhunger_bar.png diff --git a/mods/hbhunger/textures/hbhunger_bar_health_poison.png b/mods/hudbars/textures/hbhunger_bar_health_poison.png similarity index 100% rename from mods/hbhunger/textures/hbhunger_bar_health_poison.png rename to mods/hudbars/textures/hbhunger_bar_health_poison.png diff --git a/mods/hbhunger/textures/hbhunger_icon.png b/mods/hudbars/textures/hbhunger_icon.png similarity index 100% rename from mods/hbhunger/textures/hbhunger_icon.png rename to mods/hudbars/textures/hbhunger_icon.png diff --git a/mods/hbhunger/textures/hbhunger_icon_health_poison.png b/mods/hudbars/textures/hbhunger_icon_health_poison.png similarity index 100% rename from mods/hbhunger/textures/hbhunger_icon_health_poison.png rename to mods/hudbars/textures/hbhunger_icon_health_poison.png