expose hp_max and breath_max from api due older engines, update info
* update README and API information about this fork
This commit is contained in:
parent
0edeb5599e
commit
c435ee31b3
7
API.md
7
API.md
@ -8,6 +8,8 @@ This API allows you to add, change, hide and unhide custom HUD bars for this mod
|
||||
To give you a *very* brief overview over this API, here is the basic workflow on how to add your own custom HUD bar:
|
||||
|
||||
* Create images for your HUD bar
|
||||
* Optionally, set `hb.hp_max` to customize maximun healt of player, implementing lua minetest api
|
||||
* Optional, set `hb.breath_max` to customize maximun players breath, implementing lua minetest api
|
||||
* Call `hb.register_hudbar` to make the definition of the HUD bar known to this mod
|
||||
* Call `hb.init_hudbar` for each player for which you want to use previously defined HUD bar
|
||||
* Use `hb.change_hudbar` whenever you need to change the values of a HUD bar of a certain player
|
||||
@ -92,8 +94,11 @@ explicitly initialized on a per-player basis.
|
||||
|
||||
You probably want to do this in the `minetest.register_on_joinplayer`.
|
||||
|
||||
Take into consideration there's a rare bug on minetest engine that into this callback,
|
||||
sometimes that call its lazy and do not executed well. In such case just recall again only one time.
|
||||
|
||||
### `hb.init_hudbar(player, identifier, start_value, start_max, start_hidden)`
|
||||
This function initialzes and activates a previously registered HUD bar and assigns it to a
|
||||
This function initializes and activates a previously registered HUD bar and assigns it to a
|
||||
certain client/player. This has only to be done once per player and after that, you can change
|
||||
the values using `hb.change_hudbar`.
|
||||
|
||||
|
12
README.md
12
README.md
@ -13,7 +13,7 @@ this mod will place them accordingly.
|
||||
|
||||
![](screenshot.png)
|
||||
|
||||
## TEchnical info
|
||||
## Technical info
|
||||
-----------------
|
||||
|
||||
> **Warning** Keep in mind if running a server with this mod,
|
||||
@ -21,14 +21,16 @@ that the custom position should be displayed correctly on every screen size.
|
||||
|
||||
#### Dependencies
|
||||
|
||||
There's no depends
|
||||
There's no depends, older engines just need intlib but its optional
|
||||
|
||||
#### Current version
|
||||
|
||||
The current version is 2.3.4.0 its a plus fork from original cos current
|
||||
The current version is 2.3.4.1 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.
|
||||
This fork feaured real honoring to max healt and max breath and customization of, also:
|
||||
|
||||
It works for Minetest 0.4.17+ (maybe 0.4.16 too) or later, including lastest crap from 5.7+.
|
||||
|
||||
#### Settings
|
||||
|
||||
@ -37,6 +39,8 @@ Use the advanced settings menu in Minetest for detailed configuration.
|
||||
|
||||
| configuration name | Description | type | values, min/default/max |
|
||||
| ---------------------------- | ------------------------------------- | ---- | ------------------------ |
|
||||
| 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 |
|
||||
| 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 |
|
||||
|
@ -50,8 +50,7 @@ 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)
|
||||
|
||||
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
|
||||
-- expose direct api
|
||||
hb.hp_max = hb.settings.hp_player_maximun
|
||||
hb.breath_max = hb.settings.br_player_maximun
|
||||
|
||||
|
7
init.lua
7
init.lua
@ -76,7 +76,7 @@ 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.19") and not string.find(statusinfo,"0.4.18") and not string.find(statusinfo,"0.4.17.4") then
|
||||
hb.settings.hp_player_maximun = 20
|
||||
hb.settings.br_player_maximun = 10
|
||||
if player_exists(player) then
|
||||
@ -312,8 +312,7 @@ function hb.register_hudbar(identifier, text_color, label, textures, default_sta
|
||||
state.text = text
|
||||
state.barlength = hb.value_to_barlength(start_value, start_max)
|
||||
|
||||
local main_error_text =
|
||||
"[hudbars] Bad initial values of HUD bar identifier “"..tostring(identifier).."” for player "..name..". "
|
||||
local main_error_text = "[hudbars] Bad initial values of HUD bar identifier “"..tostring(identifier).."” for player "..name..". "
|
||||
|
||||
if start_max < start_value then
|
||||
minetest.log("error", main_error_text.."start_max ("..start_max..") is smaller than start_value ("..start_value..")!")
|
||||
@ -546,7 +545,7 @@ local function custom_hud(player)
|
||||
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
|
||||
-- real honoring to configuration of max hp custom heal and breath from others mod
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user