forked from minetest-mods/gauges
Compare commits
5 Commits
3b2552d655
...
master
Author | SHA1 | Date | |
---|---|---|---|
0341fe1ef9 | |||
b6cfb91717 | |||
b7051168f1 | |||
7c916f93a0 | |||
b08db516d5 |
@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Changed
|
||||
|
||||
- [Health and breath bars now adapt to custom maximum values instead of being hardcoded to 20 and 11 respectively.](https://github.com/minetest-mods/gauges/pull/9)
|
||||
|
||||
### Fixed
|
||||
|
||||
- [The health bar entity is no longer lost when a player teleports.](https://github.com/minetest-mods/gauges/pull/10)
|
||||
- A side effect is that health bar entities are no longer saved in map metadata.
|
||||
|
||||
## [1.0.4] - 2020-09-27
|
||||
|
||||
### Added
|
||||
|
7
init.lua
7
init.lua
@ -3,6 +3,10 @@
|
||||
-- Copyright © 2014-2020 4aiman, Hugo Locurcio and contributors - MIT License
|
||||
-- See `LICENSE.md` included in the source distribution for details.
|
||||
|
||||
local function round(v)
|
||||
return math.floor(v + 0.5)
|
||||
end
|
||||
|
||||
local enabled = minetest.settings:get_bool("health_bars") ~= false
|
||||
if enabled then
|
||||
enabled = minetest.settings:get_bool("enable_damage")
|
||||
@ -36,7 +40,7 @@ local function scaleToDefault(player, field)
|
||||
-- Scale "hp" or "breath" to supported amount
|
||||
local current = player["get_" .. field](player)
|
||||
local max_display = math.max(player:get_properties()[field .. "_max"], current)
|
||||
return math.round(current / max_display * max[field])
|
||||
return round(current / max_display * max[field])
|
||||
end
|
||||
|
||||
minetest.register_entity("gauges:hp_bar", {
|
||||
@ -45,6 +49,7 @@ minetest.register_entity("gauges:hp_bar", {
|
||||
textures = {"blank.png"},
|
||||
collisionbox = {0},
|
||||
physical = false,
|
||||
static_save = false,
|
||||
|
||||
on_step = function(self)
|
||||
local player = self.wielder
|
||||
|
Reference in New Issue
Block a user