Page 1 of 4
[Mod] HUD bars [1.7.1] [hudbars]

Posted:
Thu Feb 05, 2015 15:07
by Wuzzy
This mod replaces the builtin health and breath indicators by nice little “progress bars” which show an icon, a label and a numerical value plus maximum.Plus, the mod is extensible with a quite powerful API.
Breath and health bar:

Example with some extra HUD bars added via the API:

(Customized hotbar
not included!)
Both bars behave similar to the builtin ones, so the breath bar will be hidden automatically if you have full breath. This auto-hide feature can be disabled (use the advanced settings menu).
Classic statbars and “
Better HUD”-style statbars are supported, too:
For modders: The mod can also be extended by custom HUD bars. You can customize the label, font color, bar color. All bars have to show a current value and a maximum value and both must be at least 0.
Currently, custom HUD bars will be automatically placed by the mod.
So, with this mod you could easily add custom player attributes and whatnot to the HUD without much trouble.
It is a fork of the “Better HUD” [hud] mod by BlockMen, but with all the stuff which I consider clutter removed, so no hunger, armor support, or modifications of other HUD elements. Just the bars. This should make it easier to integrate this mod with other mods without much hassle.
I consider this mod finished and usable now and its API stable. But backwards-compatible feature requests and bug reports are still welcome, possibly even if this thread has become old.
Version: 1.7.1 (This mod uses
semantic versioning, as of 2.0.0 of the standard)
Works with: Minetest 0.4.12 and later
Project page with Git repository:
http://repo.or.cz/w/minetest_hudbars.gitDownload: See attachment.
Translations (when using intllib): German, Portuguese.
Dependencies:
None!Optional dependency:
Internationalization Library [intllib]License for code: WTFPL
License for images: Contains some CC BY-SA 3.0 images (see README), rest is WTFPL.
List of subgames using this mod:
List of mods using this mod:
This mod is
incompatible with:
Re: [Mod] HUD bars [0.1.0] [hudbars]

Posted:
Thu Feb 05, 2015 15:30
by srifqi
Looks nice!
/me is waiting for Mana mod!
Re: [Mod] HUD bars [0.1.0] [hudbars]

Posted:
Thu Feb 05, 2015 16:29
by Minetestforfun
great work again, your work is awesome !
Is it possible to tweak this mod because i want to have only the "progressive mana bar" and other bars with hearth/bread/bubles/etc... ? (for tests)
Re: [Mod] HUD bars [0.1.0] [hudbars]

Posted:
Thu Feb 05, 2015 16:33
by rubenwardy
Raw numbers makes sense when you don't show hearts or fractional hearts. Ie 19/20
Re: [Mod] HUD bars [0.1.0] [hudbars]

Posted:
Thu Feb 05, 2015 18:05
by ExeterDad
Looks really slick. Well done
Version 0.2.0 released

Posted:
Sun Feb 08, 2015 03:18
by Wuzzy
Hi! I released version 0.2.0 today.
Not much changed, but I added the API documentation, you can find it in API.md.
The codebase did not really change.
But the API will certainly be still subject to change, there are some real oddities in it. But feel free to look already now into it and give your comments.
There are also some other minor tweaks which are not worth mentioning, lol.
Version 0.3.0 released

Posted:
Tue Feb 10, 2015 01:47
by Wuzzy
I release version 0.3.0 today. I cleaned up the API, so it makes more sense and I got rid of some oddities it had.
Changelog:
- Rename main table from “hud” to “hb” (affects function names!)
- Arguments 3-4 in hb.change_hudbar can be nil for values which should not change
- Add proper function hb.init_hudbar, replaces odd call to hud.hudtables[identifier].add_all
- Update API documentation and fix mistakes
- Use “hudbars.conf” instead of “hud.conf” (configuration file)
One major thing I want to add to this are sane configuration variables. Currently, they are a bit chaotic. Lastly, I want to do a bit of refactoring before 1.0.0. Then final testing, and I could release 1.0.0.
I also want to you inform of a problem with this mod: Currently, it is unable to cope with different GUI scales. Do enough people care about such stuff? And is it really my duty to fix it or should I just wait for the engine to become better in this regard?
Version 0.4.0 released

Posted:
Thu Feb 12, 2015 05:25
by Wuzzy
I release 0.4.0 today. I have again worked hard on the API to make extension as painless as possible.
- New function: hb.get_hudbar_state to get information about the state of an active HUD bar, such as values, whether it is hidden, etc.
- hb.change_hudbar has been optimized to call hud_change fewer times, which is hopefully good for networking
- Rename hb.register_hudbar parameter “start_hide” to “start_hidden”
- start_hidden parameter now finally works
- Do not affect other HUD flags (crosshair, wielditem, etc.) when starting mod
- Show error message when trying to call hb.init_hudbar or hb.change_hudbar with bad values
- Update documentation
- Lots of refactoring
- Health and breath bar now use API, this makes the code much much cleaner
Download in first post.
I also finally uploaded the Git repository, here is the project page:
http://repo.or.cz/w/minetest_hudbars.gitThere is probably not much left to do for the 1.0.0. If you want to have certain API functions added, please tell me now before I release 1.0.0. I am now pretty happy with the API as of now.
I will probably only make just some final testing, add some smaller features, then, if nothing serious pops up, I will release 1.0.0.
Also, any testing of this mod, especially the API, will be greatly appreciated! If you don't understand something, ask here right away, I will try to help. :-)
Edit: I uploaded a new screenshot on the first post to show what is possible with the API.
Version 1.0.0 released!

Posted:
Thu Feb 12, 2015 21:17
by Wuzzy
Finally!
Version 1.0.0 is there.
The changelog is rather small this time:
- Add new parameter start_hidden to hb.init_hudbar, specified whether HUD bar is hidden on start
- Copy-editing of API.md and README.txt
- Internal: Fix add_all weirdness
The download is as always in the attachment of the first post.
From version 1.0.0, I try to ensure backwards-compability as long as possible and only break it when it I think it is really neccessary. Hopefully never. I consider the API to be fairly stable and usable now. When backwards compatibility is broken, the major version number will be increased, since this is a SemVer.
But it is still not too late to make feature requests or report bugs, but from now on, requests for features which are backwards-compatible are highly preferred over requests for features which are not backwards-compatible.
Bugfix release: 1.0.1

Posted:
Sat Feb 21, 2015 16:27
by Wuzzy
Version 1.0.1 is here to fix a nasty race condition bug which caused the server to crash on some systems.
Download is in the first post, as always.
Re: [Mod] HUD bars [1.0.1] [hudbars]

Posted:
Sun Feb 22, 2015 21:18
by SpaghettiToastBook
If you connect to a server with this mod more than once, the hotbar, crosshairs, and hand don't appear anymore.
Bugfix release: 1.0.2

Posted:
Mon Feb 23, 2015 00:44
by Wuzzy
Version 1.0.2 is here to fix 2 embarrisingly stupid bugs:
- Fix HUD elements like crosshair, hotbar and wielded item disappearing for rejoining players (Bug reported by SpaghettiToastBook, thanks for reporting!)
- Remove pointless delays for initializing the HUD for new or rejoining players. The HUD should be now correctly displayed immediately after joining
Re: [Mod] HUD bars [1.0.2] [hudbars]

Posted:
Fri Feb 27, 2015 07:53
by Wuzzy
Is it possible to tweak this mod because i want to have only the "progressive mana bar" and other bars with hearth/bread/bubles/etc... ? (for tests)
Sorry, I have missed this question, I shall answer it now:
Well, it is always possible to tweak if you mean with “tweak” to actually edit source code.
But it is not done by changing a single varible.
Currently, this mod forces the health and breath to be shown as HUD bars, this is hardcoded.
Everything else (like the mana bar) is provided by seperate mods.
Maybe I can edit this mod in such a way that it allows for different “bar styles”, for example, the classical icon-based statbars.
But I am just not motivated for that.
Personally, I do not think it is a good idea from an usability standpoint if you mix the classical icon-based statbars with the progress-bar-like bars.
Also, I think the icon-based approach is flawed in many aspects:
- Icon bars fail badly if you need large values, they can only give you a very coarse estimate
- For example, the hunger bar from the Better HUD mod is ambigious when it shows 10 breads: It means your saturation is between 20 and 30. The last 5 breads are hidden so that all icon bars show never more than 10 symbols. IMO this is just stupid, I did not even know about this until I started to create [hbhunger]
- Icon bars also fail badly when numerical values are important, obviously
Especially when Minetest will allow to manually set the max health and breath of players, the standard icon-based approach will become really limiting (Would you now display 50 heart symbols for 100 HP?), but this mod will be perfectly prepared as soon as you can change these maximum values. It would only require a minor change in the source code.
PS, as for hunger, I have recently forked the “Better HUD” mod once again, ripped it apart which resulted in this mod adding the hunger game mechanic from Better HUD, but with using the HUD bars mod:
viewtopic.php?f=9&t=11336
Re: [Mod] HUD bars [1.0.2] [hudbars]

Posted:
Tue Mar 03, 2015 10:14
by Minetestforfun
Hi,
Thank you for your answer.
Today, I decided to change all of my status bars to your "progressive" status bars.
My main problem, it's my other mods...
I need your bar on health / stamina / mana / breath / hunger, and maybe, if it's possible, armor...
So, I suposed I need [hudbars] + [hbhunger], and i need to import from [hud] the hunger.lua (tweaked) and the hud.conf (tweaked), i also need to delete [hud]
Any advice ? Did I forget something ?
Re: [Mod] HUD bars [1.0.2] [hudbars]

Posted:
Tue Mar 03, 2015 13:57
by Wuzzy
Minetestforfun wrote:Hi,
Thank you for your answer.
Today, I decided to change all of my status bars to your "progressive" status bars.
My main problem, it's my other mods...
I need your bar on health / stamina / mana / breath / hunger, and maybe, if it's possible, armor...
So, I suposed I need [hudbars] + [hbhunger], and i need to import from [hud] the hunger.lua (tweaked) and the hud.conf (tweaked), i also need to delete [hud]
Any advice ? Did I forget something ?
Health, stamina, mana, breath, hunger and armor bars are provided when you enable these mods:
- [hudbars] (core API + health bar + breath bar)
- [stamina] (stamina bar)
- [mana] (mana bar)
- [hbhunger] (satiation bar)
- [hbarmor] (armor bar)
But then you
must disable:
Use either [hud] or [hudbars], but not both. Both together would simply just mess up the HUD and other unexpected / untested stuff.
If you use [hudbars] + [hbhunger] + [hbarmor], the original [hud] mod should be already be pretty well emulated (all 3 mods are forks of [hud]). Note that [hbhunger] and [hbarmor] are both a bit experimental.
There is really no point in trying to run both [hud] and [hudbars] at the same time.
So why would you want to import hunger.lua or anything else from [hud]? I don't understand what you are saying here.
[hbhunger] is not compatible with [hud] at all, you shouldn't “import” anything (whatever you meant by that). If you miss a particular feature in [hbhunger], make a feature request in the correct thread.
Also note that I have made a list of mods which use this mod in the first post of this thread.
Re: [Mod] HUD bars [1.0.2] [hudbars]

Posted:
Tue Mar 03, 2015 15:30
by cHyper
+1 awesome mod...
Re: [Mod] HUD bars [1.0.2] [hudbars]

Posted:
Tue Mar 03, 2015 18:59
by mahmutelmas06
Thank you for the mod its awesome.
Cant u provide intllib support to translate this mod to our languages ?
viewtopic.php?f=11&t=4929
Re: [Mod] HUD bars [1.0.2] [hudbars]

Posted:
Wed Mar 04, 2015 01:37
by Wuzzy
I could provide intllib support, yes.
At the moment, I am a bit lazy for stuff like this. I wait until Minetest has a sane mechanic for translating mods. See here:
https://github.com/minetest/minetest/issues/2270The problem with intllib is that it is server-side and forces the server's language to all clients.
Version 1.0.3 released.

Posted:
Wed Mar 04, 2015 03:48
by Wuzzy
Version 1.0.3 is released! This version has been adjusted for Minetest 0.4.12.
This version only changes the default position of the HUD bars, so that the HUD bars don't overlap with the hotbar. It should work out of the box for most subgames (including Minetest (the subgame)), but you can always configure the mod for different values if it is neccessary. See the readme file.
Re: [Mod] HUD bars [1.0.3] [hudbars]

Posted:
Wed Mar 04, 2015 17:50
by mahmutelmas06
Re: [Mod] HUD bars [1.0.3] [hudbars]

Posted:
Wed Mar 04, 2015 19:05
by Wuzzy
Nope. This is totally out of scope of this mod.
The scope of this mod is to provide HUD bars for health and breathing, plus an API for mods to build upon. This mod has nothing to do with hunger or eating.
You probably meant the [hbhunger] mod.
Re: [Mod] HUD bars [1.0.3] [hudbars]

Posted:
Thu Mar 12, 2015 19:52
by bdjnk
This is great. Really cleans up the HUD and clarifies your condition.
I've got no suggestions nor complaints. I just wanted to state my appreciation. Thanks :)
Re: [Mod] HUD bars [1.0.3] [hudbars]

Posted:
Sun Mar 22, 2015 20:15
by pilcrow
I like this mod. I just wish there was a setting to make the breath bar not disappear; I have a thing for symmetry, and would rather just see it all the time...
Release 1.1.0

Posted:
Mon Mar 23, 2015 17:49
by Wuzzy
Done. In version 1.1.0, which I just released, you have to add “hudbars_autohide_breath = false” into your minetest.conf to disable the automatic hiding of a full breath bar. By default, the breath bar is automatically hidden.
This setting is server-sided only for now. This may change if Minetest adds a sane way in the Lua API to interact with a player's client-side configuration. I could probably hack my own system in Lua, but I fear the codebase will become much more bloated, and this is undesirable for me for such a small feature.
Re: [Mod] HUD bars [1.1.0] [hudbars]

Posted:
Mon Mar 23, 2015 20:12
by pilcrow
Awesome, thanks! I am definitely gonna use this mod. It makes things look so much nicer! :)
Release 1.2.0

Posted:
Thu May 21, 2015 15:19
by Wuzzy
I have added a couple of new configuration options, which result in version 1.2.0.
Most notably, you can now manually sort the HUD bars, also, a classic statbar-style is now optionally supported (tell me what you think about it). Of course, the progress-bar like style is still supported and the default, so nothing changes if you don't change the settings. I suppose those settings are most useful for subgame hackers. :-)
Changelog:
- New setting: hudbars_sorting. You can now manually sort all the HUD bars. Useful if you don't like automatic order
- New setting: hudbars_bar_type. You now can change the appearance of the HUD bars.
- New HUD bar types, slightly experimental: Classic statbars and modern [hud]-style statbars (similar to BlockMen's Better HUD mod)
- New experimental/unfinished setting: hudbars_alignment_pattern: You can now make the HUD bars stack vertically instead of the current zig-zag pattern. Note you probably need to change source code to productively use this feature
- Various position-related HUD bar settings to change the base position of HUD bars (see README.txt)
- Remove hudbars.conf support and hudbars.conf.example (was never officially supported anyways)
Example screenshot of [hud]-style statbars:
https://i.imgur.com/ydN0G4g.pngExample screenshot of manually moved position in stack_down mode (updates for other mods using [hudbars] are to follow):
https://i.imgur.com/Vq9p5z2.pngRead README.txt to learn more about all the new settings.
Re: [Mod] HUD bars [1.2.0] [hudbars]

Posted:
Sun May 24, 2015 05:20
by GunshipPenguin
Hi Wuzzy,
I'm having an issue with hudbars on my hunger games server. Right after the countdown to start the game, the server crashes with this error:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
21:38:36: ERROR[main]: ERROR: An unhandled exception occurred: ...4.12/bin/../games/hungry_games/mods/hudbars/init.lua:359: attempt to index field '?' (a nil value)
21:38:36: ERROR[main]: stack traceback:
21:38:36: ERROR[main]: ...4.12/bin/../games/hungry_games/mods/hudbars/init.lua:359: in function 'hide_hudbar'
21:38:36: ERROR[main]: ...4.12/bin/../games/hungry_games/mods/hudbars/init.lua:438: in function 'update_hud'
21:38:36: ERROR[main]: ...4.12/bin/../games/hungry_games/mods/hudbars/init.lua:470: in function '?'
21:38:36: ERROR[main]: ...hys/minetest-0.4.12/bin/../builtin/game/register.lua:341: in function <...hys/minetest-0.4.12/bin/../builtin/game/register.lua:329>
In thread 7f3149fef740:
/home/rhys/minetest-0.4.12/src/main.cpp:882: int main(int, char**): Assertion '0' failed.
Debug stacks:
DEBUG STACK FOR THREAD 7f313ffff700:
#0 virtual void* CurlFetchThread::Thread()
DEBUG STACK FOR THREAD 7f3149fef740:
#0 int main(int, char**)
(Leftover data: #1 Dedicated server branch)
(Leftover data: #2 virtual void ServerMap::save(ModifiedState))
(Leftover data: #3 void ItemStack::serialize(std::ostream&) const)
Right before the game begins, I noticed that the following function is called, which I'm fairly sure has something to do with this as survival.reset_player_state() is a function from the survival modpack, which you modified in my hungry_games fork to make compatible with hudbars. This function is found in engine.lua in the hungry_games mod:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
local reset_player_state = function(player)
local name = player:get_player_name()
player:set_hp(20)
survival.reset_player_state(name, "hunger")
survival.reset_player_state(name, "thirst")
end
This happens about 50% of the time and makes the server almost unplayable at some points. I've uninstalled hudbars and reverted to an older version of the survival_modpack for now while I figure this out. Hoping you could lend me a hand.
Thanks for any help in advance.
Re: [Mod] HUD bars [1.2.0] [hudbars]

Posted:
Sun May 24, 2015 15:20
by Wuzzy
Hmm, this looks like a difficult bug for me. I have looked into the HUD bars mod but was unable to find anything suspicios. What seems to be clear to me is that, for some reason, the hb.hide_hudbars function somehow got a player which is nil, therefore the name is nil, and you can't use nil as a table index.
I also have looked into the Hungry Games mods, especially survival_modpack, but I have not spotted anything suspicious there, too.
I am not even sure which mod is actually responsible for the crash, but it seems to be more likely that HUD bars is responsible, judging from the stack trace. I can't explain it otherwise for now, unless the Hungry Games does some really nasty shit, like overwriting one of HUD bar's core tables. But I don't know yet. :-(
I am also not sure if the code you pointed to is actually responsible, because it does not touch anything near that weird player object, which is nil.
Could you give me more information of the crash? If you still have the log, more context would probably help me. Please give me more text of the debug.txt before the crash. The best thing for me would be a couple of logs for several server sessions, that is, server boots, then runs for a while until the crash.
Also, do you have information on how many players were on the server when it crashed?
Also, are you able to repoduce this crash on a local test server? If so, then please tell me how.
Sadly, I can't reproduce anything of this. Maybe this is a sort of bug which only happens when you use an online server with many players, but does not happen on local servers.
Re: [Mod] HUD bars [1.2.0] [hudbars]

Posted:
Sun May 24, 2015 19:07
by mahmutelmas06
Addind classic hudbar option is nice. I prefer old style.
Re: [Mod] HUD bars [1.2.0] [hudbars]

Posted:
Sun May 24, 2015 20:36
by prestidigitator
Question: Have you found anything that guarantees z-order? Seems like for the background and text there's very much an assumption that HUDs added later are drawn on top, but I've never seen anything that specifies this. That means any day there could easily be a minor ("backwards compatible") change in the engine (e.g. draw all HUDs of a particular type at once) and suddenly text couldn't be overlaid on top of bars, or might appear on top some of the time but not others. Troubling....