diff --git a/mods/README.md b/mods/README.md index ca411d2..1d7a668 100644 --- a/mods/README.md +++ b/mods/README.md @@ -23,7 +23,7 @@ Most of those mods have mirror at http://git.mirror.org | fire | https://codeberg.org/minenux/minetest-mod-fire | https://codeberg.org/minenux/minetest-mod-fire/commit/4e5f7ad55314bd9b126fb133cfc5a32fa58b20d2 | [fire/README.md](fire/README.md) | | fireflies | https://codeberg.org/minenux/minetest-game-minetest | https://codeberg.org/minenux/minetest-game-minetest/commit/ee13c9f46ad23972dfd52e74104b265d81bd50b8 | [fireflies/README.md](fireflies/README.md) | | flowers | https://codeberg.org/minenux/minetest-game-minetest | https://codeberg.org/minenux/minetest-game-minetest/commit/c7cb79422ba19c696966472942db6177c934838d | | -| hudbars | https://codeberg.org/minenux/minetest-mod-hudbars | https://codeberg.org/minenux/minetest-mod-hudbars/commit/c219b708f89ccf8683c3ee33e1fe55641cc8b10a | [hudbars/README.md](hudbars/README.md) | +| hudbars | https://codeberg.org/minenux/minetest-mod-hudbars | https://codeberg.org/minenux/minetest-mod-hudbars/commit/1a86b2a773030bd26d6fac2c3b9f6df6d23916ed | [hudbars/README.md](hudbars/README.md) | | give_initial_stuff | https://codeberg.org/minenux/minetest-game-minetest | https://codeberg.org/minenux/minetest-game-minetest/commit/c7cb79422ba19c696966472942db6177c934838d | | | killme | https://codeberg.org/minenux/minetest-game-minetest | https://codeberg.org/minenux/minetest-game-minetest/commit/c7cb79422ba19c696966472942db6177c934838d | | | sfinv | https://codeberg.org/minenux/minetest-game-minetest | https://codeberg.org/minenux/minetest-game-minetest/commit/c7cb79422ba19c696966472942db6177c934838d | | 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 04475ac..75ec2e6 100644 --- a/mods/hudbars/default_settings.lua +++ b/mods/hudbars/default_settings.lua @@ -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.1) +hb.settings.tick = hb.load_setting("hudbars_tick", "number", 0.3) -- 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) +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 @@ -47,11 +47,33 @@ else hb.settings.sorting_reverse = { [0] = "health", [1] = "breath" } end -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) +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) 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 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/hudbars/hunger.lua b/mods/hudbars/hunger.lua new file mode 100644 index 0000000..0387581 --- /dev/null +++ b/mods/hudbars/hunger.lua @@ -0,0 +1,175 @@ +-- Keep these for backwards compatibility +function hbhunger.save_hunger(player) + hbhunger.set_hunger_raw(player) +end +function hbhunger.load_hunger(player) + hbhunger.get_hunger_raw(player) +end + +-- wrapper for minetest.item_eat (this way we make sure other mods can't break this one) +local org_eat = minetest.do_item_eat +minetest.do_item_eat = function(hp_change, replace_with_item, itemstack, user, pointed_thing) + local old_itemstack = itemstack + itemstack = hbhunger.eat(hp_change, replace_with_item, itemstack, user, pointed_thing) + for _, callback in pairs(minetest.registered_on_item_eats) do + local result = callback(hp_change, replace_with_item, itemstack, user, pointed_thing, old_itemstack) + if result then + return result + end + end + return itemstack +end + +-- food functions +local food = hbhunger.food + +function hbhunger.register_food(name, hunger_change, replace_with_item, poisen, heal, sound) + food[name] = {} + food[name].saturation = hunger_change -- hunger points added + food[name].replace = replace_with_item -- what item is given back after eating + food[name].poisen = poisen -- time its poisening + food[name].healing = heal -- amount of HP + food[name].sound = sound -- special sound that is played when eating +end + +function hbhunger.eat(hp_change, replace_with_item, itemstack, user, pointed_thing) + local item = itemstack:get_name() + local def = food[item] + if not def then + def = {} + if type(hp_change) ~= "number" then + hp_change = 1 + minetest.log("error", "Wrong on_use() definition for item '" .. item .. "'") + end + def.saturation = hp_change * 1.3 + def.replace = replace_with_item + end + local func = hbhunger.item_eat(def.saturation, def.replace, def.poisen, def.healing, def.sound) + return func(itemstack, user, pointed_thing) +end + +-- Poison player +local function poisenp(tick, time, time_left, player) + -- First check if player is still there + if not player:is_player() then + return + end + time_left = time_left + tick + if time_left < time then + minetest.after(tick, poisenp, tick, time, time_left, player) + else + hbhunger.poisonings[player:get_player_name()] = hbhunger.poisonings[player:get_player_name()] - 1 + if hbhunger.poisonings[player:get_player_name()] <= 0 then + -- Reset HUD bar color + hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health.png", nil, "hudbars_bar_health.png") + end + end + if player:get_hp()-1 > 0 then + player:set_hp(player:get_hp()-1) + end + +end + +function hbhunger.item_eat(hunger_change, replace_with_item, poisen, heal, sound) + return function(itemstack, user, pointed_thing) + if itemstack:take_item() ~= nil and user ~= nil then + local name = user:get_player_name() + local h = tonumber(hbhunger.hunger[name]) + local hp = user:get_hp() + if h == nil or hp == nil then + return + end + if user:is_player() then + local object, object_pos + -- Check if user is a "fake player" (unofficial imitation of a the player data structure) + if type(user) == "userdata" then + object = user + else + object_pos = user:get_pos() + end + minetest.sound_play( + {name = sound or "hbhunger_eat_generic", + gain = 1}, + {object=object, + pos=object_pos, + max_hear_distance = 16, + pitch = 1 + math.random(-10, 10)*0.005,}, + true + ) + end + + -- Saturation + if h < hbhunger.SAT_MAX and hunger_change then + h = h + hunger_change + if h > hbhunger.SAT_MAX then h = hbhunger.SAT_MAX end + hbhunger.hunger[name] = h + hbhunger.set_hunger_raw(user) + end + -- we must respect the real maximun hp of the player already set + 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 < 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 + user:set_hp(hp) + end + -- Poison + if poisen then + -- Set poison bar + hb.change_hudbar(user, "health", nil, nil, "hbhunger_icon_health_poison.png", nil, "hbhunger_bar_health_poison.png") + hbhunger.poisonings[name] = hbhunger.poisonings[name] + 1 + poisenp(1, poisen, 0, user) + end + + if itemstack:get_count() == 0 then + itemstack:add_item(replace_with_item) + else + local inv = user:get_inventory() + if inv:room_for_item("main", replace_with_item) then + inv:add_item("main", replace_with_item) + else + minetest.add_item(user:get_pos(), replace_with_item) + end + end + end + return itemstack + end +end + +-- player-action based hunger changes +function hbhunger.handle_node_actions(pos, oldnode, player, ext) + -- is_fake_player comes from the pipeworks, we are not interested in those + if not player or not player:is_player() or player.is_fake_player == true then + return + end + local name = player:get_player_name() + local exhaus = hbhunger.exhaustion[name] + if exhaus == nil then return end + local new = hbhunger.EXHAUST_PLACE + -- placenode event + if not ext then + new = hbhunger.EXHAUST_DIG + end + -- assume its send by main timer when movement detected + if not pos and not oldnode then + new = hbhunger.EXHAUST_MOVE + end + exhaus = exhaus + new + if exhaus > hbhunger.EXHAUST_LVL then + exhaus = 0 + local h = tonumber(hbhunger.hunger[name]) + h = h - 1 + if h < 0 then h = 0 end + hbhunger.hunger[name] = h + hbhunger.set_hunger_raw(player) + end + hbhunger.exhaustion[name] = exhaus +end + +minetest.register_on_placenode(hbhunger.handle_node_actions) +minetest.register_on_dignode(hbhunger.handle_node_actions) diff --git a/mods/hudbars/init.lua b/mods/hudbars/init.lua index 3133ff4..1669c9a 100644 --- a/mods/hudbars/init.lua +++ b/mods/hudbars/init.lua @@ -24,7 +24,17 @@ end local N = function(s) return s end +local modarmors = minetest.get_modpath("3d_armor") +local modhbarm = minetest.get_modpath("hbarmor") +local modhbhung = minetest.get_modpath("hbhunger") + +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 +44,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 +103,59 @@ end -- Load default settings dofile(minetest.get_modpath("hudbars").."/default_settings.lua") +if not modhbhung 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 player:is_player() + return player ~= nil and (type(player) == "userdata") +end + +local must_hide = function(playername, arm) + if modarmors then + return ((not armor.def[playername].count or armor.def[playername].count == 0 or not hb.settings.forceload_default_hudbars) and arm == 0) + end + return modarmors +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 +195,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 @@ -234,7 +310,7 @@ function hb.register_hudbar(identifier, text_color, label, textures, default_sta hud_elem_type = "image", position = pos, scale = bgscale, - text = "hudbars_bar_background.png", + text = "", alignment = {x=1,y=1}, offset = { x = offset.x - 1, y = offset.y - 1 }, z_index = 0, @@ -456,6 +532,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 +553,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,10 +597,20 @@ 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 - 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) + 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 modhbarm 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 modhbhung 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 end local function hide_builtin(player) @@ -531,27 +620,67 @@ local function hide_builtin(player) player:hud_set_flags(flags) end +if not modhbarm and modarmors 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 - hb.init_hudbar(player, "health", math.min(hp, hp_max), hp_max, hide) + 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) + 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) + + if not modhbarm and modarmors 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 modhbhung then + hb.init_hudbar(player, "satiation", hbhunger.get_hunger_raw(player), nil, (not hb.settings.forceload_default_hudbars) ) + end end end @@ -563,16 +692,18 @@ end -- update built-in HUD bars local function update_hud(player) - if not player_exists(player) then return end + + 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 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 @@ -581,10 +712,38 @@ local function update_hud(player) end --health update_health(player) + -- armor + if not modhbarm and modarmors 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 modhbhung 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 @@ -595,34 +754,122 @@ 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 modhbhung 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 modhbhung 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[player:get_player_name()] = player + hb.players[name] = player + if not modhbarm then + hbarmor.player_active[name] = true + end + if not modhbhung then + hbhunger.set_hunger_raw(player) + end end) minetest.register_on_leaveplayer(function(player) - hb.players[player:get_player_name()] = nil + if not player_exists(player) then return end + + local name = player:get_player_name() + hb.players[name] = nil + if not modhbarm then + hbarmor.player_active[name] = false + end end) +local modresult = "" + +if modhbarm then modresult = modresult .. " without build-in hbarmor" end +if modhbhung 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 all hud elements update_hud(player) end + if not modhbarm and modarmors 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 modhbhung 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 + 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/hudbars/locale/hudbars.fr.tr b/mods/hudbars/locale/hudbars.fr.tr new file mode 100644 index 0000000..0a8a382 --- /dev/null +++ b/mods/hudbars/locale/hudbars.fr.tr @@ -0,0 +1,2 @@ +# textdomain:hbhunger +Satiation=Satiété 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/hudbars/register_foods.lua b/mods/hudbars/register_foods.lua new file mode 100644 index 0000000..c7dd5b0 --- /dev/null +++ b/mods/hudbars/register_foods.lua @@ -0,0 +1,331 @@ +if minetest.get_modpath("default") ~= nil then + hbhunger.register_food("default:apple", 2) + hbhunger.register_food("default:blueberries", 2) +end +if minetest.get_modpath("flowers") ~= nil then + hbhunger.register_food("flowers:mushroom_brown", 1) + hbhunger.register_food("flowers:mushroom_red", 1, "", 3) +end +if minetest.get_modpath("farming") ~= nil then + hbhunger.register_food("farming:bread", 5) +end + +if minetest.get_modpath("mobs") ~= nil then + if mobs.mod ~= nil and mobs.mod == "redo" then + hbhunger.register_food("mobs:cheese", 4) + hbhunger.register_food("mobs:meat", 8) + hbhunger.register_food("mobs:meat_raw", 4) + hbhunger.register_food("mobs:rat_cooked", 4) + hbhunger.register_food("mobs:honey", 2) + hbhunger.register_food("mobs:pork_raw", 3, "", 3) + hbhunger.register_food("mobs:pork_cooked", 8) + hbhunger.register_food("mobs:chicken_cooked", 6) + hbhunger.register_food("mobs:chicken_raw", 2, "", 3) + hbhunger.register_food("mobs:chicken_egg_fried", 2) + if minetest.get_modpath("bucket") then + hbhunger.register_food("mobs:bucket_milk", 3, "bucket:bucket_empty") + end + else + hbhunger.register_food("mobs:meat", 6) + hbhunger.register_food("mobs:meat_raw", 3) + hbhunger.register_food("mobs:rat_cooked", 5) + end +end + +if minetest.get_modpath("moretrees") ~= nil then + hbhunger.register_food("moretrees:coconut_milk", 1) + hbhunger.register_food("moretrees:raw_coconut", 2) + hbhunger.register_food("moretrees:acorn_muffin", 3) + hbhunger.register_food("moretrees:spruce_nuts", 1) + hbhunger.register_food("moretrees:pine_nuts", 1) + hbhunger.register_food("moretrees:fir_nuts", 1) +end + +if minetest.get_modpath("dwarves") ~= nil then + hbhunger.register_food("dwarves:beer", 2) + hbhunger.register_food("dwarves:apple_cider", 1) + hbhunger.register_food("dwarves:midus", 2) + hbhunger.register_food("dwarves:tequila", 2) + hbhunger.register_food("dwarves:tequila_with_lime", 2) + hbhunger.register_food("dwarves:sake", 2) +end + +if minetest.get_modpath("animalmaterials") ~= nil then + hbhunger.register_food("animalmaterials:milk", 2) + hbhunger.register_food("animalmaterials:meat_raw", 3) + hbhunger.register_food("animalmaterials:meat_pork", 3) + hbhunger.register_food("animalmaterials:meat_beef", 3) + hbhunger.register_food("animalmaterials:meat_chicken", 3) + hbhunger.register_food("animalmaterials:meat_lamb", 3) + hbhunger.register_food("animalmaterials:meat_venison", 3) + hbhunger.register_food("animalmaterials:meat_undead", 3, "", 3) + hbhunger.register_food("animalmaterials:meat_toxic", 3, "", 5) + hbhunger.register_food("animalmaterials:meat_ostrich", 3) + hbhunger.register_food("animalmaterials:fish_bluewhite", 2) + hbhunger.register_food("animalmaterials:fish_clownfish", 2) +end + +if minetest.get_modpath("fishing") ~= nil then + hbhunger.register_food("fishing:fish_raw", 2) + hbhunger.register_food("fishing:fish_cooked", 5) + hbhunger.register_food("fishing:sushi", 6) + hbhunger.register_food("fishing:shark", 4) + hbhunger.register_food("fishing:shark_cooked", 8) + hbhunger.register_food("fishing:pike", 4) + hbhunger.register_food("fishing:pike_cooked", 8) +end + +if minetest.get_modpath("glooptest") ~= nil then + hbhunger.register_food("glooptest:kalite_lump", 1) +end + +if minetest.get_modpath("bushes") ~= nil then + hbhunger.register_food("bushes:sugar", 1) + hbhunger.register_food("bushes:strawberry", 2) + hbhunger.register_food("bushes:berry_pie_raw", 3) + hbhunger.register_food("bushes:berry_pie_cooked", 4) + hbhunger.register_food("bushes:basket_pies", 15) +end + +if minetest.get_modpath("bushes_classic") then + -- bushes_classic mod, as found in the plantlife modpack + local berries = { + "strawberry", + "blackberry", + "blueberry", + "raspberry", + "gooseberry", + "mixed_berry"} + for _, berry in ipairs(berries) do + if berry ~= "mixed_berry" then + hbhunger.register_food("bushes:"..berry, 1) + end + hbhunger.register_food("bushes:"..berry.."_pie_raw", 2) + hbhunger.register_food("bushes:"..berry.."_pie_cooked", 5) + hbhunger.register_food("bushes:basket_"..berry, 15) + end +end + +if minetest.get_modpath("mushroom") ~= nil then + hbhunger.register_food("mushroom:brown", 1) + hbhunger.register_food("mushroom:red", 1, "", 3) + -- mushroom potions: red = strong poison, brown = light restorative + if minetest.get_modpath("vessels") then + hbhunger.register_food("mushroom:brown_essence", 1, "vessels:glass_bottle", nil, 4) + hbhunger.register_food("mushroom:poison", 1, "vessels:glass_bottle", 10) + end +end + +if minetest.get_modpath("docfarming") ~= nil then + hbhunger.register_food("docfarming:carrot", 3) + hbhunger.register_food("docfarming:cucumber", 2) + hbhunger.register_food("docfarming:corn", 3) + hbhunger.register_food("docfarming:potato", 4) + hbhunger.register_food("docfarming:bakedpotato", 5) + hbhunger.register_food("docfarming:raspberry", 3) +end + +if minetest.get_modpath("farming_plus") ~= nil then + hbhunger.register_food("farming_plus:carrot_item", 3) + hbhunger.register_food("farming_plus:banana", 2) + hbhunger.register_food("farming_plus:orange_item", 2) + hbhunger.register_food("farming:pumpkin_bread", 4) + hbhunger.register_food("farming_plus:strawberry_item", 2) + hbhunger.register_food("farming_plus:tomato_item", 2) + hbhunger.register_food("farming_plus:potato_item", 4) + hbhunger.register_food("farming_plus:rhubarb_item", 2) +end + +if minetest.get_modpath("mtfoods") ~= nil then + hbhunger.register_food("mtfoods:dandelion_milk", 1) + hbhunger.register_food("mtfoods:sugar", 1) + hbhunger.register_food("mtfoods:short_bread", 4) + hbhunger.register_food("mtfoods:cream", 1) + hbhunger.register_food("mtfoods:chocolate", 2) + hbhunger.register_food("mtfoods:cupcake", 2) + hbhunger.register_food("mtfoods:strawberry_shortcake", 2) + hbhunger.register_food("mtfoods:cake", 3) + hbhunger.register_food("mtfoods:chocolate_cake", 3) + hbhunger.register_food("mtfoods:carrot_cake", 3) + hbhunger.register_food("mtfoods:pie_crust", 3) + hbhunger.register_food("mtfoods:apple_pie", 3) + hbhunger.register_food("mtfoods:rhubarb_pie", 2) + hbhunger.register_food("mtfoods:banana_pie", 3) + hbhunger.register_food("mtfoods:pumpkin_pie", 3) + hbhunger.register_food("mtfoods:cookies", 2) + hbhunger.register_food("mtfoods:mlt_burger", 5) + hbhunger.register_food("mtfoods:potato_slices", 2) + hbhunger.register_food("mtfoods:potato_chips", 3) + --mtfoods:medicine + hbhunger.register_food("mtfoods:casserole", 3) + hbhunger.register_food("mtfoods:glass_flute", 2) + hbhunger.register_food("mtfoods:orange_juice", 2) + hbhunger.register_food("mtfoods:apple_juice", 2) + hbhunger.register_food("mtfoods:apple_cider", 2) + hbhunger.register_food("mtfoods:cider_rack", 2) +end + +if minetest.get_modpath("fruit") ~= nil then + hbhunger.register_food("fruit:apple", 2) + hbhunger.register_food("fruit:pear", 2) + hbhunger.register_food("fruit:bananna", 3) + hbhunger.register_food("fruit:orange", 2) +end + +if minetest.get_modpath("mush45") ~= nil then + hbhunger.register_food("mush45:meal", 4) +end + +if minetest.get_modpath("seaplants") ~= nil then + hbhunger.register_food("seaplants:kelpgreen", 1) + hbhunger.register_food("seaplants:kelpbrown", 1) + hbhunger.register_food("seaplants:seagrassgreen", 1) + hbhunger.register_food("seaplants:seagrassred", 1) + hbhunger.register_food("seaplants:seasaladmix", 6) + hbhunger.register_food("seaplants:kelpgreensalad", 1) + hbhunger.register_food("seaplants:kelpbrownsalad", 1) + hbhunger.register_food("seaplants:seagrassgreensalad", 1) + hbhunger.register_food("seaplants:seagrassgreensalad", 1) +end + +if minetest.get_modpath("mobfcooking") ~= nil then + hbhunger.register_food("mobfcooking:cooked_pork", 6) + hbhunger.register_food("mobfcooking:cooked_ostrich", 6) + hbhunger.register_food("mobfcooking:cooked_beef", 6) + hbhunger.register_food("mobfcooking:cooked_chicken", 6) + hbhunger.register_food("mobfcooking:cooked_lamb", 6) + hbhunger.register_food("mobfcooking:cooked_venison", 6) + hbhunger.register_food("mobfcooking:cooked_fish", 6) +end + +if minetest.get_modpath("creatures") ~= nil then + hbhunger.register_food("creatures:meat", 6) + hbhunger.register_food("creatures:flesh", 3) + hbhunger.register_food("creatures:rotten_flesh", 3, "", 3) +end + +if minetest.get_modpath("ethereal") then + hbhunger.register_food("ethereal:strawberry", 1) + hbhunger.register_food("ethereal:banana", 4) + hbhunger.register_food("ethereal:pine_nuts", 1) + hbhunger.register_food("ethereal:bamboo_sprout", 0, "", 3) + hbhunger.register_food("ethereal:fern_tubers", 1) + hbhunger.register_food("ethereal:banana_bread", 7) + hbhunger.register_food("ethereal:mushroom_plant", 2) + hbhunger.register_food("ethereal:coconut_slice", 2) + hbhunger.register_food("ethereal:golden_apple", 4, "", nil, 10) + hbhunger.register_food("ethereal:wild_onion_plant", 2) + hbhunger.register_food("ethereal:mushroom_soup", 4, "ethereal:bowl") + hbhunger.register_food("ethereal:mushroom_soup_cooked", 6, "ethereal:bowl") + hbhunger.register_food("ethereal:hearty_stew", 6, "ethereal:bowl") + hbhunger.register_food("ethereal:hearty_stew_cooked", 10, "ethereal:bowl") + if minetest.get_modpath("bucket") then + hbhunger.register_food("ethereal:bucket_cactus", 2, "bucket:bucket_empty") + end + hbhunger.register_food("ethereal:fish_raw", 2) + hbhunger.register_food("ethereal:fish_cooked", 5) + hbhunger.register_food("ethereal:seaweed", 1) + hbhunger.register_food("ethereal:yellowleaves", 1, "", nil, 1) + hbhunger.register_food("ethereal:sashimi", 4) + hbhunger.register_food("ethereal:orange", 2) +end + +if minetest.get_modpath("farming") and farming.mod == "redo" then + hbhunger.register_food("farming:bread", 6) + hbhunger.register_food("farming:potato", 1) + hbhunger.register_food("farming:baked_potato", 6) + hbhunger.register_food("farming:cucumber", 4) + hbhunger.register_food("farming:tomato", 4) + hbhunger.register_food("farming:carrot", 3) + hbhunger.register_food("farming:carrot_gold", 6, "", nil, 8) + hbhunger.register_food("farming:corn", 3) + hbhunger.register_food("farming:corn_cob", 5) + hbhunger.register_food("farming:melon_slice", 2) + hbhunger.register_food("farming:pumpkin_slice", 1) + hbhunger.register_food("farming:pumpkin_bread", 9) + hbhunger.register_food("farming:coffee_cup", 2, "farming:drinking_cup") + hbhunger.register_food("farming:coffee_cup_hot", 3, "farming:drinking_cup", nil, 2) + hbhunger.register_food("farming:cookie", 2) + hbhunger.register_food("farming:chocolate_dark", 3) + hbhunger.register_food("farming:donut", 4) + hbhunger.register_food("farming:donut_chocolate", 6) + hbhunger.register_food("farming:donut_apple", 6) + hbhunger.register_food("farming:raspberries", 1) + hbhunger.register_food("farming:blueberries", 1) + hbhunger.register_food("farming:muffin_blueberry", 4) + if minetest.get_modpath("vessels") then + hbhunger.register_food("farming:smoothie_raspberry", 2, "vessels:drinking_glass") + end + hbhunger.register_food("farming:rhubarb", 1) + hbhunger.register_food("farming:rhubarb_pie", 6) + hbhunger.register_food("farming:beans", 1) +end + +if minetest.get_modpath("kpgmobs") ~= nil then + hbhunger.register_food("kpgmobs:uley", 3) + hbhunger.register_food("kpgmobs:meat", 6) + hbhunger.register_food("kpgmobs:rat_cooked", 5) + hbhunger.register_food("kpgmobs:med_cooked", 4) + if minetest.get_modpath("bucket") then + hbhunger.register_food("kpgmobs:bucket_milk", 4, "bucket:bucket_empty") + end +end + +if minetest.get_modpath("jkfarming") ~= nil then + hbhunger.register_food("jkfarming:carrot", 3) + hbhunger.register_food("jkfarming:corn", 3) + hbhunger.register_food("jkfarming:melon_part", 2) + hbhunger.register_food("jkfarming:cake", 3) +end + +if minetest.get_modpath("jkanimals") ~= nil then + hbhunger.register_food("jkanimals:meat", 6) +end + +if minetest.get_modpath("jkwine") ~= nil then + hbhunger.register_food("jkwine:grapes", 2) + hbhunger.register_food("jkwine:winebottle", 1) +end + +if minetest.get_modpath("cooking") ~= nil then + hbhunger.register_food("cooking:meat_beef_cooked", 4) + hbhunger.register_food("cooking:fish_bluewhite_cooked", 3) + hbhunger.register_food("cooking:fish_clownfish_cooked", 1) + hbhunger.register_food("cooking:meat_chicken_cooked", 2) + hbhunger.register_food("cooking:meat_cooked", 2) + hbhunger.register_food("cooking:meat_pork_cooked", 3) + hbhunger.register_food("cooking:meat_toxic_cooked", -3) + hbhunger.register_food("cooking:meat_venison_cooked", 3) + hbhunger.register_food("cooking:meat_undead_cooked", 1) +end + +-- ferns mod of plantlife_modpack +if minetest.get_modpath("ferns") ~= nil then + hbhunger.register_food("ferns:fiddlehead", 1, "", 1) + hbhunger.register_food("ferns:fiddlehead_roasted", 3) + hbhunger.register_food("ferns:ferntuber_roasted", 3) + hbhunger.register_food("ferns:horsetail_01", 1) +end + +if minetest.get_modpath("pizza") ~= nil then + hbhunger.register_food("pizza:pizza", 30, "", nil, 30) + hbhunger.register_food("pizza:pizzaslice", 5, "", nil, 5) +end + +if minetest.get_modpath("nssm") then + hbhunger.register_food("nssm:werewolf_leg", 3) + hbhunger.register_food("nssm:heron_leg", 2) + hbhunger.register_food("nssm:chichibios_heron_leg", 4) + hbhunger.register_food("nssm:crocodile_tail", 3) + hbhunger.register_food("nssm:duck_legs", 1) + hbhunger.register_food("nssm:ant_leg", 1) + hbhunger.register_food("nssm:spider_leg", 1) + hbhunger.register_food("nssm:tentacle", 2) + hbhunger.register_food("nssm:worm_flesh", 2, "", 2) -- poisonous + hbhunger.register_food("nssm:amphibian_heart", 1) + hbhunger.register_food("nssm:raw_scrausics_wing", 1) + -- superfoods + hbhunger.register_food("nssm:phoenix_nuggets", 20, "", nil, 20) + hbhunger.register_food("nssm:phoenix_tear", 20, "", nil, 20) +end + diff --git a/mods/hudbars/screenshot.png b/mods/hudbars/screenshot.png index 88ee323..82531ef 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 6ce1385..4a491ad 100644 --- a/mods/hudbars/settingtypes.txt +++ b/mods/hudbars/settingtypes.txt @@ -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 true +hudbars_autohide_breath (Automatically hide breath indicators) bool false # 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,8 +120,21 @@ 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 20 +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 10 +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/hudbars/sounds/hbhunger_eat_generic.ogg b/mods/hudbars/sounds/hbhunger_eat_generic.ogg new file mode 100644 index 0000000..b6acd07 Binary files /dev/null and b/mods/hudbars/sounds/hbhunger_eat_generic.ogg differ diff --git a/mods/hudbars/textures/hbarmor_bar.png b/mods/hudbars/textures/hbarmor_bar.png new file mode 100644 index 0000000..3c65224 Binary files /dev/null and b/mods/hudbars/textures/hbarmor_bar.png differ 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/hudbars/textures/hbhunger_bar.png b/mods/hudbars/textures/hbhunger_bar.png new file mode 100644 index 0000000..c94bf52 Binary files /dev/null and b/mods/hudbars/textures/hbhunger_bar.png differ diff --git a/mods/hudbars/textures/hbhunger_bar_health_poison.png b/mods/hudbars/textures/hbhunger_bar_health_poison.png new file mode 100644 index 0000000..516bf6b Binary files /dev/null and b/mods/hudbars/textures/hbhunger_bar_health_poison.png differ diff --git a/mods/hudbars/textures/hbhunger_icon.png b/mods/hudbars/textures/hbhunger_icon.png new file mode 100644 index 0000000..22447c1 Binary files /dev/null and b/mods/hudbars/textures/hbhunger_icon.png differ diff --git a/mods/hudbars/textures/hbhunger_icon_health_poison.png b/mods/hudbars/textures/hbhunger_icon_health_poison.png new file mode 100644 index 0000000..daf6d39 Binary files /dev/null and b/mods/hudbars/textures/hbhunger_icon_health_poison.png differ diff --git a/mods/hudbars/textures/hudbars_icon_breath.png b/mods/hudbars/textures/hudbars_icon_breath.png index 8f49fbd..810cac9 100644 Binary files a/mods/hudbars/textures/hudbars_icon_breath.png and b/mods/hudbars/textures/hudbars_icon_breath.png differ diff --git a/mods/hudbars/textures/hudbars_icon_health.png b/mods/hudbars/textures/hudbars_icon_health.png index f1c980f..d5302ec 100644 Binary files a/mods/hudbars/textures/hudbars_icon_health.png and b/mods/hudbars/textures/hudbars_icon_health.png differ