Update HUD
This commit is contained in:
parent
6d60a2d71b
commit
45e108b24f
@ -306,6 +306,25 @@ minetest.register_node("default:dirt", {
|
|||||||
sounds = default.node_sound_dirt_defaults(),
|
sounds = default.node_sound_dirt_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
minetest.register_node("default:gravel", {
|
||||||
|
description = "Gravel",
|
||||||
|
tiles = {"default_gravel.png"},
|
||||||
|
is_ground_content = true,
|
||||||
|
stack_max = 64,
|
||||||
|
groups = {crumbly=2, falling_node=1, building = 1},
|
||||||
|
drop = {
|
||||||
|
max_items = 1,
|
||||||
|
items = {
|
||||||
|
{items = {'default:flint'},rarity = 7},
|
||||||
|
{items = {'default:gravel'}}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
sounds = default.node_sound_dirt_defaults({
|
||||||
|
footstep = {name="default_gravel_footstep", gain=0.45},
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
|
||||||
-- sandstone --
|
-- sandstone --
|
||||||
minetest.register_node("default:sand", {
|
minetest.register_node("default:sand", {
|
||||||
description = "Sand",
|
description = "Sand",
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
Minetest mod "Better HUD"
|
Minetest mod "Better HUD"
|
||||||
=========================
|
=========================
|
||||||
Version: 2.1.4
|
Version: 2.1.5
|
||||||
|
|
||||||
(c) Copyright BlockMen (2013-2015)
|
(c) Copyright BlockMen (2013-2016)
|
||||||
|
|
||||||
|
|
||||||
About this mod:
|
About this mod:
|
||||||
@ -15,6 +15,7 @@ Changes in builtin HUD items:
|
|||||||
- Uses better textures for Hotbar
|
- Uses better textures for Hotbar
|
||||||
- Uses texture for crosshair
|
- Uses texture for crosshair
|
||||||
- Positions of builtin statbars can be changed via "hud.conf" file
|
- Positions of builtin statbars can be changed via "hud.conf" file
|
||||||
|
- Experimental "ItemWheel" that replaces the hotbar (must be enabled by adding "hud_item_wheel = true" in minetest.conf)
|
||||||
|
|
||||||
This mod gets provided as Modpack aswell, which includes the hunger mod (https://github.com/BlockMen/hunger)
|
This mod gets provided as Modpack aswell, which includes the hunger mod (https://github.com/BlockMen/hunger)
|
||||||
More information concerning the hunger mechanics can be get there.
|
More information concerning the hunger mechanics can be get there.
|
||||||
@ -25,7 +26,7 @@ This mod supports the 3d_armor mod by stu (https://github.com/stujones11/minetes
|
|||||||
|
|
||||||
License:
|
License:
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
(c) Copyright BlockMen (2013-2015)
|
(c) Copyright BlockMen (2013-2016)
|
||||||
|
|
||||||
|
|
||||||
Code:
|
Code:
|
||||||
@ -38,7 +39,7 @@ You should have received a copy of the GNU Lesser General Public
|
|||||||
License along with this library; if not, write to the Free Software
|
License along with this library; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
See LICENSE.txt and http://www.gnu.org/licenses/lgpl-3.0.txt
|
See LICENSE.txt and https://www.gnu.org/licenses/lgpl-3.0.en.html
|
||||||
|
|
||||||
|
|
||||||
Textures:
|
Textures:
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
-- global values
|
-- global values
|
||||||
hud.registered_items = {}
|
hud.registered_items = {}
|
||||||
hud.damage_events = {}
|
hud.damage_events = {}
|
||||||
@ -62,7 +63,7 @@ function hud.register(name, def)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- no error so far, return sucess
|
-- no error so far, return success
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -236,3 +237,32 @@ minetest.register_on_joinplayer(function(player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
function hud.player_event(player, event)
|
||||||
|
if not player then return end -- ADDED
|
||||||
|
|
||||||
|
--needed for first update called by on_join
|
||||||
|
minetest.after(0, function(player) -- ADDED (player)
|
||||||
|
if event == "health_changed" then
|
||||||
|
for _,v in pairs(hud.damage_events) do
|
||||||
|
if v.func then
|
||||||
|
v.func(player)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if event == "breath_changed" then
|
||||||
|
for _,v in pairs(hud.breath_events) do
|
||||||
|
if v.func then
|
||||||
|
v.func(player)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if event == "hud_changed" then--called when flags changed
|
||||||
|
|
||||||
|
end
|
||||||
|
end, player) -- ADDED , player)
|
||||||
|
end
|
||||||
|
|
||||||
|
core.register_playerevent(hud.player_event)
|
@ -1,9 +1,10 @@
|
|||||||
|
|
||||||
HUD_IW_MAX = 8
|
HUD_IW_MAX = 8
|
||||||
HUD_IW_TICK = 0.4
|
HUD_IW_TICK = 0.4
|
||||||
if minetest.is_singleplayer() == true then
|
if minetest.is_singleplayer() == true then
|
||||||
HUD_IW_TICK = 0.2
|
HUD_IW_TICK = 0.2
|
||||||
end
|
end
|
||||||
HUD_ENABLE_HUNGER = true
|
|
||||||
HUD_SB_SIZE = {x = 24, y = 24}
|
HUD_SB_SIZE = {x = 24, y = 24}
|
||||||
|
|
||||||
HUD_HEALTH_POS = {x = 0.5,y = 1}
|
HUD_HEALTH_POS = {x = 0.5,y = 1}
|
||||||
@ -16,6 +17,15 @@ HUD_ARMOR_POS = {x = 0.5, y = 1}
|
|||||||
HUD_ARMOR_OFFSET = {x = -248, y = -124}
|
HUD_ARMOR_OFFSET = {x = -248, y = -124}
|
||||||
|
|
||||||
-- read hud.conf settings
|
-- read hud.conf settings
|
||||||
|
function hud.read_conf()
|
||||||
|
local mod_path = minetest.get_modpath("hud")
|
||||||
|
local set = io.open(mod_path .. "/hud.conf", "r")
|
||||||
|
if set then
|
||||||
|
dofile(mod_path .. "/hud.conf")
|
||||||
|
set:close()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
hud.read_conf()
|
hud.read_conf()
|
||||||
|
|
||||||
local damage_enabled = minetest.setting_getbool("enable_damage")
|
local damage_enabled = minetest.setting_getbool("enable_damage")
|
||||||
@ -29,12 +39,16 @@ if (enable_hunger == true or HUD_ENABLE_HUNGER == true) and not hud.show_hunger
|
|||||||
hud.notify_hunger(5)
|
hud.notify_hunger(5)
|
||||||
end
|
end
|
||||||
|
|
||||||
if damage_enabled then
|
if damage_enabled ~= true then
|
||||||
|
hud.show_armor = false
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
hud.register("health", {
|
hud.register("health", {
|
||||||
hud_elem_type = "statbar",
|
hud_elem_type = "statbar",
|
||||||
position = HUD_HEALTH_POS,
|
position = HUD_HEALTH_POS,
|
||||||
size = HUD_SB_SIZE,
|
size = HUD_SB_SIZE,
|
||||||
text = "hud_heart_fg.png",
|
text = "heart.png",
|
||||||
number = 20,
|
number = 20,
|
||||||
alignment = {x = -1, y = -1},
|
alignment = {x = -1, y = -1},
|
||||||
offset = HUD_HEALTH_OFFSET,
|
offset = HUD_HEALTH_OFFSET,
|
||||||
@ -53,7 +67,7 @@ if damage_enabled then
|
|||||||
hud_elem_type = "statbar",
|
hud_elem_type = "statbar",
|
||||||
position = HUD_AIR_POS,
|
position = HUD_AIR_POS,
|
||||||
size = HUD_SB_SIZE,
|
size = HUD_SB_SIZE,
|
||||||
text = "hud_air_fg.png",
|
text = "bubble.png",
|
||||||
number = 0,
|
number = 0,
|
||||||
alignment = {x = -1, y = -1},
|
alignment = {x = -1, y = -1},
|
||||||
offset = HUD_AIR_OFFSET,
|
offset = HUD_AIR_OFFSET,
|
||||||
@ -62,7 +76,8 @@ if damage_enabled then
|
|||||||
{
|
{
|
||||||
type = "breath",
|
type = "breath",
|
||||||
func = function(player)
|
func = function(player)
|
||||||
local air = player:get_breath()
|
if not player then return end -- ADDED
|
||||||
|
local air = player:get_breath() or 11
|
||||||
if air > 10 then
|
if air > 10 then
|
||||||
air = 0
|
air = 0
|
||||||
end
|
end
|
||||||
@ -96,6 +111,3 @@ if damage_enabled then
|
|||||||
background = "hud_hunger_bg.png",
|
background = "hud_hunger_bg.png",
|
||||||
max = 0,
|
max = 0,
|
||||||
})
|
})
|
||||||
else
|
|
||||||
hud.show_armor = false
|
|
||||||
end
|
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
function hud.read_conf()
|
|
||||||
local mod_path = minetest.get_modpath("hud")
|
|
||||||
local set = io.open(mod_path .. "/hud.conf", "r")
|
|
||||||
if set then
|
|
||||||
dofile(mod_path .. "/hud.conf")
|
|
||||||
set:close()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function hud.notify_hunger(delay, use)
|
|
||||||
local txt_part = "enable"
|
|
||||||
if use then
|
|
||||||
txt_part = "use"
|
|
||||||
end
|
|
||||||
minetest.after(delay, function()
|
|
||||||
minetest.chat_send_all("#Better HUD: You can't " .. txt_part .. " hunger without the \"hunger\" mod")
|
|
||||||
minetest.chat_send_all(" Enable it or download it from \"https://github.com/BlockMen/hunger\"")
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
function hud.player_event(player, event)
|
|
||||||
--needed for first update called by on_join
|
|
||||||
minetest.after(0, function()
|
|
||||||
if event == "health_changed" then
|
|
||||||
for _,v in pairs(hud.damage_events) do
|
|
||||||
if v.func then
|
|
||||||
v.func(player)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if event == "breath_changed" then
|
|
||||||
for _,v in pairs(hud.breath_events) do
|
|
||||||
if v.func then
|
|
||||||
v.func(player)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if event == "hud_changed" then--called when flags changed
|
|
||||||
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
core.register_playerevent(hud.player_event)
|
|
@ -1,7 +1,8 @@
|
|||||||
hud = {}
|
|
||||||
local modpath = minetest.get_modpath("hud")
|
|
||||||
|
|
||||||
dofile(modpath .. "/api.lua")
|
hud = {}
|
||||||
dofile(modpath .. "/functions.lua")
|
|
||||||
dofile(modpath .. "/builtin.lua")
|
local path = minetest.get_modpath("hud")
|
||||||
dofile(modpath .. "/legacy.lua")
|
|
||||||
|
dofile(path .. "/api.lua")
|
||||||
|
dofile(path .. "/builtin.lua")
|
||||||
|
dofile(path .. "/legacy.lua")
|
@ -1,195 +0,0 @@
|
|||||||
local hb = {}
|
|
||||||
local scale = tonumber(core.setting_get("hud_scaling")) or 1
|
|
||||||
|
|
||||||
local function update_wheel(player)
|
|
||||||
local name = player:get_player_name()
|
|
||||||
if not player or not name then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local i = player:get_wield_index()
|
|
||||||
local i1 = i - 1
|
|
||||||
local i3 = i + 1
|
|
||||||
|
|
||||||
-- it's a wheel
|
|
||||||
if i1 < 1 then
|
|
||||||
i1 = HUD_IW_MAX
|
|
||||||
end
|
|
||||||
if i3 > HUD_IW_MAX then
|
|
||||||
i3 = 1
|
|
||||||
end
|
|
||||||
|
|
||||||
-- get the displayed items
|
|
||||||
local inv = player:get_inventory()
|
|
||||||
local item = hb[name].item
|
|
||||||
local index = hb[name].index
|
|
||||||
local item2 = player:get_wielded_item():get_name()
|
|
||||||
|
|
||||||
-- update all items when wielded has changed
|
|
||||||
if item and item2 and item ~= item2 or item == "wheel_init" or (index and index ~= i) then
|
|
||||||
local items = {}
|
|
||||||
items[1] = inv:get_stack("main", i1):get_name() or nil
|
|
||||||
items[2] = item2
|
|
||||||
items[3] = inv:get_stack("main", i3):get_name() or nil
|
|
||||||
local num = player:get_wielded_item():get_count()
|
|
||||||
local wear = player:get_wielded_item():get_wear()
|
|
||||||
if num < 2 then
|
|
||||||
num = ""
|
|
||||||
else
|
|
||||||
num = tostring(num)
|
|
||||||
end
|
|
||||||
if wear > 0 then
|
|
||||||
num = tostring(100 - math.floor((wear/65535)*100)) .. "%"
|
|
||||||
end
|
|
||||||
|
|
||||||
for n, m in pairs(items) do
|
|
||||||
-- some default values
|
|
||||||
local image = "hud_wielded.png"
|
|
||||||
local need_scale = false
|
|
||||||
local s1 = {x = 1*scale, y = 1*scale}
|
|
||||||
local s2 = {x = 3*scale, y = 3*scale}
|
|
||||||
if n ~= 2 then
|
|
||||||
s1 = {x = 0.6*scale, y = 0.6*scale}
|
|
||||||
s2 = {x = 2*scale, y = 2*scale}
|
|
||||||
end
|
|
||||||
|
|
||||||
-- get the images
|
|
||||||
local def = minetest.registered_items[m]
|
|
||||||
if def then
|
|
||||||
if def.tiles and (def.tiles[1] and not def.tiles[1].name) then
|
|
||||||
image = minetest.inventorycube(def.tiles[1], def.tiles[6] or def.tiles[3] or def.tiles[1], def.tiles[3] or def.tiles[1])
|
|
||||||
need_scale = true
|
|
||||||
end
|
|
||||||
if def.inventory_image and def.inventory_image ~= "" then
|
|
||||||
image = def.inventory_image
|
|
||||||
need_scale = false
|
|
||||||
end
|
|
||||||
if def.wielded_image and def.wielded_image ~= "" then
|
|
||||||
image = def.wielded_image
|
|
||||||
need_scale = false
|
|
||||||
end
|
|
||||||
-- needed for nodes with inventory cube inv imges, e.g. glass
|
|
||||||
if string.find(image, 'inventorycube') then
|
|
||||||
need_scale = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- get the id and update hud elements
|
|
||||||
local id = hb[name].id[n]
|
|
||||||
if id and image then
|
|
||||||
if need_scale then
|
|
||||||
player:hud_change(id, "scale", s1)
|
|
||||||
else
|
|
||||||
player:hud_change(id, "scale", s2)
|
|
||||||
end
|
|
||||||
-- make previous and next item darker
|
|
||||||
--if n ~= 2 then
|
|
||||||
--image = image .. "^[colorize:#0005"
|
|
||||||
--end
|
|
||||||
player:hud_change(id, "text", image)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if hb[name].id[4] then
|
|
||||||
player:hud_change(hb[name].id[4], "text", num)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- update wielded buffer
|
|
||||||
if hb[name].id[2] ~= nil then
|
|
||||||
hb[name].item = item2
|
|
||||||
hb[name].index = i
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
|
||||||
local name = player:get_player_name()
|
|
||||||
hb[name]= {}
|
|
||||||
hb[name].id = {}
|
|
||||||
hb[name].item = "wheel_init"
|
|
||||||
hb[name].index = 1
|
|
||||||
|
|
||||||
minetest.after(0.1, function()
|
|
||||||
|
|
||||||
-- hide builtin hotbar
|
|
||||||
local hud_flags = player:hud_get_flags()
|
|
||||||
hud_flags.hotbar = false
|
|
||||||
player:hud_set_flags(hud_flags)
|
|
||||||
|
|
||||||
player:hud_add({
|
|
||||||
hud_elem_type = "image",
|
|
||||||
text = "hud_new.png",
|
|
||||||
position = {x = 0.5, y = 1},
|
|
||||||
scale = {x = 1*scale, y = 1*scale},
|
|
||||||
alignment = {x = 0, y = -1},
|
|
||||||
offset = {x = 0, y = 0}
|
|
||||||
})
|
|
||||||
|
|
||||||
hb[name].id[1] = player:hud_add({
|
|
||||||
hud_elem_type = "image",
|
|
||||||
text = "hud_wielded.png",
|
|
||||||
position = {x = 0.5, y = 1},
|
|
||||||
scale = {x = 1*scale, y = 1*scale},
|
|
||||||
alignment = {x = 0, y = -1},
|
|
||||||
offset = {x = -75*scale, y = -8*scale}
|
|
||||||
})
|
|
||||||
|
|
||||||
hb[name].id[2] = player:hud_add({
|
|
||||||
hud_elem_type = "image",
|
|
||||||
text = "hud_wielded.png",
|
|
||||||
position = {x = 0.5, y = 1},
|
|
||||||
scale = {x = 3*scale, y = 3*scale},
|
|
||||||
alignment = {x = 0, y = -1},
|
|
||||||
offset = {x = 0, y = -12*scale}
|
|
||||||
})
|
|
||||||
|
|
||||||
hb[name].id[3] = player:hud_add({
|
|
||||||
hud_elem_type = "image",
|
|
||||||
text = "hud_wielded.png",
|
|
||||||
position = {x = 0.5, y = 1},
|
|
||||||
scale = {x = 1*scale, y = 1*scale},
|
|
||||||
alignment = {x = 0, y = -1},
|
|
||||||
offset = {x = 75*scale, y = -8*scale}
|
|
||||||
})
|
|
||||||
|
|
||||||
hb[name].id[4] = player:hud_add({
|
|
||||||
hud_elem_type = "text",
|
|
||||||
position = {x = 0.5, y = 1},
|
|
||||||
offset = {x = 35*scale, y = -55*scale},
|
|
||||||
alignment = {x = 0, y = -1},
|
|
||||||
number = 0xffffff,
|
|
||||||
text = "",
|
|
||||||
})
|
|
||||||
|
|
||||||
-- init item wheel
|
|
||||||
minetest.after(0, function()
|
|
||||||
hb[name].item = "wheel_init"
|
|
||||||
update_wheel(player)
|
|
||||||
end)
|
|
||||||
end)
|
|
||||||
end)
|
|
||||||
|
|
||||||
local function update_wrapper(a, b, player)
|
|
||||||
local name = player:get_player_name()
|
|
||||||
if not name then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
minetest.after(0, function()
|
|
||||||
hb[name].item = "wheel_init"
|
|
||||||
update_wheel(player)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_on_placenode(update_wrapper)
|
|
||||||
minetest.register_on_dignode(update_wrapper)
|
|
||||||
|
|
||||||
|
|
||||||
local timer = 0
|
|
||||||
minetest.register_globalstep(function(dtime)
|
|
||||||
timer = timer + dtime
|
|
||||||
if timer >= HUD_IW_TICK then
|
|
||||||
timer = 0
|
|
||||||
for _, player in ipairs(minetest.get_connected_players()) do
|
|
||||||
update_wheel(player)
|
|
||||||
end
|
|
||||||
end--timer
|
|
||||||
end)
|
|
@ -4,7 +4,7 @@ end
|
|||||||
|
|
||||||
if hud.show_armor then
|
if hud.show_armor then
|
||||||
local shields = minetest.get_modpath("shields") ~= nil
|
local shields = minetest.get_modpath("shields") ~= nil
|
||||||
local armor_org_func = armor.update_armor
|
local armor_org_func = armor.set_player_armor
|
||||||
|
|
||||||
local function get_armor_lvl(def)
|
local function get_armor_lvl(def)
|
||||||
-- items/protection based display
|
-- items/protection based display
|
||||||
@ -22,7 +22,7 @@ if hud.show_armor then
|
|||||||
return tonumber(20 * ret)
|
return tonumber(20 * ret)
|
||||||
end
|
end
|
||||||
|
|
||||||
function armor.update_armor(self, player)
|
function armor.set_player_armor(self, player)
|
||||||
armor_org_func(self, player)
|
armor_org_func(self, player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local def = self.def
|
local def = self.def
|
||||||
@ -34,6 +34,17 @@ if hud.show_armor then
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function hud.notify_hunger(delay, use)
|
||||||
|
local txt_part = "enable"
|
||||||
|
if use then
|
||||||
|
txt_part = "use"
|
||||||
|
end
|
||||||
|
minetest.after(delay, function()
|
||||||
|
minetest.chat_send_all("#Better HUD: You can't " .. txt_part .. " hunger without the \"hunger\" mod")
|
||||||
|
minetest.chat_send_all(" Enable it or download it from \"https://github.com/BlockMen/hunger\"")
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
-- Hunger related functions
|
-- Hunger related functions
|
||||||
if not hud.show_hunger then
|
if not hud.show_hunger then
|
||||||
function hud.set_hunger()
|
function hud.set_hunger()
|
||||||
@ -55,6 +66,7 @@ if not hud.show_hunger then
|
|||||||
function hud.save_hunger()
|
function hud.save_hunger()
|
||||||
hud.notify_hunger(1, true)
|
hud.notify_hunger(1, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
function hud.load_hunger(player)
|
function hud.load_hunger(player)
|
||||||
hud.notify_hunger(1, true)
|
hud.notify_hunger(1, true)
|
||||||
end
|
end
|
||||||
|
Before Width: | Height: | Size: 191 B After Width: | Height: | Size: 191 B |
Before Width: | Height: | Size: 362 B After Width: | Height: | Size: 362 B |
@ -1,17 +1,18 @@
|
|||||||
|
|
||||||
local register_food = hunger.register_food
|
local register_food = hunger.register_food
|
||||||
|
|
||||||
register_food("default:apple", 2)
|
register_food("default:apple", 2)
|
||||||
|
|
||||||
if minetest.get_modpath("farming") ~= nil then
|
if minetest.get_modpath("farming") then
|
||||||
register_food("farming:bread", 4)
|
register_food("farming:bread", 4)
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("flowers") ~= nil then
|
if minetest.get_modpath("flowers") then
|
||||||
register_food("flowers:mushroom_brown", 1)
|
register_food("flowers:mushroom_brown", 1)
|
||||||
register_food("flowers:mushroom_red", 1, "", 3)
|
register_food("flowers:mushroom_red", 1, "", 3)
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("mobs") ~= nil then
|
if minetest.get_modpath("mobs") then
|
||||||
if mobs.mod ~= nil and mobs.mod == "redo" then
|
if mobs.mod ~= nil and mobs.mod == "redo" then
|
||||||
register_food("mobs:cheese", 4)
|
register_food("mobs:cheese", 4)
|
||||||
register_food("mobs:meat", 8)
|
register_food("mobs:meat", 8)
|
||||||
@ -34,7 +35,7 @@ if minetest.get_modpath("mobs") ~= nil then
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("moretrees") ~= nil then
|
if minetest.get_modpath("moretrees") then
|
||||||
register_food("moretrees:coconut_milk", 1)
|
register_food("moretrees:coconut_milk", 1)
|
||||||
register_food("moretrees:raw_coconut", 2)
|
register_food("moretrees:raw_coconut", 2)
|
||||||
register_food("moretrees:acorn_muffin", 3)
|
register_food("moretrees:acorn_muffin", 3)
|
||||||
@ -43,7 +44,7 @@ if minetest.get_modpath("moretrees") ~= nil then
|
|||||||
register_food("moretrees:fir_nuts", 1)
|
register_food("moretrees:fir_nuts", 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("dwarves") ~= nil then
|
if minetest.get_modpath("dwarves") then
|
||||||
register_food("dwarves:beer", 2)
|
register_food("dwarves:beer", 2)
|
||||||
register_food("dwarves:apple_cider", 1)
|
register_food("dwarves:apple_cider", 1)
|
||||||
register_food("dwarves:midus", 2)
|
register_food("dwarves:midus", 2)
|
||||||
@ -52,7 +53,7 @@ if minetest.get_modpath("dwarves") ~= nil then
|
|||||||
register_food("dwarves:sake", 2)
|
register_food("dwarves:sake", 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("animalmaterials") ~= nil then
|
if minetest.get_modpath("animalmaterials") then
|
||||||
register_food("animalmaterials:milk", 2)
|
register_food("animalmaterials:milk", 2)
|
||||||
register_food("animalmaterials:meat_raw", 3)
|
register_food("animalmaterials:meat_raw", 3)
|
||||||
register_food("animalmaterials:meat_pork", 3)
|
register_food("animalmaterials:meat_pork", 3)
|
||||||
@ -67,7 +68,7 @@ if minetest.get_modpath("animalmaterials") ~= nil then
|
|||||||
register_food("animalmaterials:fish_clownfish", 2)
|
register_food("animalmaterials:fish_clownfish", 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("fishing") ~= nil then
|
if minetest.get_modpath("fishing") then
|
||||||
register_food("fishing:fish_raw", 2)
|
register_food("fishing:fish_raw", 2)
|
||||||
register_food("fishing:fish_cooked", 5)
|
register_food("fishing:fish_cooked", 5)
|
||||||
register_food("fishing:sushi", 6)
|
register_food("fishing:sushi", 6)
|
||||||
@ -77,11 +78,11 @@ if minetest.get_modpath("fishing") ~= nil then
|
|||||||
register_food("fishing:pike_cooked", 8)
|
register_food("fishing:pike_cooked", 8)
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("glooptest") ~= nil then
|
if minetest.get_modpath("glooptest") then
|
||||||
register_food("glooptest:kalite_lump", 1)
|
register_food("glooptest:kalite_lump", 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("bushes") ~= nil then
|
if minetest.get_modpath("bushes") then
|
||||||
register_food("bushes:sugar", 1)
|
register_food("bushes:sugar", 1)
|
||||||
register_food("bushes:strawberry", 2)
|
register_food("bushes:strawberry", 2)
|
||||||
register_food("bushes:berry_pie_raw", 3)
|
register_food("bushes:berry_pie_raw", 3)
|
||||||
@ -108,7 +109,7 @@ if minetest.get_modpath("bushes_classic") then
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("mushroom") ~= nil then
|
if minetest.get_modpath("mushroom") then
|
||||||
register_food("mushroom:brown", 1)
|
register_food("mushroom:brown", 1)
|
||||||
register_food("mushroom:red", 1, "", 3)
|
register_food("mushroom:red", 1, "", 3)
|
||||||
-- mushroom potions: red = strong poison, brown = light restorative
|
-- mushroom potions: red = strong poison, brown = light restorative
|
||||||
@ -118,7 +119,7 @@ if minetest.get_modpath("mushroom") ~= nil then
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("docfarming") ~= nil then
|
if minetest.get_modpath("docfarming") then
|
||||||
register_food("docfarming:carrot", 3)
|
register_food("docfarming:carrot", 3)
|
||||||
register_food("docfarming:cucumber", 2)
|
register_food("docfarming:cucumber", 2)
|
||||||
register_food("docfarming:corn", 3)
|
register_food("docfarming:corn", 3)
|
||||||
@ -127,7 +128,7 @@ if minetest.get_modpath("docfarming") ~= nil then
|
|||||||
register_food("docfarming:raspberry", 3)
|
register_food("docfarming:raspberry", 3)
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("farming_plus") ~= nil then
|
if minetest.get_modpath("farming_plus") then
|
||||||
register_food("farming_plus:carrot_item", 3)
|
register_food("farming_plus:carrot_item", 3)
|
||||||
register_food("farming_plus:banana", 2)
|
register_food("farming_plus:banana", 2)
|
||||||
register_food("farming_plus:orange_item", 2)
|
register_food("farming_plus:orange_item", 2)
|
||||||
@ -138,7 +139,7 @@ if minetest.get_modpath("farming_plus") ~= nil then
|
|||||||
register_food("farming_plus:rhubarb_item", 2)
|
register_food("farming_plus:rhubarb_item", 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("mtfoods") ~= nil then
|
if minetest.get_modpath("mtfoods") then
|
||||||
register_food("mtfoods:dandelion_milk", 1)
|
register_food("mtfoods:dandelion_milk", 1)
|
||||||
register_food("mtfoods:sugar", 1)
|
register_food("mtfoods:sugar", 1)
|
||||||
register_food("mtfoods:short_bread", 4)
|
register_food("mtfoods:short_bread", 4)
|
||||||
@ -167,18 +168,18 @@ if minetest.get_modpath("mtfoods") ~= nil then
|
|||||||
register_food("mtfoods:cider_rack", 2)
|
register_food("mtfoods:cider_rack", 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("fruit") ~= nil then
|
if minetest.get_modpath("fruit") then
|
||||||
register_food("fruit:apple", 2)
|
register_food("fruit:apple", 2)
|
||||||
register_food("fruit:pear", 2)
|
register_food("fruit:pear", 2)
|
||||||
register_food("fruit:bananna", 3)
|
register_food("fruit:bananna", 3)
|
||||||
register_food("fruit:orange", 2)
|
register_food("fruit:orange", 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("mush45") ~= nil then
|
if minetest.get_modpath("mush45") then
|
||||||
register_food("mush45:meal", 4)
|
register_food("mush45:meal", 4)
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("seaplants") ~= nil then
|
if minetest.get_modpath("seaplants") then
|
||||||
register_food("seaplants:kelpgreen", 1)
|
register_food("seaplants:kelpgreen", 1)
|
||||||
register_food("seaplants:kelpbrown", 1)
|
register_food("seaplants:kelpbrown", 1)
|
||||||
register_food("seaplants:seagrassgreen", 1)
|
register_food("seaplants:seagrassgreen", 1)
|
||||||
@ -190,7 +191,7 @@ if minetest.get_modpath("seaplants") ~= nil then
|
|||||||
register_food("seaplants:seagrassgreensalad", 1)
|
register_food("seaplants:seagrassgreensalad", 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("mobfcooking") ~= nil then
|
if minetest.get_modpath("mobfcooking") then
|
||||||
register_food("mobfcooking:cooked_pork", 6)
|
register_food("mobfcooking:cooked_pork", 6)
|
||||||
register_food("mobfcooking:cooked_ostrich", 6)
|
register_food("mobfcooking:cooked_ostrich", 6)
|
||||||
register_food("mobfcooking:cooked_beef", 6)
|
register_food("mobfcooking:cooked_beef", 6)
|
||||||
@ -200,7 +201,7 @@ if minetest.get_modpath("mobfcooking") ~= nil then
|
|||||||
register_food("mobfcooking:cooked_fish", 6)
|
register_food("mobfcooking:cooked_fish", 6)
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("creatures") ~= nil then
|
if minetest.get_modpath("creatures") then
|
||||||
register_food("creatures:meat", 6)
|
register_food("creatures:meat", 6)
|
||||||
register_food("creatures:flesh", 3)
|
register_food("creatures:flesh", 3)
|
||||||
register_food("creatures:rotten_flesh", 3, "", 3)
|
register_food("creatures:rotten_flesh", 3, "", 3)
|
||||||
@ -264,7 +265,7 @@ if minetest.get_modpath("farming") and farming.mod == "redo" then
|
|||||||
register_food("farming:grapes", 1)
|
register_food("farming:grapes", 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("kpgmobs") ~= nil then
|
if minetest.get_modpath("kpgmobs") then
|
||||||
register_food("kpgmobs:uley", 3)
|
register_food("kpgmobs:uley", 3)
|
||||||
register_food("kpgmobs:meat", 6)
|
register_food("kpgmobs:meat", 6)
|
||||||
register_food("kpgmobs:rat_cooked", 5)
|
register_food("kpgmobs:rat_cooked", 5)
|
||||||
@ -274,23 +275,23 @@ if minetest.get_modpath("kpgmobs") ~= nil then
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("jkfarming") ~= nil then
|
if minetest.get_modpath("jkfarming") then
|
||||||
register_food("jkfarming:carrot", 3)
|
register_food("jkfarming:carrot", 3)
|
||||||
register_food("jkfarming:corn", 3)
|
register_food("jkfarming:corn", 3)
|
||||||
register_food("jkfarming:melon_part", 2)
|
register_food("jkfarming:melon_part", 2)
|
||||||
register_food("jkfarming:cake", 3)
|
register_food("jkfarming:cake", 3)
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("jkanimals") ~= nil then
|
if minetest.get_modpath("jkanimals") then
|
||||||
register_food("jkanimals:meat", 6)
|
register_food("jkanimals:meat", 6)
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("jkwine") ~= nil then
|
if minetest.get_modpath("jkwine") then
|
||||||
register_food("jkwine:grapes", 2)
|
register_food("jkwine:grapes", 2)
|
||||||
register_food("jkwine:winebottle", 1)
|
register_food("jkwine:winebottle", 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("cooking") ~= nil then
|
if minetest.get_modpath("cooking") then
|
||||||
register_food("cooking:meat_beef_cooked", 4)
|
register_food("cooking:meat_beef_cooked", 4)
|
||||||
register_food("cooking:fish_bluewhite_cooked", 3)
|
register_food("cooking:fish_bluewhite_cooked", 3)
|
||||||
register_food("cooking:fish_clownfish_cooked", 1)
|
register_food("cooking:fish_clownfish_cooked", 1)
|
||||||
@ -303,19 +304,19 @@ if minetest.get_modpath("cooking") ~= nil then
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- ferns mod of plantlife_modpack
|
-- ferns mod of plantlife_modpack
|
||||||
if minetest.get_modpath("ferns") ~= nil then
|
if minetest.get_modpath("ferns") then
|
||||||
register_food("ferns:fiddlehead", 1, "", 1)
|
register_food("ferns:fiddlehead", 1, "", 1)
|
||||||
register_food("ferns:fiddlehead_roasted", 3)
|
register_food("ferns:fiddlehead_roasted", 3)
|
||||||
register_food("ferns:ferntuber_roasted", 3)
|
register_food("ferns:ferntuber_roasted", 3)
|
||||||
register_food("ferns:horsetail_01", 1)
|
register_food("ferns:horsetail_01", 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("pizza") ~= nil then
|
if minetest.get_modpath("pizza") then
|
||||||
register_food("pizza:pizza", 30, "", nil, 30)
|
register_food("pizza:pizza", 30, "", nil, 30)
|
||||||
register_food("pizza:pizzaslice", 5, "", nil, 5)
|
register_food("pizza:pizzaslice", 5, "", nil, 5)
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("wine") ~= nil then
|
if minetest.get_modpath("wine") then
|
||||||
register_food("wine:glass_wine", 2)
|
register_food("wine:glass_wine", 2)
|
||||||
register_food("wine:glass_beer", 2)
|
register_food("wine:glass_beer", 2)
|
||||||
register_food("wine:glass_mead", 2)
|
register_food("wine:glass_mead", 2)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
-- read/write
|
-- read/write
|
||||||
function hunger.read(player)
|
function hunger.read(player)
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
|
@ -2,7 +2,7 @@ hunger = {}
|
|||||||
hunger.players = {}
|
hunger.players = {}
|
||||||
hunger.food = {}
|
hunger.food = {}
|
||||||
|
|
||||||
HUNGER_TICK = 800 -- time in seconds after that 1 hunger point is taken
|
HUNGER_TICK = 600 -- time in seconds after that 1 hunger point is taken
|
||||||
HUNGER_HEALTH_TICK = 4 -- time in seconds after player gets healed/damaged
|
HUNGER_HEALTH_TICK = 4 -- time in seconds after player gets healed/damaged
|
||||||
HUNGER_MOVE_TICK = 0.5 -- time in seconds after the movement is checked
|
HUNGER_MOVE_TICK = 0.5 -- time in seconds after the movement is checked
|
||||||
|
|
||||||
@ -22,8 +22,13 @@ HUNGER_MAX = 30 -- maximum level of saturation
|
|||||||
local modpath = minetest.get_modpath("hunger")
|
local modpath = minetest.get_modpath("hunger")
|
||||||
dofile(modpath .. "/functions.lua")
|
dofile(modpath .. "/functions.lua")
|
||||||
dofile(modpath .. "/food.lua")
|
dofile(modpath .. "/food.lua")
|
||||||
dofile(modpath .. "/legacy.lua")
|
|
||||||
|
|
||||||
|
-- legacy functions
|
||||||
|
hud.item_eat = hunger.item_eat
|
||||||
|
hud.set_hunger = hunger.save
|
||||||
|
hud.get_hunger = hunger.load
|
||||||
|
hud.save_hunger = hunger.save
|
||||||
|
hud.load_hunger = hunger.load
|
||||||
|
|
||||||
-- Callbacks
|
-- Callbacks
|
||||||
if minetest.setting_getbool("enable_damage") then
|
if minetest.setting_getbool("enable_damage") then
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
hud.item_eat = hunger.item_eat
|
|
||||||
hud.set_hunger = hunger.save
|
|
||||||
hud.get_hunger = hunger.load
|
|
||||||
hud.save_hunger = hunger.save
|
|
||||||
hud.load_hunger = hunger.load
|
|
Loading…
x
Reference in New Issue
Block a user