mirror of
https://github.com/minetest-mods/hbsprint.git
synced 2024-08-19 04:24:10 +02:00
hunger_ng support
This commit is contained in:
parent
7ff4f434c0
commit
08ee8028f1
@ -1,3 +1,4 @@
|
|||||||
player_monoids?
|
player_monoids?
|
||||||
hudbars?
|
hudbars?
|
||||||
hbhunger?
|
hbhunger?
|
||||||
|
hunger_ng?
|
||||||
|
24
init.lua
24
init.lua
@ -20,8 +20,16 @@ local stamina_timer = 0
|
|||||||
local breath_timer = 0
|
local breath_timer = 0
|
||||||
|
|
||||||
local hudbars = minetest.get_modpath("hudbars") or false
|
local hudbars = minetest.get_modpath("hudbars") or false
|
||||||
local starve = minetest.get_modpath("hbhunger") or false
|
|
||||||
local monoids = minetest.get_modpath("player_monoids") or false
|
local monoids = minetest.get_modpath("player_monoids") or false
|
||||||
|
local starve
|
||||||
|
if minetest.get_modpath("hbhunger") then
|
||||||
|
starve = "hbhunger"
|
||||||
|
elseif minetest.get_modpath("hunger_ng") then
|
||||||
|
starve = "hunger_ng"
|
||||||
|
--starve_drain = starve_drain * -1
|
||||||
|
else
|
||||||
|
starve = false
|
||||||
|
end
|
||||||
|
|
||||||
-- Functions
|
-- Functions
|
||||||
|
|
||||||
@ -71,8 +79,13 @@ end
|
|||||||
|
|
||||||
local function drain_hunger(player, hunger, name)
|
local function drain_hunger(player, hunger, name)
|
||||||
if hunger > 0 then
|
if hunger > 0 then
|
||||||
hbhunger.hunger[name] = hunger - starve_drain
|
local newhunger = hunger - starve_drain
|
||||||
hbhunger.set_hunger_raw(player)
|
if starve == "hbhunger" then
|
||||||
|
hbhunger.hunger[name] = newhunger
|
||||||
|
hbhunger.set_hunger_raw(player)
|
||||||
|
elseif starve == "hunger_ng" then
|
||||||
|
player:set_attribute("hunger_ng:hunger", newhunger)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -141,7 +154,6 @@ minetest.register_globalstep(function(dtime)
|
|||||||
elseif key == "Use" and not dir then
|
elseif key == "Use" and not dir then
|
||||||
key_press = ctrl.aux1
|
key_press = ctrl.aux1
|
||||||
end
|
end
|
||||||
|
|
||||||
-- if key == "W" and dir then
|
-- if key == "W" and dir then
|
||||||
-- key_press = ctrl.aux1 and ctrl.up or key_press and ctrl.up
|
-- key_press = ctrl.aux1 and ctrl.up or key_press and ctrl.up
|
||||||
-- elseif key == "W" then
|
-- elseif key == "W" then
|
||||||
@ -155,8 +167,10 @@ minetest.register_globalstep(function(dtime)
|
|||||||
local ground = minetest.get_node_or_nil({x=pos.x, y=pos.y-1, z=pos.z})
|
local ground = minetest.get_node_or_nil({x=pos.x, y=pos.y-1, z=pos.z})
|
||||||
local walkable = false
|
local walkable = false
|
||||||
local player_stamina = tonumber(player:get_attribute("stamina"))
|
local player_stamina = tonumber(player:get_attribute("stamina"))
|
||||||
if starve then
|
if starve == "hbhunger" then
|
||||||
hunger = tonumber(hbhunger.hunger[name])
|
hunger = tonumber(hbhunger.hunger[name])
|
||||||
|
elseif starve == "hunger_ng" then
|
||||||
|
hunger = tonumber(player:get_attribute("hunger_ng:hunger"))
|
||||||
end
|
end
|
||||||
if ground ~= nil then
|
if ground ~= nil then
|
||||||
walkable = minetest.registered_nodes[ground.name].walkable
|
walkable = minetest.registered_nodes[ground.name].walkable
|
||||||
|
Loading…
Reference in New Issue
Block a user