[Mod] HUD Bars [2.3.5] [hudbars]

User avatar
Wuzzy
Member
Posts: 4780
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Release 1.2.0

by Wuzzy » Post

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.png

Example screenshot of manually moved position in stack_down mode (updates for other mods using [hudbars] are to follow):
https://i.imgur.com/Vq9p5z2.png

Read README.txt to learn more about all the new settings.

User avatar
GunshipPenguin
Member
Posts: 94
Joined: Tue Jan 28, 2014 00:38
GitHub: GunshipPenguin
IRC: GunshipPenguin
In-game: GunshipPenguin
Location: Vancouver, BC

Re: [Mod] HUD bars [1.2.0] [hudbars]

by GunshipPenguin » Post

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:

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:

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.

User avatar
Wuzzy
Member
Posts: 4780
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: [Mod] HUD bars [1.2.0] [hudbars]

by Wuzzy » Post

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.

User avatar
mahmutelmas06
Member
Posts: 367
Joined: Mon Mar 02, 2015 13:10
GitHub: mahmutelmas06
IRC: mahmutelmas06
In-game: masum

Re: [Mod] HUD bars [1.2.0] [hudbars]

by mahmutelmas06 » Post

Addind classic hudbar option is nice. I prefer old style.
My Mods:

Beverage

prestidigitator
Member
Posts: 647
Joined: Thu Feb 21, 2013 23:54

Re: [Mod] HUD bars [1.2.0] [hudbars]

by prestidigitator » Post

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....

User avatar
GunshipPenguin
Member
Posts: 94
Joined: Tue Jan 28, 2014 00:38
GitHub: GunshipPenguin
IRC: GunshipPenguin
In-game: GunshipPenguin
Location: Vancouver, BC

Re: [Mod] HUD bars [1.2.0] [hudbars]

by GunshipPenguin » Post

Wuzzy wrote: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.
Ok, after much experimenting, I've managed to reproduce this bug on a test server. The test server was running minetest 0.4.12 stable, with my fork of hungry_games, and no mods besides the ones in hungry_games.

The problem seems to arise when a player joins while the countdown to the match is ongoing. You can recreate this yourself, connect 2 clients to a server and make both of them vote to begin, then while the countdown is going on, connect another client to the server, the server crashes 100% of the time on my machine, with the following error:

Code: Select all

21:38:42: ERROR[main]: ServerError: ...4.12/bin/../games/hungry_games/mods/hudbars/init.lua:359: attempt to index field '?' (a nil value)
21:38:42: ERROR[main]: stack traceback:
21:38:42: ERROR[main]: 	...4.12/bin/../games/hungry_games/mods/hudbars/init.lua:359: in function 'hide_hudbar'
21:38:42: ERROR[main]: 	...4.12/bin/../games/hungry_games/mods/hudbars/init.lua:438: in function 'update_hud'
21:38:42: ERROR[main]: 	...4.12/bin/../games/hungry_games/mods/hudbars/init.lua:470: in function '?'
21:38:42: ERROR[main]: 	...top/minetest-0.4.12/bin/../builtin/game/register.lua:341: in function <...top/minetest-0.4.12/bin/../builtin/game/register.lua:329>
Another thing I've noticed, is that the player joining during the countdown has a hunger and thirst hudbar, but no health hudbar.

The fact that this bug seemed to arise about 50% of the time on my hungry_games server would make sense, as there were people joining and leaving the server quite often, and statistically, it's likely that somebody would join during the 10 second countdown to the match start.

User avatar
Wuzzy
Member
Posts: 4780
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Bugfix release: 1.2.1

by Wuzzy » Post

I have found the bug!

The bug was caused by Hungry Games changing enable_damage. HUD bars 1.2.0 is totally not prepared for enable_damage to be changed in mid-game. If you start the server with damage disabled, the default HUD bars won't initialize on the assumption that they are not needed anyways. But when enable_damage gets turned on, the script suddenly tries to update the breath and health HUD bars, which of course don't exist. Therefore the crash.

I just released version 1.2.1, which fixes said bug. This version should not crash anymore when you change enable_damage in mid-game, it also updates the HUD when this happens.
I am not 100% sure how reliable this will go on your sever, and I am personally not really happy with the fix for now, but it seems to work fine. Maybe I will release another patch release which solves the enable_damage switching problematic more sanely.


Thanks for the help, it was really needed here.

User avatar
TenPlus1
Member
Posts: 3700
Joined: Mon Jul 29, 2013 13:38
In-game: TenPlus1
Contact:

Re: [Mod] HUD bars [1.2.1] [hudbars]

by TenPlus1 » Post

Would it be possible to add your hudbars, hbhunger and related mods to github so mod makers can post changes and fixes to your code more easily.

User avatar
Wuzzy
Member
Posts: 4780
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: [Mod] HUD bars [1.2.1] [hudbars]

by Wuzzy » Post

Yes, of course. But I am not going to do it. I have published a Git repository already:
http://repo.or.cz/w/minetest_hudbars.git

Feel free to copy it and post it on GitHub yourselves. If you want to have some changes upstream, just clone my repo do the changes and publish your modified version on any public repository, then write a post here and point to the relevant branch or commits. If I have time, motivation and like the changes, I'll include them.

User avatar
TenPlus1
Member
Posts: 3700
Joined: Mon Jul 29, 2013 13:38
In-game: TenPlus1
Contact:

Re: [Mod] HUD bars [1.2.1] [hudbars]

by TenPlus1 » Post

No probs, uploaded to my own git for testing :)

https://github.com/tenplus1/hudbars
Last edited by TenPlus1 on Fri Jul 22, 2016 19:01, edited 1 time in total.

User avatar
pinkysnow
Member
Posts: 91
Joined: Sat Sep 26, 2015 01:58
GitHub: pinkysnowman

Re: [Mod] HUD bars [1.2.1] [hudbars]

by pinkysnow » Post

there needs to be a way to set the position of each bar to whatever you want seperatly of any other bar

User avatar
Wuzzy
Member
Posts: 4780
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: [Mod] HUD bars [1.2.1] [hudbars]

by Wuzzy » Post

pinkysnow wrote:there needs to be a way to set the position of each bar to whatever you want seperatly of any other bar
Uh, why? Honestly, I wanted to avoid this kind of “micromanagement” and wanted to keep my mod as simple as possible. But I may be more likely to be convinced if you can give me a concrete use case for your feature request.

But currently, I am not in my Minetest phase, so things can take a while.

drkwv
Member
Posts: 102
Joined: Thu Jun 28, 2012 13:48
GitHub: aa6

Re: [Mod] HUD bars [1.2.1] [hudbars]

by drkwv » Post

Hi, Wuzzy.
Could you please add an ability to change hud icon, bar icon and text color for a player? I've made a wadsprint mod and have trouble integrating it with hudbars because the mod should change an icon from `off` to `on` state while sprinting but that isn't an option in the hudbars API.

User avatar
Wuzzy
Member
Posts: 4780
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: [Mod] HUD bars [1.2.1] [hudbars]

by Wuzzy » Post

This is a good idea. In fact, I had a similar idea much earlier, but I never got around to actually implement it.
First I need to think how exactly I should implement such a feature to make it useful for a wide audience, not just a single mod. ;-) But that should not be too hard.

I'll put it on the to-do list, but no promises are made.

What do you mean, you have trouble integrating? Doesn't it work at all or don't you just like the final result because that feature is missing?

drkwv
Member
Posts: 102
Joined: Thu Jun 28, 2012 13:48
GitHub: aa6

Re: [Mod] HUD bars [1.2.1] [hudbars]

by drkwv » Post

Just the feature is missing. Everything else works nice and the API is good and consistent.

User avatar
Wuzzy
Member
Posts: 4780
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Version 1.3.0

by Wuzzy » Post

Version 1.3.0 is released!

Changes:
- Make all settings avaialbe in Minetest's new advanced settings menu
- Fix HUD bars overlapping (basically breaking the HUD) when both hudbars_tick and hudbars_vmargin were set
- Use Markdown syntax in readme file
- Fix some factual mistakes in readme file
- Add metadata: mod.conf, description.txt, screenshot.png

Sorry, no possibility to change images on-the-fly yet. Maybe later. :-/

User avatar
Wuzzy
Member
Posts: 4780
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Version 1.4.0

by Wuzzy » Post

Version 1.4.0 released!

I have implemented the suggestion of drkwv!

Now the API allows you to change the appearance (images and text) of a HUD bar after it has been registered. This is done by extending the function hb.change_hudbar.

Specifically, you can change the following values:
- icon
- background icon for the “modern statbar” mode
- bar segment image
- text label
- text color

So, basically almost everything. :-)

drkwv
Member
Posts: 102
Joined: Thu Jun 28, 2012 13:48
GitHub: aa6

Re: [Mod] HUD bars [1.4.0] [hudbars]

by drkwv » Post

Thank you! Will try it as soon as possible.

drkwv
Member
Posts: 102
Joined: Thu Jun 28, 2012 13:48
GitHub: aa6

Re: [Mod] HUD bars [1.4.0] [hudbars]

by drkwv » Post

I've updated minetest_wadsprint to be compatible with new hudbars API but it works only if I comment the lines in hb.change_hudbar:

Code: Select all

	-- if new_value == nil and new_max_value == nil then
	-- 	return
	-- end
That's because my code changes only icon and bar image. Please fix. :)

User avatar
Wuzzy
Member
Posts: 4780
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Bugfix release 1.4.1.

by Wuzzy » Post

Oops! Thanks for reporting the bug. This was obviuosly an embarrassing oversight by me. ;-)

I just now released version 1.4.1.
This version fixes the aforementioned bug that hb.change_hudbar is a no-op if new_value and new_max_value were both nil. In 1.4.0 it was not possible to update a HUD bar if you only want to change its appearance but not the value. That's all!

If there are still problems, report them.

Martno
Member
Posts: 80
Joined: Thu May 28, 2015 07:09
Location: Hungary

Re: [Mod] HUD bars [1.4.1] [hudbars]

by Martno » Post

Is it possible to make the hud bars changing their size according to the gui_scaling setting, or the font size?
I always make fonts bigger because they are too small on my screen (1680x1050). But the hud bars are too small (they are good on a 15" laptop screen, but on bigger resolution monitors, they are small), and if I change the gui_scaling or font size, this problem occurs:
Image
Attachments
gui-scalingHUD.png
gui-scalingHUD.png (29.08 KiB) Viewed 1251 times

User avatar
Wuzzy
Member
Posts: 4780
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: [Mod] HUD bars [1.4.1] [hudbars]

by Wuzzy » Post

I fear the answer is “No.”. I can only scale some particular HUD elements with screen size, but not all. Especially the colored part of the progress bar is not scalable since the HUD API of Minetest is simply too weak for now. Well, I can scale it, but only with absolute numbers, not along with screen size.
If I would know of some way to scale the HUD elements properly, I would probably have done it already.

And with fonts it's even worse. Minetest has zero support for custom font sizes and mods can't handle it in any way.

Which means the HUD Bars as of now have to be fixed-size, sadly.

If someone finds a workaround to sacle ALL HUD elements, that would help a lot. But IMO the real problem lies in Minetest's incomplete HUD element API.

What I COULD do would be to increase the size of everything manually. That would still be fixed size but hopefully it's more managable.
But I fear there is not a single good solution to your problem at the moment. :-(

Martno
Member
Posts: 80
Joined: Thu May 28, 2015 07:09
Location: Hungary

Re: [Mod] HUD bars [1.4.1] [hudbars]

by Martno » Post

Ok, thanks for the answer.
If you increase the size a bit (not too big for lower resolution screens) I think that would be good enough.

User avatar
BrunoMine
Member
Posts: 1082
Joined: Thu Apr 25, 2013 17:29
GitHub: BrunoMine
Location: SP-Brasil
Contact:

Re: [Mod] HUD bars [1.4.1] [hudbars]

by BrunoMine » Post

I liked this work. I want to help, but the repository looks confused. Is there a nicer interface to contribute?

User avatar
Wuzzy
Member
Posts: 4780
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: [Mod] HUD bars [1.4.1] [hudbars]

by Wuzzy » Post

With what do you want to help?
Repositories don't need any interface to contribute. My hoster just happens to have a HTML interface.

If you are looking for the git clone URL, use this one:
http://repo.or.cz/minetest_hudbars.git
(yes, this is both the HTML page and the actual repository clone URL)

Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests