mirror of
https://github.com/minetest-mods/hbsprint.git
synced 2025-07-04 09:20:43 +02:00
Compare commits
1 Commits
master
...
nalc-1.2.0
Author | SHA1 | Date | |
---|---|---|---|
afd3680984 |
11
.github/workflows/build.yml
vendored
11
.github/workflows/build.yml
vendored
@ -1,11 +0,0 @@
|
||||
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
19
.luacheckrc
@ -1,19 +0,0 @@
|
||||
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"
|
||||
}
|
25
init.lua
25
init.lua
@ -130,8 +130,8 @@ local function is_walkable(ground)
|
||||
end
|
||||
|
||||
local function create_particles(player, name, ground)
|
||||
local def = minetest.registered_nodes[ground.name] or {}
|
||||
local tile = def.tiles and def.tiles[1] or def.inventory_image
|
||||
local def = minetest.registered_nodes[ground.name]
|
||||
local tile = def.tiles[1] or def.inventory_image
|
||||
if type(tile) == "table" then
|
||||
tile = tile.name
|
||||
end
|
||||
@ -182,16 +182,17 @@ end)
|
||||
|
||||
local function sprint_step(player, dtime)
|
||||
local name = player:get_player_name()
|
||||
local fast = minetest.get_player_privs(name).fast
|
||||
|
||||
if not fast then
|
||||
if minetest.get_player_privs(name).fast then
|
||||
return
|
||||
end
|
||||
|
||||
if stamina then
|
||||
stamina_timer[name] = (stamina_timer[name] or 0) + dtime
|
||||
end
|
||||
if breath then
|
||||
breath_timer[name] = (breath_timer[name] or 0) + dtime
|
||||
end
|
||||
end
|
||||
|
||||
local ctrl = player:get_player_control()
|
||||
local key_press
|
||||
@ -203,7 +204,7 @@ local function sprint_step(player, dtime)
|
||||
|
||||
if not key_press then
|
||||
stop_sprint(player)
|
||||
if stamina and not fast and stamina_timer[name] >= replenish then
|
||||
if stamina and stamina_timer[name] >= replenish then
|
||||
replenish_stamina(player)
|
||||
stamina_timer[name] = 0
|
||||
end
|
||||
@ -234,15 +235,15 @@ local function sprint_step(player, dtime)
|
||||
hunger = hunger_ng.get_hunger_information(name).hunger.exact
|
||||
end
|
||||
|
||||
if (player_stamina > 0 and hunger > starve_limit and ground) or fast then
|
||||
if player_stamina > 0 and hunger > starve_limit and ground then
|
||||
start_sprint(player)
|
||||
if stamina and not fast then drain_stamina(player) end
|
||||
if starve and not fast then drain_hunger(player, name) end
|
||||
if breath and not fast and breath_timer[name] >= 2 then
|
||||
if stamina then drain_stamina(player) end
|
||||
if starve then drain_hunger(player, name) end
|
||||
if breath and breath_timer[name] >= 2 then
|
||||
drain_breath(player)
|
||||
breath_timer[name] = 0
|
||||
end
|
||||
if particles and ground then
|
||||
if particles then
|
||||
create_particles(player, name, ground)
|
||||
end
|
||||
else
|
||||
@ -259,3 +260,5 @@ minetest.register_globalstep(function(dtime)
|
||||
sprint_timer = 0
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.log("action", "[hbsprint] loaded.")
|
||||
|
Reference in New Issue
Block a user