Skip to content

Commit

Permalink
Hunger Mods Support + more
Browse files Browse the repository at this point in the history
Supports hbhunger
Supports hunger_ng
Code Change to make non-MTG use easier
Addition of drinking sound
Farming Redo Support Added
Mobs_Animal Support Added
Ethereal Support Added
New Thirst Icon
New Canteen Icon
New Bowl icon
  • Loading branch information
sirrobzeroone committed Sep 21, 2021
1 parent debe438 commit 4bae22e
Show file tree
Hide file tree
Showing 28 changed files with 281 additions and 71 deletions.
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,24 @@ Version: 0.10.2

License:
Code: LGPL 2.1 (see included LICENSE file)
Textures: CC-BY-SA (see http://creativecommons.org/licenses/by-sa/4.0/)
Textures:
vessels_glass_bottle_full_cc_by_sa_3.png
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
modified from vessels_glass_bottle.png
Copyright (C) 2012-2016 Vanessa Ezekowitz
Copyright (C) 2016 Thomas-S

thirsty_drop_100_24_cc0.png +.xcf
thirsty_drop_100_16_cc0.png
thirsty_wooden_bowl_cc0.png +.xcf
thirsty_bronze_canteen_cc0.png +.xcf
thirsty_steel_canteen_cc0.png
thirsty_amulet_moisture_cc0.png +.xcf
thirsty_amulet_hydration_cc0.png +.xcf
Public Domain CC0 1.0 Universal
Sirrobzeroone

All other Images CC BY-SA 4.0 (see http://creativecommons.org/licenses/by-sa/4.0/)

Report bugs or request help on the forum topic.

Expand Down
80 changes: 43 additions & 37 deletions components.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,43 @@

local E = thirsty.ext_nodes_items

----------------------------
--------------------------
-- Tier 0 Hydrate Nodes --
----------------------------
if minetest.get_modpath("default") then
thirsty.register_hydrate_node("default:water_source")
thirsty.register_hydrate_node("default:water_flowing")
thirsty.register_hydrate_node("default:river_water_source")
thirsty.register_hydrate_node("default:river_water_flowing")
--------------------------
if minetest.registered_items[E.water_source] then
thirsty.register_hydrate_node(E.water_source)
end

if minetest.registered_items[E.water_source_f] then
thirsty.register_hydrate_node(E.water_source_f)
end

if minetest.registered_items[E.water_source_riv] then
thirsty.register_hydrate_node(E.water_source_riv)
end

if minetest.registered_items[E.water_source_riv_f] then
thirsty.register_hydrate_node(E.water_source_riv_f)
end


-------------------------------------------
-- Tier 1 Drink from nodes using cup etc --
-------------------------------------------

-- Nodes --
-- see drinking fountain


-- Items --
if minetest.get_modpath("vessels") and thirsty.config.register_vessels then
if minetest.registered_items[E.drinking_glass] and thirsty.config.register_vessels then
-- add "drinking" to vessels
thirsty.augment_item_for_drinking('vessels:drinking_glass', 20)
thirsty.augment_item_for_drinking(E.drinking_glass, 20)
end

if minetest.get_modpath("default") and thirsty.config.register_bowl and not minetest.registered_craftitems["farming:bowl"] then
if thirsty.config.register_bowl and not minetest.registered_items[E.wood_bowl] then
-- our own simple wooden bowl
minetest.register_craftitem('thirsty:wooden_bowl', {
description = "Wooden bowl",
inventory_image = "thirsty_bowl_16.png",
inventory_image = "thirsty_bowl_cc0.png",
liquids_pointable = true,
})

Expand All @@ -55,9 +63,9 @@ end
thirsty.augment_item_for_drinking("thirsty:wooden_bowl", 22)

-- modify farming redo wooden bowl to be usable.
elseif thirsty.config.register_bowl and minetest.registered_craftitems["farming:bowl"] then
elseif thirsty.config.register_bowl and minetest.registered_items[E.wood_bowl] then

thirsty.augment_item_for_drinking("farming:bowl", 22)
thirsty.augment_item_for_drinking(E.wood_bowl, 22)

end

Expand All @@ -76,37 +84,27 @@ Wear corresponds to hydro level as follows:
]]

if minetest.get_modpath("mobs_animal") and thirsty.config.register_glass_milk and minetest.registered_items["mobs:glass_milk"] then

local def = table.copy(minetest.registered_items["mobs:glass_milk"])
def.on_use = function(itemstack,player,pointed_thing)
thirsty.drink(player,2,22,"vessels:drinking_glass")
minetest.do_item_eat(1,nil, itemstack:take_item(), player, pointed_thing)
return itemstack
end

minetest.register_craftitem(":mobs:glass_milk", def)

if thirsty.config.register_vessels and minetest.registered_items[E.glass_bottle] then
thirsty.register_canteen_complex(E.glass_bottle,10,22,E.glass_bottle_f)
end

if minetest.get_modpath("vessels") and thirsty.config.register_vessels then

thirsty.register_canteen_complex("vessels:glass_bottle",10,22,"vessels_glass_bottle_full_cc_by_sa_3.png")
thirsty.register_canteen_complex("vessels:steel_bottle",20,24)

if thirsty.config.register_vessels and minetest.registered_items[E.steel_bottle] then
thirsty.register_canteen_complex(E.steel_bottle,20,24)
end


if minetest.get_modpath("default") and thirsty.config.register_canteens then
if thirsty.config.register_canteens and
minetest.registered_items[E.steel_ingot] and
minetest.registered_items[E.bronze_ingot] then

minetest.register_craftitem('thirsty:steel_canteen', {
description = 'Steel canteen',
inventory_image = "thirsty_steel_canteen_16.png",
inventory_image = "thirsty_steel_canteen_cc0.png",
})

minetest.register_craftitem("thirsty:bronze_canteen", {
description = "Bronze canteen",
inventory_image = "thirsty_bronze_canteen_16.png",
inventory_image = "thirsty_bronze_canteen_cc0.png",
})

thirsty.register_canteen("thirsty:steel_canteen",40,25)
Expand Down Expand Up @@ -135,7 +133,9 @@ end
-- Tier 3 Drinking Fountain --
-------------------------------

if minetest.get_modpath("default") and minetest.get_modpath("bucket") and thirsty.config.register_drinking_fountain then
if thirsty.config.register_drinking_fountain and
minetest.registered_items[E.stone] and
minetest.registered_items[E.bucket_water]then

minetest.register_node('thirsty:drinking_fountain', {
description = 'Drinking fountain',
Expand Down Expand Up @@ -193,7 +193,10 @@ end
-- Tier 4: Water fountains, Water extenders --
----------------------------------------------

if minetest.get_modpath("default") and minetest.get_modpath("bucket") and thirsty.config.register_fountains then
if thirsty.config.register_fountains and
minetest.registered_items[E.copper_ingot] and
minetest.registered_items[E.mese_crystal] and
minetest.registered_items[E.bucket_water] then

minetest.register_node('thirsty:water_fountain', {
description = 'Water fountain',
Expand Down Expand Up @@ -262,7 +265,10 @@ they are searched for in player's inventories
]]

if minetest.get_modpath("default") and minetest.get_modpath("bucket") and thirsty.config.register_amulets then
if thirsty.config.register_amulets and
minetest.registered_items[E.diamond] and
minetest.registered_items[E.mese_crystal] and
minetest.registered_items[E.bucket_water] then

minetest.register_craftitem('thirsty:injector', {
description = 'Amulet of Hydration',
Expand Down
39 changes: 29 additions & 10 deletions components_external_nodes_items.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,35 @@ These are nodes and items required to make canteens and
fountains. Simply change the name here to change the reference
across the whole mod.
]]--

local E = thirsty.ext_nodes_items

-- item and node mod aliases, change these as needed.
E.group_wood = "group:wood"
E.stone = "default:stone"
E.steel_ingot = "default:steel_ingot"
E.bronze_ingot = "default:bronze_ingot"
E.copper_ingot = "default:copper_ingot"
E.mese_crystal = "default:mese_crystal"
E.diamond = "default:diamond"
E.bucket_water = "bucket:bucket_water"
E.bucket_empty = "bucket:bucket_empty"
-- if item dosen't exist as either Ing or Aug item
-- it wont register.

-- Basic Water, change here or register
-- using thirsty.register_hydrate_node()
-- and leave these unchanged.
E.water_source = "default:water_source"
E.water_source_f = "default:water_flowing"
E.water_source_riv = "default:river_water_source"
E.water_source_riv_f = "default:river_water_flowing"

-- Ingredients
E.group_wood = "group:wood"
E.stone = "default:stone"
E.steel_ingot = "default:steel_ingot"
E.bronze_ingot = "default:bronze_ingot"
E.copper_ingot = "default:copper_ingot"
E.mese_crystal = "default:mese_crystal"
E.diamond = "default:diamond"
E.bucket_water = "bucket:bucket_water"
E.bucket_empty = "bucket:bucket_empty"

-- Augumented Items
E.drinking_glass = "vessels:drinking_glass"
E.glass_bottle = "vessels:glass_bottle" -- looks like glass potion bottle
E.glass_bottle_f = "vessels_glass_bottle_full_cc_by_sa_3.png" -- image for registering full version of above
E.steel_bottle = "vessels:steel_bottle"
E.wood_bowl = "farming:bowl"
E.glass_milk = "mobs:glass_milk" -- note needs E.drinking_glass for empty return item
1 change: 1 addition & 0 deletions functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ function thirsty.drink(player, value, max, empty_vessel)
hydro = math.min(hydro + value, max)
--print("Drinking by "..value.." to "..hydro)
pmeta:set_float("thirsty_hydro", hydro)
minetest.sound_play("thirsty_breviceps_drink-drinking-liquid", { to_player = player:get_player_name(), gain = 2.0, })

if empty_vessel then
player:get_inventory():add_item("main", empty_vessel.." 1")
Expand Down
4 changes: 2 additions & 2 deletions hud.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ end
if minetest.get_modpath("hudbars") then
hb.register_hudbar('thirst', 0xffffff, "Hydration", {
bar = 'thirsty_hudbars_bar.png',
icon = 'thirsty_cup_100_16.png'
icon = 'thirsty_drop_100_24_cc0.png'
}, 20, 20, false)
function thirsty.hud_init(player)
local pmeta = player:get_meta()
Expand All @@ -60,7 +60,7 @@ else
thirsty.players[name].hud_id = player:hud_add({
hud_elem_type = "statbar",
position = { x=0.5, y=1 },
text = "thirsty_cup_100_24.png",
text = "thirsty_drop_100_24_cc0.png",
number = thirsty.hud_clamp(pmeta:get_float("thirsty_hydro")),
direction = 0,
size = { x=24, y=24 },
Expand Down
39 changes: 22 additions & 17 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
--Media/Images--
vessels_glass_bottle_full_cc_by_sa_3.png
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
modified from vessels_glass_bottle.png
Copyright (C) 2012-2016 Vanessa Ezekowitz
Copyright (C) 2016 Thomas-S
thirsty_amulet_moisture_cc0.png
Public Domain CC0
Sirrobzeroone
thirsty_amulet_hydration_cc0.png
Public Domain CC0
Sirrobzeroone
See Readme.MD - Mix of:
CC BY-SA 3.0
CC BY-SA 4.0
CC0 1.0 Universal
-------------------------------------------
-- Terminology: "Thirst" vs. "hydration" --
Expand Down Expand Up @@ -138,15 +129,29 @@ thirsty = {

local M = thirsty
local C = M.config
local modpath = minetest.get_modpath("thirsty")

thirsty.time_next_tick = thirsty.config.tick_time

dofile(minetest.get_modpath('thirsty')..'/hud.lua')
dofile(minetest.get_modpath('thirsty')..'/functions.lua')
dofile(modpath..'/hud.lua')
dofile(modpath..'/functions.lua')

minetest.register_on_joinplayer(thirsty.on_joinplayer)
minetest.register_on_dieplayer(thirsty.on_dieplayer)
minetest.register_globalstep(thirsty.main_loop)

dofile(minetest.get_modpath('thirsty')..'/components_external_nodes_items.lua')
dofile(minetest.get_modpath('thirsty')..'/components.lua')
dofile(modpath..'/components_external_nodes_items.lua')
dofile(modpath..'/components.lua')
dofile(modpath..'/interop_a_functions.lua')


-- mobs_animal specific config
if minetest.get_modpath("mobs_animal") then
dofile(modpath..'/interop_mobs_animal.lua')
end

-- farming(redo) specific config
if minetest.get_modpath("farming") and
farming.mod == "redo" then
dofile(modpath..'/interop_farming_redo.lua')
end
55 changes: 55 additions & 0 deletions interop_a_functions.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
------------------------------------------------------------
-- _____ _ _ _ --
-- |_ _| |_ (_)_ _ __| |_ _ _ --
-- | | | ' \| | '_(_-< _| || | --
-- |_| |_||_|_|_| /__/\__|\_, | --
-- |__/ --
------------------------------------------------------------
-- Thirsty mod [interoperability function] --
------------------------------------------------------------
-- because I'm lazy and like small code blocks --
------------------------------------------------------------

thirsty.register_hb_hng_drink = function (item_name,satiate_value,heal_value,hyd_value,hyd_max,rtn_item_name)

local is_hunger_ng = false
local is_hbhunger = false
if minetest.get_modpath("hunger_ng") then is_hunger_ng = true end
if minetest.get_modpath("hbhunger") then is_hbhunger = true end

if is_hunger_ng then
hunger_ng.add_hunger_data(item_name,{
satiates = satiate_value,
heals = heal_value,
returns = nil,
timeout = nil
})
end

if is_hbhunger then
hbhunger.register_food(item_name, satiate_value)
end

local def = table.copy(minetest.registered_items[item_name])
def.on_use = function(itemstack,player,pointed_thing)

thirsty.drink(player,hyd_value,hyd_max,rtn_item_name)

if minetest.registered_items[item_name]._hunger_ng then
hunger_ng.alter_hunger(player:get_player_name(), satiate_value, "from:thirsty-"..item_name)
player:set_hp(player:get_hp()+heal_value)
itemstack:take_item()
return itemstack
else
minetest.do_item_eat(satiate_value,nil, itemstack:take_item(), player, pointed_thing)
return itemstack
end

end

if def.type == "node" then
minetest.register_node(":"..item_name, def)
else
minetest.register_craftitem(":"..item_name, def)
end
end
20 changes: 20 additions & 0 deletions interop_ethereal.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
------------------------------------------------------------
-- _____ _ _ _ --
-- |_ _| |_ (_)_ _ __| |_ _ _ --
-- | | | ' \| | '_(_-< _| || | --
-- |_| |_||_|_|_| /__/\__|\_, | --
-- |__/ --
------------------------------------------------------------
-- Thirsty mod [interop_ethereal] --
------------------------------------------------------------
-- Settings to support Ethereal --
------------------------------------------------------------

local E = thirsty.ext_nodes_items
----------------------------
-- Hydrate and Food Items --
----------------------------
thirsty.register_hb_hng_drink("ethereal:firethorn_jelly" ,1,0,1,20,E.glass_bottle)
thirsty.register_hb_hng_drink("ethereal:mushroom_soup" ,2.5,0,2,20,ethereal:bowl)
thirsty.register_hb_hng_drink("ethereal:hearty_stew" ,7.0,0,1,20,ethereal:bowl)
thirsty.register_hb_hng_drink("ethereal:golden_apple" ,10,10,10,30,nil)
Loading

0 comments on commit 4bae22e

Please sign in to comment.