mirror of
https://github.com/minetest-mods/gauges.git
synced 2025-07-26 20:10:18 +02:00
Compare commits
8 Commits
master
...
b7051168f1
Author | SHA1 | Date | |
---|---|---|---|
b7051168f1 | |||
3b2552d655 | |||
cdbbff71de | |||
1d6848bc9c | |||
5e76ccfa78 | |||
e1cae85e42 | |||
e1534c2139 | |||
d5f2404ddd |
20
.github/workflows/build.yml
vendored
20
.github/workflows/build.yml
vendored
@ -1,20 +0,0 @@
|
|||||||
name: build
|
|
||||||
on: [push, pull_request]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
luacheck:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
sudo apt-get update -qq
|
|
||||||
sudo apt-get install -qqq luarocks
|
|
||||||
- name: Install LuaCheck and pre-commit
|
|
||||||
run: |
|
|
||||||
pip3 install pre-commit
|
|
||||||
luarocks install --local luacheck
|
|
||||||
- name: Run LuaCheck with pre-commit
|
|
||||||
run: |
|
|
||||||
export PATH="$HOME/.luarocks/bin:$PATH"
|
|
||||||
pre-commit run --all-files
|
|
16
.travis.yml
Normal file
16
.travis.yml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
dist: bionic
|
||||||
|
language: python
|
||||||
|
|
||||||
|
python:
|
||||||
|
- 3.7.1
|
||||||
|
|
||||||
|
install:
|
||||||
|
- sudo apt-get update -qq
|
||||||
|
- sudo apt-get install -qqq luarocks
|
||||||
|
- pip3 install pre-commit
|
||||||
|
- luarocks install --local luacheck
|
||||||
|
|
||||||
|
script:
|
||||||
|
# All linters are run with pre-commit hooks
|
||||||
|
- export PATH="$HOME/.luarocks/bin:$PATH"
|
||||||
|
- pre-commit run --all-files
|
11
init.lua
11
init.lua
@ -3,10 +3,6 @@
|
|||||||
-- Copyright © 2014-2020 4aiman, Hugo Locurcio and contributors - MIT License
|
-- Copyright © 2014-2020 4aiman, Hugo Locurcio and contributors - MIT License
|
||||||
-- See `LICENSE.md` included in the source distribution for details.
|
-- 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
|
local enabled = minetest.settings:get_bool("health_bars") ~= false
|
||||||
if enabled then
|
if enabled then
|
||||||
enabled = minetest.settings:get_bool("enable_damage")
|
enabled = minetest.settings:get_bool("enable_damage")
|
||||||
@ -35,13 +31,12 @@ local function add_gauge(player)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- credit:
|
-- credit: https://github.com/minetest/minetest/blob/6de8d77e17017cd5cc7b065d42566b6b1cd076cc/builtin/game/statbars.lua#L30-L37
|
||||||
-- https://github.com/minetest/minetest/blob/master/builtin/game/statbars.lua#L31-L37
|
|
||||||
local function scaleToDefault(player, field)
|
local function scaleToDefault(player, field)
|
||||||
-- Scale "hp" or "breath" to supported amount
|
-- Scale "hp" or "breath" to supported amount
|
||||||
local current = player["get_" .. field](player)
|
local current = player["get_" .. field](player)
|
||||||
local max_display = math.max(player:get_properties()[field .. "_max"], current)
|
local max_display = math.max(player:get_properties()[field .. "_max"], current)
|
||||||
return round(current / max_display * max[field])
|
return math.round(current / max_display * max[field])
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_entity("gauges:hp_bar", {
|
minetest.register_entity("gauges:hp_bar", {
|
||||||
@ -95,3 +90,5 @@ if enabled then
|
|||||||
minetest.after(1, add_gauge, player)
|
minetest.after(1, add_gauge, player)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.log("action", "[gauges] loaded.")
|
||||||
|
Reference in New Issue
Block a user