Compare commits
30 Commits
Author | SHA1 | Date | |
---|---|---|---|
a231a5fb82 | |||
d6fe732528 | |||
3d53b43696 | |||
93d994cbad | |||
e9568ccdae | |||
c126114237 | |||
5634463f01 | |||
79e9343331 | |||
fa0ed391c6 | |||
e513aeb9cb | |||
02e5de41c2 | |||
b71769f63f | |||
2063945d5c | |||
ceb313e9ff | |||
bfc5f8cbb5 | |||
a4408d010f | |||
878a351e9d | |||
72aeb873d0 | |||
a493641f02 | |||
3d1b4b0a97 | |||
96a796cce7 | |||
71a30b5620 | |||
41fbe9a0d0 | |||
dd1bf4e74c | |||
2e3d5b7ca5 | |||
72c96c25a4 | |||
556f91b5c6 | |||
3d36b82a00 | |||
4f5e49e8b0 | |||
9ed25e212e |
2
.mailmap
Normal file
@ -0,0 +1,2 @@
|
||||
Wuzzy <Wuzzy@disroot.org> <Wuzzy2@mail.ru>
|
||||
Wuzzy <Wuzzy@disroot.org> <almikes@aol.com>
|
42
README.md
Normal file
@ -0,0 +1,42 @@
|
||||
# HUD bar for `3d_armor` [`hbarmor`]
|
||||
|
||||
* Version: 1.0.1
|
||||
|
||||
## 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 <https://opensource.org/licenses/MIT> for more details.
|
49
README.txt
@ -1,49 +0,0 @@
|
||||
Minetest mod: HUD bar for armor [hbarmor]
|
||||
=========================================
|
||||
Version: 0.1.0
|
||||
|
||||
License of source code: WTFPL
|
||||
-----------------------------
|
||||
By Wuzzy,
|
||||
|
||||
forked from the mod “Better HUD (and hunger)” [hud]
|
||||
by BlockMen (2013-2014).
|
||||
|
||||
|
||||
|
||||
Using the mod:
|
||||
--------------
|
||||
This mod adds a simple HUD bar which displays the current
|
||||
damage of the player's armor (from the 3D Armor mod) as a percentage,
|
||||
this number is of course rounded.
|
||||
100% 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 1
|
||||
- 3D Armor [3d_armor] (tested with 0.4.3)
|
||||
|
||||
|
||||
|
||||
License of textures:
|
||||
--------------------
|
||||
hbarmor_icon.png - Stu (CC BY-SA 3.0), modified by BlockMen
|
||||
hbarmor_bgicon.png - Stu (CC BY-SA 3.0), modified by BlockMen
|
||||
hbarmor_bar.png - Wuzzy (WTFPL)
|
||||
|
||||
|
||||
everything else is WTFPL:
|
||||
(c) 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 Do What The Fuck You Want
|
||||
To Public License, Version 2, as published by Sam Hocevar. See
|
||||
http://sam.zoy.org/wtfpl/COPYING for more details.
|
37
armor.lua
@ -1,37 +0,0 @@
|
||||
minetest.after(0, function()
|
||||
if not armor.def then
|
||||
minetest.after(2,minetest.chat_send_all,"#Better HUD: Please update your version of 3darmor")
|
||||
HUD_SHOW_ARMOR = false
|
||||
end
|
||||
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
|
||||
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] = lvl* (items * (100 / max_items))
|
||||
|
||||
|
||||
end
|
@ -1,88 +0,0 @@
|
||||
0.2 Beta
|
||||
--------
|
||||
- added support of custom config files
|
||||
- you can eat max. 50% more than before (although it isnt shown in hunger bar)
|
||||
- you get healed with 8 breads and more (in hunger bar) now
|
||||
- a bread (from farming) == 2 breads in hunger bar
|
||||
|
||||
0.2.1 Beta
|
||||
----------
|
||||
- tweaked override of food
|
||||
- added support for food of dwares, moretrees and simple mobs
|
||||
|
||||
0.2.2 Beta
|
||||
----------
|
||||
- added support for food of animalmaterials (mobf modpack),fishing
|
||||
|
||||
0.2.3 Beta
|
||||
----------
|
||||
- added support for food of glooptest and bushes (commit by CheeseKeg)
|
||||
|
||||
0.3 Beta
|
||||
----------
|
||||
- added fancy borders of hud inventory bar (only for screenheight <= 800)
|
||||
|
||||
0.4 Beta
|
||||
----------
|
||||
- enabled drowning
|
||||
|
||||
0.5 Beta
|
||||
----------
|
||||
- removed the fancy borders of hud inventory bar and moved to new native support
|
||||
- moved crosshair to native support too
|
||||
|
||||
1.0
|
||||
---
|
||||
- hunger is reset after death
|
||||
- health and hunger bar is shown correct on all screen resolutions now
|
||||
- switched to changed native hotbar image support
|
||||
- fixed revival of player when drown
|
||||
- hunger bar is not shown anymore if hunger is disabled
|
||||
- hunger can be disabled by minetest.conf ("hud_hunger_enable = false")
|
||||
|
||||
1.1
|
||||
---
|
||||
- added support for stu's 3darmor mod
|
||||
- restructured and cleaned up code
|
||||
- added support for poisen food (damages player, but does not kill)
|
||||
|
||||
1.2
|
||||
---
|
||||
- Send statbar values only to client when changed
|
||||
- Hide armor bar if not wearing armor
|
||||
- More reliable food overrides (by CiaranG)
|
||||
- Support for bushes_classic foods (plantlife modpack) (by CiaranG)
|
||||
- Add support for mushroom mod food/poison (by CiaranG)
|
||||
- Add support for mods: fruit and mush45
|
||||
- New images for hotbar, smaller armor icons
|
||||
|
||||
1.3
|
||||
---
|
||||
- New way hunger is saved (all old files in world dirctory can get deleted [e.g. hud_BlockMen_hunger])
|
||||
- Fixed healing (not while drowning, fix after death)
|
||||
- Add support for mods: seaplants[sea] and mobfcooking (by Xanthin)
|
||||
- Tweaked hand image
|
||||
- Player can die caus of starving now
|
||||
|
||||
1.3.1
|
||||
-----
|
||||
- Add compatibility for statbar scaling
|
||||
- Fix typo in depends.txt
|
||||
- Lower maintimer tick
|
||||
|
||||
1.3.2
|
||||
-----
|
||||
- Fix dependecies (by Chris Beelby)
|
||||
- Add support for creatures mod
|
||||
- Add optional healing for food (by TenPlus1)
|
||||
|
||||
1.3.3
|
||||
-----
|
||||
- Prevent crash with armor mod and missing player
|
||||
- Add support for ethereal mod (by TenPlus1)
|
||||
|
||||
1.4
|
||||
---
|
||||
- New hunger mechanics/added experimental player-action based hunger
|
||||
- Better crosshair texture, switched to "new" default hand
|
||||
- Added support for farming redo mod, kpgmobs and jkmod
|
@ -1,2 +0,0 @@
|
||||
hudbars
|
||||
3d_armor
|
@ -1,9 +0,0 @@
|
||||
-- If true, automatically hides the armor when the player wears no armor.
|
||||
-- Otherwise, the armor bar shows “0%”.
|
||||
|
||||
--hbarmor.autohide = true
|
||||
|
||||
-- Time difference in seconds between updates to the HUD armor bar.
|
||||
-- Increase this number for slow servers.
|
||||
|
||||
-- hbarmor.tick = 0.1
|
63
init.lua
@ -1,4 +1,11 @@
|
||||
hbarmor = {}
|
||||
local S = minetest.get_translator("hbarmor")
|
||||
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 = {}
|
||||
@ -6,21 +13,25 @@ hbarmor.armor = {}
|
||||
-- Stores if player's HUD bar has been initialized so far.
|
||||
hbarmor.player_active = {}
|
||||
|
||||
-- HUD item ids
|
||||
local armor_hud = {}
|
||||
|
||||
-- Time difference in seconds between updates to the HUD armor bar.
|
||||
-- Increase this number for slow servers.
|
||||
hbarmor.tick = 0.1
|
||||
|
||||
-- If true, the armor bar is hidden when the player does not wear any armor
|
||||
hbarmor.autohide = true
|
||||
|
||||
--load custom settings
|
||||
local set = io.open(minetest.get_modpath("hbarmor").."/hbarmor.conf", "r")
|
||||
if set then
|
||||
dofile(minetest.get_modpath("hbarmor").."/hbarmor.conf")
|
||||
set:close()
|
||||
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
|
||||
@ -32,7 +43,7 @@ end
|
||||
local function custom_hud(player)
|
||||
local name = player:get_player_name()
|
||||
|
||||
if minetest.setting_getbool("enable_damage") then
|
||||
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!")
|
||||
@ -50,15 +61,41 @@ local function custom_hud(player)
|
||||
end
|
||||
|
||||
--register and define armor HUD bar
|
||||
hb.register_hudbar("armor", 0xFFFFFF, "Armor", { icon = "hbarmor_icon.png", bgicon = "hbarmor_bgicon.png", bar = "hbarmor_bar.png" }, 0, 100, hbarmor.autohide, "%s: %d%%")
|
||||
hb.register_hudbar("armor", 0xFFFFFF, S("Armor"), { icon = "hbarmor_icon.png", bgicon = "hbarmor_bgicon.png", bar = "hbarmor_bar.png" }, 0, 100, hbarmor.autohide, N("@1: @2%"), { order = { "label", "value" }, textdomain = "hbarmor" } )
|
||||
|
||||
dofile(minetest.get_modpath("hbarmor").."/armor.lua")
|
||||
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
|
||||
--armor
|
||||
local arm = tonumber(hbarmor.armor[name])
|
||||
if not arm then
|
||||
arm = 0
|
||||
@ -94,7 +131,7 @@ minetest.register_globalstep(function(dtime)
|
||||
main_timer = main_timer + dtime
|
||||
timer = timer + dtime
|
||||
if main_timer > hbarmor.tick or timer > 4 then
|
||||
if minetest.setting_getbool("enable_damage") 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()
|
||||
|
3
locale/hbarmor.de.tr
Normal file
@ -0,0 +1,3 @@
|
||||
# textdomain:hbarmor
|
||||
Armor=Panzerung
|
||||
@1: @2%=@1: @2%
|
2
locale/hbarmor.fr.tr
Normal file
@ -0,0 +1,2 @@
|
||||
# textdomain:hbarmor
|
||||
Armor=Armure
|
3
locale/hbarmor.it.tr
Normal file
@ -0,0 +1,3 @@
|
||||
# textdomain:hbarmor
|
||||
Armor=Armatura
|
||||
@1: @2%=@1:@2%
|
5
locale/template.txt
Normal file
@ -0,0 +1,5 @@
|
||||
# textdomain:hbarmor
|
||||
Armor=
|
||||
|
||||
# Format string for displaying the armor. E.g. "Armor: 100%"
|
||||
@1: @2%=
|
3
mod.conf
Normal file
@ -0,0 +1,3 @@
|
||||
name = hbarmor
|
||||
description = Adds a HUD bar displaying the current damage of the player's armor.
|
||||
depends = hudbars, 3d_armor
|
BIN
screenshot.png
Normal file
After Width: | Height: | Size: 11 KiB |
7
settingtypes.txt
Normal file
@ -0,0 +1,7 @@
|
||||
#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 true
|
||||
|
||||
#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.1 0.0 4.0
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 70 B |
Before Width: | Height: | Size: 424 B After Width: | Height: | Size: 369 B |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 361 B |