Compare commits

1 Commits

Author SHA1 Message Date
92a1e0cddb Add LuaCheck and GitHub workflow (#32) 2023-01-15 14:17:54 +01:00
3 changed files with 36 additions and 11 deletions

11
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,11 @@
on: [push, pull_request]
name: build
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: lint
uses: Roang-zero1/factorio-mod-luacheck@master
with:
luacheckrc_url: ""

19
.luacheckrc Normal file
View File

@ -0,0 +1,19 @@
allow_defined_top = true
unused_args = false
max_line_length = false
read_globals = {
string = {fields = {"split", "trim"}},
table = {fields = {"copy", "getn"}},
"player_monoids",
"playerphysics",
"hb",
"vector",
"hunger_ng",
}
globals = {
"minetest",
"hbhunger"
}

View File

@ -84,28 +84,25 @@ local function drain_stamina(player)
player:get_meta():set_float("hbsprint:stamina", player_stamina)
end
if mod_hudbars then
if autohide and
player_stamina < hb.get_hudtable("stamina").hudstate[player:get_player_name()].max
then hb.unhide_hudbar(player, "stamina") end
if autohide and player_stamina < 20 then hb.unhide_hudbar(player, "stamina") end
hb.change_hudbar(player, "stamina", player_stamina)
end
end
local function replenish_stamina(player)
local player_stamina = player:get_meta():get_float("hbsprint:stamina")
local max_stamina = hb.get_hudtable("stamina").hudstate[player:get_player_name()].max
local player_stamina = player:get_meta():get_float("hbsprint:stamina")
local ctrl = player:get_player_control()
if player_stamina < max_stamina and not ctrl.jump then
if player_stamina < 20 and not ctrl.jump then
if not ctrl.right and not ctrl.left and not ctrl.down and not ctrl.up and not ctrl.LMB and not ctrl.RMB then
player_stamina = math.min(max_stamina, player_stamina + standing)
player_stamina = math.min(20, player_stamina + standing)
else
player_stamina = math.min(max_stamina, player_stamina + stamina_heal)
player_stamina = math.min(20, player_stamina + stamina_heal)
end
player:get_meta():set_float("hbsprint:stamina", player_stamina)
end
if mod_hudbars then
hb.change_hudbar(player, "stamina", player_stamina)
if autohide and player_stamina >= max_stamina then hb.hide_hudbar(player, "stamina") end
if autohide and player_stamina >= 20 then hb.hide_hudbar(player, "stamina") end
end
end
@ -262,5 +259,3 @@ minetest.register_globalstep(function(dtime)
sprint_timer = 0
end
end)
minetest.log("action", "[hbsprint] loaded.")