Move Better HUD API in builtin, move hunger bar in hunger mod, armor bar in armor mod, code cleanup

master
MoNTE48 2019-06-16 00:46:47 +02:00
parent 77fd213408
commit e11a78243b
24 changed files with 105 additions and 772 deletions

View File

@ -1,17 +1,31 @@
-- global values
hud.registered_items = {}
hud.damage_events = {}
hud.breath_events = {}
--From Better HUD mod
--Copyright (C) BlockMen (2013-2016)
--This program is free software; you can redistribute it and/or modify
--it under the terms of the GNU Lesser General Public License as published by
--the Free Software Foundation; either version 3.0 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--GNU Lesser General Public License for more details.
--
--You should have received a copy of the GNU Lesser General Public License along
--with this program; if not, write to the Free Software Foundation, Inc.,
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
hud = {}
-- keep id handling internal
local hud_id = {} -- hud item ids
local sb_bg = {} -- statbar background ids
-- localize often used table
local items = hud.registered_items
local items = {}
local function throw_error(msg)
minetest.log("error", "Better HUD[error]: " .. msg)
minetest.log("error", "HUD[error]: " .. msg)
end
--
@ -46,21 +60,6 @@ function hud.register(name, def)
-- add item itself
items[name] = def
-- register events
if def.events then
for _,v in pairs(def.events) do
if v and v.type and v.func then
if v.type == "damage" then
table.insert(hud.damage_events, v)
end
if v.type == "breath" then
table.insert(hud.breath_events, v)
end
end
end
end
-- no error so far, return success
return true
end
@ -148,36 +147,6 @@ function hud.remove_item(player, name)
return true
end
-- Armor
if hud.show_armor then
local armor_org_func = armor.set_player_armor
local function get_armor_lvl(def)
-- items/protection based display
local lvl = def.level or 0
local max = 63 -- full diamond armor
-- TODO: is there a sane way to read out max values?
local ret = lvl/max
if ret > 1 then
ret = 1
end
return tonumber(20 * ret)
end
function armor.set_player_armor(self, player)
armor_org_func(self, player)
local name = player:get_player_name()
local def = self.def
local armor_lvl = 0
if def[name] and def[name].level then
armor_lvl = get_armor_lvl(def[name])
end
hud.change_item(player, "armor", {number = armor_lvl})
end
end
--
-- Add registered HUD items to joining players
--
@ -194,14 +163,7 @@ local function add_hud_item(player, name, def)
end
minetest.register_on_joinplayer(function(player)
-- first: hide the default statbars
--[[local hud_flags = player:hud_get_flags()
hud_flags.healthbar = false
hud_flags.breathbar = false
player:hud_set_flags(hud_flags)]]
-- now add the backgrounds for statbars
-- add the backgrounds for statbars
for _,item in pairs(sb_bg) do
add_hud_item(player, _.."_bg", item)
end
@ -209,34 +171,4 @@ minetest.register_on_joinplayer(function(player)
for _,item in pairs(items) do
add_hud_item(player, _, item)
end
end)
function hud.player_event(player, event)
if not player then return end
--needed for first update called by on_join
minetest.after(0.1, function(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)
end
core.register_playerevent(hud.player_event)

View File

@ -31,6 +31,7 @@ assert(loadfile(gamepath.."falling.lua"))(builtin_shared)
dofile(gamepath.."features.lua")
dofile(gamepath.."voxelarea.lua")
dofile(gamepath.."forceloading.lua")
dofile(gamepath.."hud.lua")
dofile(gamepath.."statbars.lua")
profiler = nil

View File

@ -1,26 +1,32 @@
-- cache setting
--[[local enable_damage = core.settings:get_bool("enable_damage")
local enable_damage = core.settings:get_bool("enable_damage")
local health_bar_definition =
{
hud_elem_type = "statbar",
position = { x=0.5, y=1 },
text = "server_flags_damage.png",
number = 20,
direction = 0,
size = { x=24, y=24 },
offset = { x=(-10*24)-25, y=-(48+24+16)},
}
local health_bar_definition = {}
if enable_damage then
hud.register("health", {
hud_elem_type = "statbar",
position = {x = 0.5, y = 1},
text = "heart.png",
number = 20,
direction = 0,
alignment = {x = -1, y = -1},
size = {x = 24, y = 24},
offset = {x = -249, y = -109},
background = "heart_bg.png",
})
end
local breath_bar_definition =
{
hud_elem_type = "statbar",
position = { x=0.5, y=1 },
text = "halo.png",
position = {x = 0.5, y = 1},
text = "bubble.png",
number = 20,
direction = 0,
size = { x=24, y=24 },
offset = {x=25,y=-(48+24+16)},
alignment = {x = -1, y = -1},
size = {x = 24, y = 24},
offset = {x = 8, y = -134},
}
local hud_ids = {}
@ -101,7 +107,7 @@ local function player_event_handler(player,eventname)
initialize_builtin_statbars(player)
if hud_ids[name].id_healthbar ~= nil then
player:hud_change(hud_ids[name].id_healthbar,"number",player:get_hp())
hud.change_item(player, "health", {number = player:get_hp()})
return true
end
end
@ -162,7 +168,7 @@ end
core.register_on_joinplayer(initialize_builtin_statbars)
core.register_on_leaveplayer(cleanup_builtin_statbars)
core.register_playerevent(player_event_handler)]]
core.register_playerevent(player_event_handler)
-- Hud Item name

View File

@ -7,7 +7,7 @@ ARMOR_DESTROY = false
ARMOR_LEVEL_MULTIPLIER = 1
ARMOR_HEAL_MULTIPLIER = 1
local modpath = minetest.get_modpath(ARMOR_MOD_NAME)
local modpath = minetest.get_modpath("3d_armor")
local worldpath = minetest.get_worldpath()
local input = io.open(modpath.."/armor.conf", "r")
if input then

View File

@ -0,0 +1,39 @@
-- (c) Copyright BlockMen (2013-2016), LGPLv3.0+
if minetest.settings:get_bool("enable_damage") then
local armor_org_func = armor.set_player_armor
local function get_armor_lvl(def)
-- items/protection based display
local lvl = def.level or 0
local max = 63 -- full diamond armor
local ret = lvl/max
if ret > 1 then
ret = 1
end
return tonumber(20 * ret)
end
function armor.set_player_armor(self, player)
armor_org_func(self, player)
local name = player:get_player_name()
local def = self.def
local armor_lvl = 0
if def[name] and def[name].level then
armor_lvl = get_armor_lvl(def[name])
end
hud.change_item(player, "armor", {number = armor_lvl})
end
hud.register("armor", {
hud_elem_type = "statbar",
position = {x = 0.5, y = 1},
size = {x = 24, y = 24},
text = "3d_armor_statbar_fg.png",
number = 0,
alignment = {x = -1, y = -1},
offset = {x = -249, y = -134},
background = "3d_armor_statbar_bg.png",
autohide_bg = true,
max = 20,
})
end

View File

@ -1,5 +1,6 @@
ARMOR_MOD_NAME = minetest.get_current_modname()
dofile(minetest.get_modpath(minetest.get_current_modname()).."/armor.lua")
local modpath = minetest.get_modpath("3d_armor")
dofile(modpath .. "/armor.lua")
dofile(modpath .. "/hud.lua")
-- Regisiter Head Armor

View File

Before

Width:  |  Height:  |  Size: 146 B

After

Width:  |  Height:  |  Size: 146 B

View File

Before

Width:  |  Height:  |  Size: 171 B

After

Width:  |  Height:  |  Size: 171 B

View File

Before

Width:  |  Height:  |  Size: 212 B

After

Width:  |  Height:  |  Size: 212 B

View File

@ -1,2 +1 @@
default
hud

View File

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -1,67 +0,0 @@
MultiCraft game mod: Better HUD
=========================
Version: 2.1.5
(c) Copyright BlockMen (2013-2016)
About this mod:
~~~~~~~~~~~~~~~
This mod improves the HUD of Minetest and adds (hidden by default) statbars for Hunger and Armor.
Also it provides an API to add new statbars easily, see API.txt for more informations.
Changes in builtin HUD items:
- Adds background for Health bar
- Uses better textures for Hotbar
- Uses texture for crosshair
- 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)
More information concerning the hunger mechanics can be get there.
This mod supports the 3d_armor mod by stu (https://github.com/stujones11/minetest-3d_armor)
License:
~~~~~~~~
(c) Copyright BlockMen (2013-2016)
Code:
Licensed under the GNU LGPL version 3.0 or higher.
You can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License
as published by the Free Software Foundation;
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
See LICENSE.txt and https://www.gnu.org/licenses/lgpl-3.0.en.html
Textures:
hud_heart_fg.png - celeron55 (CC BY-SA 3.0), modified by BlockMen
hud_heart_bg.png - celeron55 (CC BY-SA 3.0), modified by BlockMen
hud_hunger_fg.png - PilzAdam (WTFPL), modified by BlockMen
hud_hunger_bg.png - PilzAdam (WTFPL), modified by BlockMen
wieldhand.png (from character.png) - Jordach (CC BY-SA 3.0), modified by BlockMen
hud_air_fg.png - kaeza (WTFPL), modified by BlockMen
hud_armor_fg.png - Stu (CC BY-SA 3.0), modified by BlockMen
hud_armor_bg.png - Stu (CC BY-SA 3.0), modified by BlockMen
Github:
~~~~~~~
https://github.com/BlockMen/hud
Forum:
~~~~~~
https://forum.minetest.net/viewtopic.php?id=6342
Changelog:
~~~~~~~~~~
see changelog.txt

View File

@ -1,73 +0,0 @@
HUD_SB_SIZE = {x = 24, y = 24}
HUD_HEALTH_OFFSET = {x = -249, y = -109}
HUD_AIR_OFFSET = {x = 8, y = -134}
HUD_HUNGER_OFFSET = {x = 8, y = -109}
HUD_ARMOR_OFFSET = {x = -249, y = -134}
hud.register("health", {
hud_elem_type = "statbar",
position = {x = 0.5, y = 1},
size = HUD_SB_SIZE,
text = "heart.png",
number = 20,
alignment = {x = -1, y = -1},
offset = HUD_HEALTH_OFFSET,
background = "hud_heart_bg.png",
events = {
{
type = "damage",
func = function(player)
hud.change_item(player, "health", {number = player:get_hp()})
end
}
},
})
hud.register("air", {
hud_elem_type = "statbar",
position = {x = 0.5, y = 1},
size = HUD_SB_SIZE,
text = "bubble.png",
number = 0,
alignment = {x = -1, y = -1},
offset = HUD_AIR_OFFSET,
background = nil,
events = {
{
type = "breath",
func = function(player)
if not player then return end
local air = player:get_breath() or 11
if air > 10 then
air = 0
end
hud.change_item(player, "air", {number = air * 2})
end
}
},
})
hud.register("armor", {
hud_elem_type = "statbar",
position = {x = 0.5, y = 1},
size = HUD_SB_SIZE,
text = "hud_armor_fg.png",
number = 0,
alignment = {x = -1, y = -1},
offset = HUD_ARMOR_OFFSET,
background = "hud_armor_bg.png",
autohide_bg = true,
max = 20,
})
hud.register("hunger", {
hud_elem_type = "statbar",
position = {x = 0.5, y = 1},
size = HUD_SB_SIZE,
text = "hud_hunger_fg.png",
number = 20,
alignment = {x = -1, y = -1},
offset = HUD_HUNGER_OFFSET,
background = "hud_hunger_bg.png",
max = 20,
})

View File

@ -1 +0,0 @@
3d_armor?

View File

@ -1,10 +0,0 @@
hud = {}
hud.show_armor = minetest.get_modpath("3d_armor") ~= nil
local modpath = minetest.get_modpath("hud")
dofile(modpath .. "/api.lua")
if minetest.settings:get_bool("enable_damage") then
dofile(modpath .. "/builtin.lua")
end

View File

@ -1,31 +1,3 @@
default
hud
animalmaterials?
bucket?
bushes?
bushes_classic?
cooking?
creatures?
docfarming?
dwarves?
ethereal?
farming?
farming_plus?
ferns?
fishing?
flowers?
fruit?
glooptest?
jkanimals?
jkfarming?
jkwine?
kpgmobs?
mobfcooking?
mobs?
moretrees?
mtfoods?
mush45?
mushroom?
pizza?
seaplants?
3d_armor?

View File

@ -1,319 +1,15 @@
local register_food = hunger.register_food
register_food("default:apple", 2)
if minetest.get_modpath("farming") then
register_food("farming:bread", 4)
end
if minetest.get_modpath("flowers") then
register_food("flowers:mushroom_brown", 1)
register_food("flowers:mushroom_red", 1, "", 3)
end
if minetest.get_modpath("mobs") then
if mobs.mod ~= nil and mobs.mod == "redo" then
register_food("mobs:cheese", 4)
register_food("mobs:meat", 8)
register_food("mobs:meat_raw", 4, "", 3)
register_food("mobs:rat_cooked", 4)
register_food("mobs:rat_meat", 2)
register_food("mobs:honey", 2)
register_food("mobs:pork_raw", 3, "", 3)
register_food("mobs:pork_cooked", 8)
register_food("mobs:chicken_cooked", 6)
register_food("mobs:chicken_raw", 2, "", 3)
register_food("mobs:chicken_egg_fried", 2)
register_food("mobs:rabbit_raw", 2, "", 3)
register_food("mobs_monster:rotten_flesh", 1, "", 4)
if minetest.get_modpath("bucket") then
register_food("mobs:bucket_milk", 3, "bucket:bucket_empty")
end
end
end
if minetest.get_modpath("moretrees") then
register_food("moretrees:coconut_milk", 1)
register_food("moretrees:raw_coconut", 2)
register_food("moretrees:acorn_muffin", 3)
register_food("moretrees:spruce_nuts", 1)
register_food("moretrees:pine_nuts", 1)
register_food("moretrees:fir_nuts", 1)
end
if minetest.get_modpath("dwarves") then
register_food("dwarves:beer", 2)
register_food("dwarves:apple_cider", 1)
register_food("dwarves:midus", 2)
register_food("dwarves:tequila", 2)
register_food("dwarves:tequila_with_lime", 2)
register_food("dwarves:sake", 2)
end
if minetest.get_modpath("animalmaterials") then
register_food("animalmaterials:milk", 2)
register_food("animalmaterials:meat_raw", 3)
register_food("animalmaterials:meat_pork", 3)
register_food("animalmaterials:meat_beef", 3)
register_food("animalmaterials:meat_chicken", 3)
register_food("animalmaterials:meat_lamb", 3)
register_food("animalmaterials:meat_venison", 3)
register_food("animalmaterials:meat_undead", 3, "", 3)
register_food("animalmaterials:meat_toxic", 3, "", 5)
register_food("animalmaterials:meat_ostrich", 3)
register_food("animalmaterials:fish_bluewhite", 2)
register_food("animalmaterials:fish_clownfish", 2)
end
if minetest.get_modpath("fishing") then
register_food("fishing:fish_raw", 2)
register_food("fishing:fish_cooked", 5)
register_food("fishing:sushi", 6)
register_food("fishing:shark", 4)
register_food("fishing:shark_cooked", 8)
register_food("fishing:pike", 4)
register_food("fishing:pike_cooked", 8)
end
if minetest.get_modpath("glooptest") then
register_food("glooptest:kalite_lump", 1)
end
if minetest.get_modpath("bushes") then
register_food("bushes:sugar", 1)
register_food("bushes:strawberry", 2)
register_food("bushes:berry_pie_raw", 3)
register_food("bushes:berry_pie_cooked", 4)
register_food("bushes:basket_pies", 15)
end
if minetest.get_modpath("bushes_classic") then
-- bushes_classic mod, as found in the plantlife modpack
local berries = {
"strawberry",
"blackberry",
"blueberry",
"raspberry",
"gooseberry",
"mixed_berry"}
for _, berry in ipairs(berries) do
if berry ~= "mixed_berry" then
register_food("bushes:" .. berry, 1)
end
register_food("bushes:" .. berry .. "_pie_raw", 2)
register_food("bushes:" .. berry .. "_pie_cooked", 5)
register_food("bushes:basket_" .. berry, 15)
end
end
if minetest.get_modpath("mushroom") then
register_food("mushroom:brown", 1)
register_food("mushroom:red", 1, "", 3)
-- mushroom potions: red = strong poison, brown = light restorative
if minetest.get_modpath("vessels") then
register_food("mushroom:brown_essence", 1, "vessels:glass_bottle", nil, 4)
register_food("mushroom:poison", 1, "vessels:glass_bottle", 10)
end
end
if minetest.get_modpath("docfarming") then
register_food("docfarming:carrot", 3)
register_food("docfarming:cucumber", 2)
register_food("docfarming:corn", 3)
register_food("docfarming:potato", 4)
register_food("docfarming:bakedpotato", 5)
register_food("docfarming:raspberry", 3)
end
if minetest.get_modpath("farming_plus") then
register_food("farming_plus:carrot_item", 3)
register_food("farming_plus:banana", 2)
register_food("farming_plus:orange_item", 2)
register_food("farming:pumpkin_bread", 4)
register_food("farming_plus:strawberry_item", 2)
register_food("farming_plus:tomato_item", 2)
register_food("farming_plus:potato_item", 4)
register_food("farming_plus:rhubarb_item", 2)
end
if minetest.get_modpath("mtfoods") then
register_food("mtfoods:dandelion_milk", 1)
register_food("mtfoods:sugar", 1)
register_food("mtfoods:short_bread", 4)
register_food("mtfoods:cream", 1)
register_food("mtfoods:chocolate", 2)
register_food("mtfoods:cupcake", 2)
register_food("mtfoods:strawberry_shortcake", 2)
register_food("mtfoods:cake", 3)
register_food("mtfoods:chocolate_cake", 3)
register_food("mtfoods:carrot_cake", 3)
register_food("mtfoods:pie_crust", 3)
register_food("mtfoods:apple_pie", 3)
register_food("mtfoods:rhubarb_pie", 2)
register_food("mtfoods:banana_pie", 3)
register_food("mtfoods:pumpkin_pie", 3)
register_food("mtfoods:cookies", 2)
register_food("mtfoods:mlt_burger", 5)
register_food("mtfoods:potato_slices", 2)
register_food("mtfoods:potato_chips", 3)
register_food("mtfoods:casserole", 3)
register_food("mtfoods:glass_flute", 2)
register_food("mtfoods:orange_juice", 2)
register_food("mtfoods:apple_juice", 2)
register_food("mtfoods:apple_cider", 2)
register_food("mtfoods:cider_rack", 2)
end
if minetest.get_modpath("fruit") then
register_food("fruit:apple", 2)
register_food("fruit:pear", 2)
register_food("fruit:bananna", 3)
register_food("fruit:orange", 2)
end
if minetest.get_modpath("mush45") then
register_food("mush45:meal", 4)
end
if minetest.get_modpath("seaplants") then
register_food("seaplants:kelpgreen", 1)
register_food("seaplants:kelpbrown", 1)
register_food("seaplants:seagrassgreen", 1)
register_food("seaplants:seagrassred", 1)
register_food("seaplants:seasaladmix", 6)
register_food("seaplants:kelpgreensalad", 1)
register_food("seaplants:kelpbrownsalad", 1)
register_food("seaplants:seagrassgreensalad", 1)
register_food("seaplants:seagrassgreensalad", 1)
end
if minetest.get_modpath("mobfcooking") then
register_food("mobfcooking:cooked_pork", 6)
register_food("mobfcooking:cooked_ostrich", 6)
register_food("mobfcooking:cooked_beef", 6)
register_food("mobfcooking:cooked_chicken", 6)
register_food("mobfcooking:cooked_lamb", 6)
register_food("mobfcooking:cooked_venison", 6)
register_food("mobfcooking:cooked_fish", 6)
end
if minetest.get_modpath("creatures") then
register_food("creatures:meat", 6)
register_food("creatures:flesh", 3)
register_food("creatures:rotten_flesh", 3, "", 3)
end
if minetest.get_modpath("ethereal") then
register_food("ethereal:strawberry", 1)
register_food("ethereal:banana", 4)
register_food("ethereal:pine_nuts", 1)
register_food("ethereal:bamboo_sprout", 0, "", 3)
register_food("ethereal:fern_tubers", 1)
register_food("ethereal:banana_bread", 7)
register_food("ethereal:mushroom_plant", 2)
register_food("ethereal:coconut_slice", 2)
register_food("ethereal:golden_apple", 4, "", nil, 10)
register_food("ethereal:wild_onion_plant", 2)
register_food("ethereal:mushroom_soup", 4, "ethereal:bowl")
register_food("ethereal:mushroom_soup_cooked", 6, "ethereal:bowl")
register_food("ethereal:hearty_stew", 6, "ethereal:bowl", 3)
register_food("ethereal:hearty_stew_cooked", 10, "ethereal:bowl")
if minetest.get_modpath("bucket") then
register_food("ethereal:bucket_cactus", 2, "bucket:bucket_empty")
end
register_food("ethereal:fish_raw", 2)
register_food("ethereal:fish_cooked", 5)
register_food("ethereal:seaweed", 1)
register_food("ethereal:yellowleaves", 1, "", nil, 1)
register_food("ethereal:sashimi", 4)
register_food("ethereal:orange", 2)
end
if minetest.get_modpath("farming") and farming.mod == "redo" then
register_food("farming:bread", 6)
register_food("farming:potato", 1)
register_food("farming:baked_potato", 6)
register_food("farming:cucumber", 4)
register_food("farming:tomato", 4)
register_food("farming:carrot", 3)
register_food("farming:carrot_gold", 6, "", nil, 8)
register_food("farming:corn", 3)
register_food("farming:corn_cob", 5)
register_food("farming:melon_slice", 2)
register_food("farming:pumpkin_slice", 1)
register_food("farming:pumpkin_bread", 9)
register_food("farming:coffee_cup", 2, "farming:drinking_cup")
register_food("farming:coffee_cup_hot", 3, "farming:drinking_cup", nil, 2)
register_food("farming:cookie", 2)
register_food("farming:chocolate_dark", 3)
register_food("farming:donut", 4)
register_food("farming:donut_chocolate", 6)
register_food("farming:donut_apple", 6)
register_food("farming:raspberries", 1)
register_food("farming:blueberries", 1)
register_food("farming:muffin_blueberry", 4)
if minetest.get_modpath("vessels") then
register_food("farming:smoothie_raspberry", 2, "vessels:drinking_glass")
end
register_food("farming:rhubarb", 1)
register_food("farming:rhubarb_pie", 6)
register_food("farming:beans", 1)
register_food("farming:grapes", 1)
end
if minetest.get_modpath("kpgmobs") then
register_food("kpgmobs:uley", 3)
register_food("kpgmobs:meat", 6)
register_food("kpgmobs:rat_cooked", 5)
register_food("kpgmobs:med_cooked", 4)
if minetest.get_modpath("bucket") then
register_food("kpgmobs:bucket_milk", 4, "bucket:bucket_empty")
end
end
if minetest.get_modpath("jkfarming") then
register_food("jkfarming:carrot", 3)
register_food("jkfarming:corn", 3)
register_food("jkfarming:melon_part", 2)
register_food("jkfarming:cake", 3)
end
if minetest.get_modpath("jkanimals") then
register_food("jkanimals:meat", 6)
end
if minetest.get_modpath("jkwine") then
register_food("jkwine:grapes", 2)
register_food("jkwine:winebottle", 1)
end
if minetest.get_modpath("cooking") then
register_food("cooking:meat_beef_cooked", 4)
register_food("cooking:fish_bluewhite_cooked", 3)
register_food("cooking:fish_clownfish_cooked", 1)
register_food("cooking:meat_chicken_cooked", 2)
register_food("cooking:meat_cooked", 2)
register_food("cooking:meat_pork_cooked", 3)
register_food("cooking:meat_toxic_cooked", -3)
register_food("cooking:meat_venison_cooked", 3)
register_food("cooking:meat_undead_cooked", 1)
end
-- ferns mod of plantlife_modpack
if minetest.get_modpath("ferns") then
register_food("ferns:fiddlehead", 1, "", 1)
register_food("ferns:fiddlehead_roasted", 3)
register_food("ferns:ferntuber_roasted", 3)
register_food("ferns:horsetail_01", 1)
end
if minetest.get_modpath("pizza") then
register_food("pizza:pizza", 30, "", nil, 30)
register_food("pizza:pizzaslice", 5, "", nil, 5)
end
if minetest.get_modpath("wine") then
register_food("wine:glass_wine", 2)
register_food("wine:glass_beer", 2)
register_food("wine:glass_mead", 2)
register_food("wine:glass_cider", 2)
end

View File

@ -177,7 +177,7 @@ local function poisenp(tick, time, time_left, player)
if time_left < time then
minetest.after(tick, poisenp, tick, time, time_left, player)
else
hud.change_item(player, "hunger", {text = "hud_hunger_fg.png"})
hud.change_item(player, "hunger", {text = "hunger_statbar_fg.png"})
end
local hp = player:get_hp() -1 or 0
if hp > 0 then

View File

@ -18,16 +18,21 @@ HUNGER_STARVE_LVL = 3 -- level of staturation that causes starving
HUNGER_MAX = 30 -- maximum level of saturation
-- 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
if minetest.settings:get_bool("enable_damage") then
hud.register("hunger", {
hud_elem_type = "statbar",
position = {x = 0.5, y = 1},
size = {x = 24, y = 24},
text = "hunger_statbar_fg.png",
number = 20,
alignment = {x = -1, y = -1},
offset = {x = 8, y = -109},
background = "hunger_statbar_bg.png",
max = 20,
})
local modpath = minetest.get_modpath("hunger")
dofile(modpath .. "/functions.lua")
dofile(modpath .. "/food.lua")

View File

Before

Width:  |  Height:  |  Size: 226 B

After

Width:  |  Height:  |  Size: 226 B

View File

Before

Width:  |  Height:  |  Size: 366 B

After

Width:  |  Height:  |  Size: 366 B

View File

@ -1,5 +1,3 @@
local show_armor = minetest.get_modpath("3d_armor")
local function drop_fields(player, name)
local inv = player:get_inventory()
for i,stack in ipairs(inv:get_list(name)) do
@ -24,7 +22,7 @@ local function set_inventory(player)
"list[detached:split;main;8,3.14;1,1;]"..
"image[1.5,0;2,4;default_player2d.png]"
-- Armor
if show_armor then
if minetest.get_modpath("3d_armor") then
local player_name = player:get_player_name()
form = form ..
"list[detached:"..player_name.."_armor;armor;0,0;1,1;]"..

View File

@ -148,7 +148,7 @@ minetest.register_craftitem(":mobs:bucket_milk", {
description = "Bucket of Milk",
inventory_image = "mobs_bucket_milk.png",
stack_max = 1,
on_use = minetest.item_eat(8, 'bucket:bucket_empty'),
on_use = minetest.item_eat(8, "bucket:bucket_empty"),
groups = {food_milk = 1, flammable = 3},
})

View File

@ -375,7 +375,7 @@ function stairs.register_stair_and_slab(subname, recipeitem, groups, images,
desc_stair, desc_slab, sounds, alpha)
-- stairs.register_stair(subname, recipeitem, groups, images, desc_stair, sounds, alpha)
-- stairs.register_slab(subname, recipeitem, groups, images, desc_slab, sounds, alpha)
stairs.register_slope(subname, recipeitem, groups, images, desc_stair, snds, alpha)
stairs.register_slope(subname, recipeitem, groups, images, desc_stair, sounds, alpha)
end
-- Nodes will be called stairs:{stair,slab,corner,invcorner,slope}_<subname>