forked from mtcontrib/minetest_hbhunger
Change “saturation” to “satiation”
This commit is contained in:
parent
e34e66a989
commit
71266f1dbb
14
README.txt
14
README.txt
@ -19,12 +19,12 @@ You can create a "hunger.conf" file to customize the properties of hunger for yo
|
||||
About hunger
|
||||
============
|
||||
This mod adds a hunger mechanic to the game.
|
||||
A new player starts with 20 saturation points out of 30.
|
||||
A new player starts with 20 satiation points out of 30.
|
||||
Player actions like digging, placing and walking cause exhausion, which lower the player's
|
||||
saturation. Also every 800 seconds you lose 1 saturation point without doing anything.
|
||||
If you are hungry (0 saturation) you will suffer damage and die in case you don't eat something.
|
||||
If your saturation is greater than 15, you will slowly regenerate health points.
|
||||
Eating food will increase your saturation.
|
||||
satiation. Also every 800 seconds you lose 1 satiation point without doing anything.
|
||||
If you are hungry (0 satiation) you will suffer damage and die in case you don't eat something.
|
||||
If your satiation is greater than 15, you will slowly regenerate health points.
|
||||
Eating food will increase your satiation.
|
||||
Important: Eating food will not directly increase your health anymore, as long as the food item
|
||||
is supported by this mod (see below).
|
||||
|
||||
@ -56,8 +56,8 @@ Currently supported food:
|
||||
- Simple mobs
|
||||
|
||||
Examples:
|
||||
Eating an apple (from the default Minetest game) increases your saturation by 2,
|
||||
eating a bread (from the default Minetest game) increases your saturation by 4.
|
||||
Eating an apple (from the default Minetest game) increases your satiation by 2,
|
||||
eating a bread (from the default Minetest game) increases your satiation by 4.
|
||||
|
||||
|
||||
License of textures:
|
||||
|
16
init.lua
16
init.lua
@ -18,7 +18,7 @@ HUNGER_HUNGER_TICK = 800 -- time in seconds after that 1 hunger point is taken
|
||||
HUNGER_EXHAUST_DIG = 3 -- exhaustion increased this value after digged node
|
||||
HUNGER_EXHAUST_PLACE = 1 -- exhaustion increased this value after placed
|
||||
HUNGER_EXHAUST_MOVE = 0.3 -- exhaustion increased this value if player movement detected
|
||||
HUNGER_EXHAUST_LVL = 160 -- at what exhaustion player saturation gets lowerd
|
||||
HUNGER_EXHAUST_LVL = 160 -- at what exhaustion player satiation gets lowerd
|
||||
|
||||
|
||||
--load custom settings
|
||||
@ -29,13 +29,13 @@ if set then
|
||||
end
|
||||
|
||||
local function custom_hud(player)
|
||||
hb.init_hudbar(player, "saturation", hbhunger.get_hunger(player))
|
||||
hb.init_hudbar(player, "satiation", hbhunger.get_hunger(player))
|
||||
end
|
||||
|
||||
dofile(minetest.get_modpath("hbhunger").."/hunger.lua")
|
||||
|
||||
-- register saturation hudbar
|
||||
hb.register_hudbar("saturation", 0xFFFFFF, "Saturation", { icon = "hbhunger_icon.png", bar = "hbhunger_bar.png" }, 20, 30, false)
|
||||
-- register satiation hudbar
|
||||
hb.register_hudbar("satiation", 0xFFFFFF, "Satiation", { icon = "hbhunger_icon.png", bar = "hbhunger_bar.png" }, 20, 30, false)
|
||||
|
||||
-- update hud elemtens if value has changed
|
||||
local function update_hud(player)
|
||||
@ -45,7 +45,7 @@ local function update_hud(player)
|
||||
local h = tonumber(hbhunger.hunger[name])
|
||||
if h_out ~= h then
|
||||
hbhunger.hunger_out[name] = h
|
||||
hb.change_hudbar(player, "saturation", h)
|
||||
hb.change_hudbar(player, "satiation", h)
|
||||
end
|
||||
end
|
||||
|
||||
@ -109,15 +109,15 @@ minetest.register_globalstep(function(dtime)
|
||||
local h = tonumber(hbhunger.hunger[name])
|
||||
local hp = player:get_hp()
|
||||
if timer > 4 then
|
||||
-- heal player by 1 hp if not dead and saturation is > 15 (of 30)
|
||||
-- heal player by 1 hp if not dead and satiation is > 15 (of 30)
|
||||
if h > 15 and hp > 0 and player:get_breath() > 0 then
|
||||
player:set_hp(hp+1)
|
||||
-- or damage player by 1 hp if saturation is < 2 (of 30)
|
||||
-- or damage player by 1 hp if satiation is < 2 (of 30)
|
||||
elseif h <= 1 then
|
||||
if hp-1 >= 0 then player:set_hp(hp-1) end
|
||||
end
|
||||
end
|
||||
-- lower saturation by 1 point after xx seconds
|
||||
-- lower satiation by 1 point after xx seconds
|
||||
if timer2 > HUNGER_HUNGER_TICK then
|
||||
if h > 0 then
|
||||
h = h-1
|
||||
|
Loading…
Reference in New Issue
Block a user