42 Commits

Author SHA1 Message Date
b771cb143e Version 0.7.1 2018-06-01 11:59:22 +02:00
4e8621632a Fixed bug with node breakers
This bug fix fixes a crash that happened whenever someone was
operating a node breaker with something edible inside the tool slot,
and the operator player is absent.
2018-06-01 11:58:52 +02:00
dd2f4c9c6d Version 0.7.0 2018-02-05 21:22:04 +01:00
6b48fb67b3 Add Malay locale by muhdnurhidayat 2018-02-05 21:21:30 +01:00
47845f184b Version 0.6.0 2017-09-18 16:49:14 +02:00
cb07c065ea Use MIT License 2017-09-18 16:33:29 +02:00
8041e9ee62 Add Italian locale by Hamlet 2017-09-18 16:32:23 +02:00
bd3f43dd2e Version 0.5.3 2017-07-12 23:25:46 +02:00
acac4fe33f replace_with_item: Fix item disappear if inv full 2017-07-12 23:24:58 +02:00
3d7d613622 Update deprecated settings syntax 2017-06-20 16:50:57 +02:00
da70eba4fd Version 0.5.2 2016-11-12 20:19:48 +01:00
6df9d499e7 Fix typos 2016-11-12 20:19:11 +01:00
ef6b974bfd Rewrite README file and convert to Markdown 2016-11-12 20:14:14 +01:00
d0174cb6f5 Fix outdated intllib boilerplate 2016-11-09 01:51:15 +01:00
a522c4da39 Add screenshot 2016-11-03 23:17:39 +01:00
edc2034647 Comment for is_fake_player 2016-10-29 20:56:05 +02:00
b0ac4c3765 Version 0.5.1 2016-10-29 20:46:01 +02:00
bd343a1643 Ignore fake players from pipeworks mod 2016-10-29 20:42:09 +02:00
e4d74685f6 Release 0.5.0 2016-10-22 13:13:06 +02:00
7cb10b31d6 Translation into portuguese 2016-10-20 15:30:21 -02:00
3763748e89 Fixed custom sound 2016-10-20 15:25:19 -02:00
ba6bfffc9d Version 0.4.1 2016-10-05 12:58:28 +02:00
f025e71d69 Add nssm foods
Kudos to TenPlus1
2016-10-05 12:56:08 +02:00
4f5d245e85 Less namespace pollution, rename hunger functions 2016-08-11 18:10:54 +02:00
e8209a0101 Update info in README 2016-08-05 18:45:46 +02:00
558790a05c Explain statbar particularities 2016-08-05 18:35:23 +02:00
c0d32203e1 Fix satiation info 2016-08-05 18:24:40 +02:00
a9d8f0f859 Add whole number of poisenp 2016-08-05 18:09:00 +02:00
d259cf59d2 Add metadata 2016-08-05 17:03:19 +02:00
7e084c50d2 Add intllib support and German 2016-08-05 16:58:00 +02:00
5ea402b3f8 Version 0.4.0 + changelog 2016-08-05 15:38:27 +02:00
abbf003145 Fix crash when poisoned player leaves server 2016-08-05 15:36:31 +02:00
30b0b41e3e Change health bar color+icon on poisoning 2016-08-05 15:29:13 +02:00
0d1f2fc7cc Generic item_eat overwrite, changes license 2016-08-05 14:56:58 +02:00
be3d491cf8 Use minetest.override_item 2016-08-05 14:28:19 +02:00
f028f6c8d8 Add support for MTG shrooms, pizza, FR beans 2016-08-05 14:25:45 +02:00
98309f5a44 Bump version, update changelog 2015-07-01 02:12:52 +02:00
ac4a5ad22f Fix hunger crash (2)
Thanks to Ombridride
2015-07-01 02:11:34 +02:00
2f37d00c59 Update readme and changelog 2015-06-28 14:29:38 +02:00
6a1c5d439a Fix exhaus bug 2015-06-28 14:28:47 +02:00
b67ae1764f Add Ethereal orange 2015-06-28 14:27:07 +02:00
d257362ef0 Add background icon 2015-05-19 23:53:51 +02:00
17 changed files with 480 additions and 311 deletions

97
README.md Normal file
View File

@ -0,0 +1,97 @@
# Hunger with HUD bar [`hbhunger`]
* Version: 0.7.1
## Using the mod
This mod adds a mechanic for hunger.
This mod depends on the HUD bars mod [`hudbars`], version 1.4.1 or any later version
starting with “1.”.
## About hunger
This mod adds a hunger mechanic to the game. Players get a new attribute called “satiation”:
* A new player starts with 20 satiation points out of 30
* Actions like digging, placing and walking cause exhaustion, which lower the satiation
* Every 800 seconds you lose 1 satiation point without doing anything
* At 1 or 0 satiation you will suffer damage and die in case you don't eat something
* If your satiation is 16 or higher, you will slowly regenerate health points
* Eating food will increase your satiation (Duh!)
Important: Eating food will not directly increase your health anymore, as long as the food
item is supported by this mod (see below).
Careful! Some foods may be poisoned. If you eat a poisoned item, you may still get a satiation
boost, but for a brief period you lose health points because of food poisoning. However,
food poisoning can never kill you.
## Statbar mode
If you use the statbar mode of the HUD Bars mod, these things are important to know:
As with all mods using HUD Bars, the bread statbar symbols represent the rough percentage
out of 30 satiation points, in steps of 5%, so the symbols give you an estimate of your
satiation. This is different from the hunger mod by BlockMen.
You gain health at 5.5 symbols or more, as 5.5 symbols correspond to 16 satiation points.
You *may* lose health at exactly 0.5 symbols, as 0.5 symbols correspond to 1-2 satiation points.
## Supported food
All mods which add food through standard measures (`minetest.item_eat`) are already
supported automatically. Poisoned food needs special support.
### Known supported food mods
* Apple from Minetest Game [`default`]
* Red and brown mushroom from Minetest Game [`flowers`]
* Bread from Minetest Game [`farming`]
* [`animalmaterials`] (Mob Framework (`mobf` modpack))
* Bushes [`bushes`]
* [`bushes_classic`]
* Creatures [`creatures`]
* [`dwarves`] (beer and such)
* Docfarming [`docfarming`]
* Ethereal / Ethereal NG [`ethereal`]
* Farming Redo [`farming`] by TenPlus1
* Farming plus [`farming_plus`]
* Ferns [`ferns`]
* Fishing [`fishing`]
* [`fruit`]
* Glooptest [`glooptest`]
* JKMod ([`jkanimals`], [`jkfarming`], [`jkwine`])
* [`kpgmobs`]
* [`mobfcooking`]
* [`mooretrees`]
* [`mtfoods`]
* [`mushroom`]
* [`mush45`]
* Seaplants [`sea`]
* Simple mobs [`mobs`]
* Pizza [`pizza`]
* Not So Simple Mobs [`nssm`]
### Supported mods without optional dependency (mods provide their own support)
* Food ([`food`], [`food_basic`])
* Sweet Foods [`food_sweet`]
### Examples
* Eating an apple (from Minetest Game) increases your satiation by 2;
* eating a bread (from Minetest Game) increases your satiation by 4.
## Licensing
This mod is free software.
### Source code
* License: [LGPL v2.1](https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html)
* Author: by Wuzzy (2015-2016)
* Forked from the “Better HUD (and hunger)” mod by BlockMen (2013-2015),
most code comes from this mod.
### Textures
* `hbhunger_icon.png`—PilzAdam ([MIT License](https://opensource.org/licenses/MIT)), modified by BlockMen
* `hbhunger_bgicon.png`—PilzAdam (MIT License), modified by BlockMen
* `hbhunger_bar.png—Wuzzy` (MIT License)
* `hbhunger_icon_health_poison.png`—celeron55 ([CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/)), modified by BlockMen, modified again by Wuzzy
* Everything else: MIT License, by BlockMen and Wuzzy

View File

@ -1,75 +0,0 @@
Minetest mod: Hunger [hbhunger]
===============================
Version: 0.3.0
License of source code: WTFPL
-----------------------------
by Wuzzy (2015)
Forked from the “Better HUD (and hunger)” mod by BlockMen (2013-2014).
Using the mod:
--------------
This mod adds a mechanic for hunger.
This mod depends on the HUD bars mod [hudbars], major version 1.
You can create a "hunger.conf" file to customize the properties of hunger for your needs.
About hunger
============
This mod adds a hunger mechanic to the game.
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
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).
Currently supported food:
-------------------------
- Apples (default)
- Animalmaterials (mobf modpack)
- Bread (default)
- Bushes
- bushes_classic
- Creatures
- Dwarves (beer and such)
- Docfarming
- Fishing
- Farming plus
- Farming (default and Tenplus1's fork)
- Food
- fruit
- Glooptest
- JKMod
- kpgmobs
- Mobfcooking
- Mooretrees
- Mtfoods
- mushroom
- mush45
- Seaplants (sea)
- Simple mobs
Examples:
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:
--------------------
hunger_icon.png - PilzAdam (WTFPL), modified by BlockMen
hunger_bar.png - Wuzzy (WTFPL)
everything else is WTFPL:
(c) Copyright BlockMen (2013-2015)
This program is free software. It comes without any warranty, to
the extent permitted by applicable law. You can redistribute it
and/or modify it under the terms of the Do What The Fuck You Want
To Public License, Version 2, as published by Sam Hocevar. See
http://sam.zoy.org/wtfpl/COPYING for more details.

View File

@ -11,3 +11,41 @@ Initial release
0.3.0
-----
- Play simple eating sound when something is eaten
0.3.1
-----
- Add Ethereal orange
- Fix exhaus variable
0.3.2
-----
- Fix another crash
0.4.0
-----
- Generic eating functionality, items using the minetest.item_eat are automatically supported
- Change health bar and icon when poisoned
- Special support for red and brown mushroom from Minetest Game [flowers]
- Special support for [pizza]
- Special support for beans from Farming Redo [farming]
- Fix crash when poisoned player leaves server
- Changed license to LGPL v2.1
0.4.1
-----
- Add foods from Not So Simple Mobs [nssm]
0.5.0
-----
- Fix custom sound not working
- Add Portuguese translation
0.5.1
-----
- Fix incompability problem with pipeworks mod
0.5.2
-----
- Fix mod not working with both intllib and mod security enabled
- Add missing screenshot
- Rewrite README and use Markdown format

View File

@ -1,5 +1,7 @@
hudbars
intllib?
default?
flowers?
animalmaterials?
bucket?
bushes?
@ -26,3 +28,5 @@ mtfoods?
mush45?
mushroom?
seaplants?
pizza?
nssm?

1
description.txt Normal file
View File

@ -0,0 +1 @@
Adds a simple hunger meachanic with satiation, food poisoning and different healing.

View File

@ -1,18 +1,68 @@
-- Keep these for backwards compatibility
function hbhunger.save_hunger(player)
hbhunger.set_hunger(player)
hbhunger.set_hunger_raw(player)
end
function hbhunger.load_hunger(player)
hbhunger.get_hunger(player)
hbhunger.get_hunger_raw(player)
end
-- wrapper for minetest.item_eat (this way we make sure other mods can't break this one)
local org_eat = core.do_item_eat
core.do_item_eat = function(hp_change, replace_with_item, itemstack, user, pointed_thing)
local old_itemstack = itemstack
itemstack = hbhunger.eat(hp_change, replace_with_item, itemstack, user, pointed_thing)
for _, callback in pairs(core.registered_on_item_eats) do
local result = callback(hp_change, replace_with_item, itemstack, user, pointed_thing, old_itemstack)
if result then
return result
end
end
return itemstack
end
-- food functions
local food = hbhunger.food
function hbhunger.register_food(name, hunger_change, replace_with_item, poisen, heal, sound)
food[name] = {}
food[name].saturation = hunger_change -- hunger points added
food[name].replace = replace_with_item -- what item is given back after eating
food[name].poisen = poisen -- time its poisening
food[name].healing = heal -- amount of HP
food[name].sound = sound -- special sound that is played when eating
end
function hbhunger.eat(hp_change, replace_with_item, itemstack, user, pointed_thing)
local item = itemstack:get_name()
local def = food[item]
if not def then
def = {}
if type(hp_change) ~= "number" then
hp_change = 1
core.log("error", "Wrong on_use() definition for item '" .. item .. "'")
end
def.saturation = hp_change * 1.3
def.replace = replace_with_item
end
local func = hbhunger.item_eat(def.saturation, def.replace, def.poisen, def.healing, def.sound)
return func(itemstack, user, pointed_thing)
end
-- Poison player
local function poisenp(tick, time, time_left, player)
-- First check if player is still there
if not player:is_player() then
return
end
time_left = time_left + tick
if time_left < time then
minetest.after(tick, poisenp, tick, time, time_left, player)
else
--reset hud image
hbhunger.poisonings[player:get_player_name()] = hbhunger.poisonings[player:get_player_name()] - 1
if hbhunger.poisonings[player:get_player_name()] <= 0 then
-- Reset HUD bar color
hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health.png", nil, "hudbars_bar_health.png")
end
end
if player:get_hp()-1 > 0 then
player:set_hp(player:get_hp()-1)
@ -20,20 +70,23 @@ local function poisenp(tick, time, time_left, player)
end
function hbhunger.item_eat(hunger_change, replace_with_item, poisen, heal)
function hbhunger.item_eat(hunger_change, replace_with_item, poisen, heal, sound)
return function(itemstack, user, pointed_thing)
if itemstack:take_item() ~= nil and user ~= nil then
local name = user:get_player_name()
local h = tonumber(hbhunger.hunger[name])
local hp = user:get_hp()
minetest.sound_play({name = "hbhunger_eat_generic", gain = 1}, {pos=user:getpos(), max_hear_distance = 16})
if h == nil or hp == nil then
return
end
minetest.sound_play({name = sound or "hbhunger_eat_generic", gain = 1}, {pos=user:getpos(), max_hear_distance = 16})
-- Saturation
if h < 30 and hunger_change then
h = h + hunger_change
if h > 30 then h = 30 end
hbhunger.hunger[name] = h
hbhunger.set_hunger(user)
hbhunger.set_hunger_raw(user)
end
-- Healing
if hp < 20 and heal then
@ -43,106 +96,113 @@ function hbhunger.item_eat(hunger_change, replace_with_item, poisen, heal)
end
-- Poison
if poisen then
--set hud-img
poisenp(1.0, poisen, 0, user)
-- Set poison bar
hb.change_hudbar(user, "health", nil, nil, "hbhunger_icon_health_poison.png", nil, "hbhunger_bar_health_poison.png")
hbhunger.poisonings[name] = hbhunger.poisonings[name] + 1
poisenp(1, poisen, 0, user)
end
--sound:eat
itemstack:add_item(replace_with_item)
if itemstack:get_count() == 0 then
itemstack:add_item(replace_with_item)
else
local inv = user:get_inventory()
if inv:room_for_item("main", replace_with_item) then
inv:add_item("main", replace_with_item)
else
minetest.add_item(user:getpos(), replace_with_item)
end
end
end
return itemstack
end
end
local function overwrite(name, hunger_change, replace_with_item, poisen, heal)
local tab = minetest.registered_items[name]
if tab == nil then return end
tab.on_use = hbhunger.item_eat(hunger_change, replace_with_item, poisen, heal)
minetest.registered_items[name] = tab
end
if minetest.get_modpath("default") ~= nil then
overwrite("default:apple", 2)
hbhunger.register_food("default:apple", 2)
end
if minetest.get_modpath("flowers") ~= nil then
hbhunger.register_food("flowers:mushroom_brown", 1)
hbhunger.register_food("flowers:mushroom_red", 1, "", 3)
end
if minetest.get_modpath("farming") ~= nil then
overwrite("farming:bread", 4)
hbhunger.register_food("farming:bread", 4)
end
if minetest.get_modpath("mobs") ~= nil then
if mobs.mod ~= nil and mobs.mod == "redo" then
overwrite("mobs:cheese", 4)
overwrite("mobs:meat", 8)
overwrite("mobs:meat_raw", 4)
overwrite("mobs:rat_cooked", 4)
overwrite("mobs:honey", 2)
overwrite("mobs:pork_raw", 3, "", 3)
overwrite("mobs:pork_cooked", 8)
overwrite("mobs:chicken_cooked", 6)
overwrite("mobs:chicken_raw", 2, "", 3)
overwrite("mobs:chicken_egg_fried", 2)
hbhunger.register_food("mobs:cheese", 4)
hbhunger.register_food("mobs:meat", 8)
hbhunger.register_food("mobs:meat_raw", 4)
hbhunger.register_food("mobs:rat_cooked", 4)
hbhunger.register_food("mobs:honey", 2)
hbhunger.register_food("mobs:pork_raw", 3, "", 3)
hbhunger.register_food("mobs:pork_cooked", 8)
hbhunger.register_food("mobs:chicken_cooked", 6)
hbhunger.register_food("mobs:chicken_raw", 2, "", 3)
hbhunger.register_food("mobs:chicken_egg_fried", 2)
if minetest.get_modpath("bucket") then
overwrite("mobs:bucket_milk", 3, "bucket:bucket_empty")
hbhunger.register_food("mobs:bucket_milk", 3, "bucket:bucket_empty")
end
else
overwrite("mobs:meat", 6)
overwrite("mobs:meat_raw", 3)
overwrite("mobs:rat_cooked", 5)
hbhunger.register_food("mobs:meat", 6)
hbhunger.register_food("mobs:meat_raw", 3)
hbhunger.register_food("mobs:rat_cooked", 5)
end
end
if minetest.get_modpath("moretrees") ~= nil then
overwrite("moretrees:coconut_milk", 1)
overwrite("moretrees:raw_coconut", 2)
overwrite("moretrees:acorn_muffin", 3)
overwrite("moretrees:spruce_nuts", 1)
overwrite("moretrees:pine_nuts", 1)
overwrite("moretrees:fir_nuts", 1)
hbhunger.register_food("moretrees:coconut_milk", 1)
hbhunger.register_food("moretrees:raw_coconut", 2)
hbhunger.register_food("moretrees:acorn_muffin", 3)
hbhunger.register_food("moretrees:spruce_nuts", 1)
hbhunger.register_food("moretrees:pine_nuts", 1)
hbhunger.register_food("moretrees:fir_nuts", 1)
end
if minetest.get_modpath("dwarves") ~= nil then
overwrite("dwarves:beer", 2)
overwrite("dwarves:apple_cider", 1)
overwrite("dwarves:midus", 2)
overwrite("dwarves:tequila", 2)
overwrite("dwarves:tequila_with_lime", 2)
overwrite("dwarves:sake", 2)
hbhunger.register_food("dwarves:beer", 2)
hbhunger.register_food("dwarves:apple_cider", 1)
hbhunger.register_food("dwarves:midus", 2)
hbhunger.register_food("dwarves:tequila", 2)
hbhunger.register_food("dwarves:tequila_with_lime", 2)
hbhunger.register_food("dwarves:sake", 2)
end
if minetest.get_modpath("animalmaterials") ~= nil then
overwrite("animalmaterials:milk", 2)
overwrite("animalmaterials:meat_raw", 3)
overwrite("animalmaterials:meat_pork", 3)
overwrite("animalmaterials:meat_beef", 3)
overwrite("animalmaterials:meat_chicken", 3)
overwrite("animalmaterials:meat_lamb", 3)
overwrite("animalmaterials:meat_venison", 3)
overwrite("animalmaterials:meat_undead", 3, "", 3)
overwrite("animalmaterials:meat_toxic", 3, "", 5)
overwrite("animalmaterials:meat_ostrich", 3)
overwrite("animalmaterials:fish_bluewhite", 2)
overwrite("animalmaterials:fish_clownfish", 2)
hbhunger.register_food("animalmaterials:milk", 2)
hbhunger.register_food("animalmaterials:meat_raw", 3)
hbhunger.register_food("animalmaterials:meat_pork", 3)
hbhunger.register_food("animalmaterials:meat_beef", 3)
hbhunger.register_food("animalmaterials:meat_chicken", 3)
hbhunger.register_food("animalmaterials:meat_lamb", 3)
hbhunger.register_food("animalmaterials:meat_venison", 3)
hbhunger.register_food("animalmaterials:meat_undead", 3, "", 3)
hbhunger.register_food("animalmaterials:meat_toxic", 3, "", 5)
hbhunger.register_food("animalmaterials:meat_ostrich", 3)
hbhunger.register_food("animalmaterials:fish_bluewhite", 2)
hbhunger.register_food("animalmaterials:fish_clownfish", 2)
end
if minetest.get_modpath("fishing") ~= nil then
overwrite("fishing:fish_raw", 2)
overwrite("fishing:fish_cooked", 5)
overwrite("fishing:sushi", 6)
overwrite("fishing:shark", 4)
overwrite("fishing:shark_cooked", 8)
overwrite("fishing:pike", 4)
overwrite("fishing:pike_cooked", 8)
hbhunger.register_food("fishing:fish_raw", 2)
hbhunger.register_food("fishing:fish_cooked", 5)
hbhunger.register_food("fishing:sushi", 6)
hbhunger.register_food("fishing:shark", 4)
hbhunger.register_food("fishing:shark_cooked", 8)
hbhunger.register_food("fishing:pike", 4)
hbhunger.register_food("fishing:pike_cooked", 8)
end
if minetest.get_modpath("glooptest") ~= nil then
overwrite("glooptest:kalite_lump", 1)
hbhunger.register_food("glooptest:kalite_lump", 1)
end
if minetest.get_modpath("bushes") ~= nil then
overwrite("bushes:sugar", 1)
overwrite("bushes:strawberry", 2)
overwrite("bushes:berry_pie_raw", 3)
overwrite("bushes:berry_pie_cooked", 4)
overwrite("bushes:basket_pies", 15)
hbhunger.register_food("bushes:sugar", 1)
hbhunger.register_food("bushes:strawberry", 2)
hbhunger.register_food("bushes:berry_pie_raw", 3)
hbhunger.register_food("bushes:berry_pie_cooked", 4)
hbhunger.register_food("bushes:basket_pies", 15)
end
if minetest.get_modpath("bushes_classic") then
@ -156,237 +216,263 @@ if minetest.get_modpath("bushes_classic") then
"mixed_berry"}
for _, berry in ipairs(berries) do
if berry ~= "mixed_berry" then
overwrite("bushes:"..berry, 1)
hbhunger.register_food("bushes:"..berry, 1)
end
overwrite("bushes:"..berry.."_pie_raw", 2)
overwrite("bushes:"..berry.."_pie_cooked", 5)
overwrite("bushes:basket_"..berry, 15)
hbhunger.register_food("bushes:"..berry.."_pie_raw", 2)
hbhunger.register_food("bushes:"..berry.."_pie_cooked", 5)
hbhunger.register_food("bushes:basket_"..berry, 15)
end
end
if minetest.get_modpath("mushroom") ~= nil then
overwrite("mushroom:brown", 1)
overwrite("mushroom:red", 1, "", 3)
hbhunger.register_food("mushroom:brown", 1)
hbhunger.register_food("mushroom:red", 1, "", 3)
-- mushroom potions: red = strong poison, brown = light restorative
if minetest.get_modpath("vessels") then
overwrite("mushroom:brown_essence", 1, "vessels:glass_bottle", nil, 4)
overwrite("mushroom:poison", 1, "vessels:glass_bottle", 10)
hbhunger.register_food("mushroom:brown_essence", 1, "vessels:glass_bottle", nil, 4)
hbhunger.register_food("mushroom:poison", 1, "vessels:glass_bottle", 10)
end
end
if minetest.get_modpath("docfarming") ~= nil then
overwrite("docfarming:carrot", 3)
overwrite("docfarming:cucumber", 2)
overwrite("docfarming:corn", 3)
overwrite("docfarming:potato", 4)
overwrite("docfarming:bakedpotato", 5)
overwrite("docfarming:raspberry", 3)
hbhunger.register_food("docfarming:carrot", 3)
hbhunger.register_food("docfarming:cucumber", 2)
hbhunger.register_food("docfarming:corn", 3)
hbhunger.register_food("docfarming:potato", 4)
hbhunger.register_food("docfarming:bakedpotato", 5)
hbhunger.register_food("docfarming:raspberry", 3)
end
if minetest.get_modpath("farming_plus") ~= nil then
overwrite("farming_plus:carrot_item", 3)
overwrite("farming_plus:banana", 2)
overwrite("farming_plus:orange_item", 2)
overwrite("farming:pumpkin_bread", 4)
overwrite("farming_plus:strawberry_item", 2)
overwrite("farming_plus:tomato_item", 2)
overwrite("farming_plus:potato_item", 4)
overwrite("farming_plus:rhubarb_item", 2)
hbhunger.register_food("farming_plus:carrot_item", 3)
hbhunger.register_food("farming_plus:banana", 2)
hbhunger.register_food("farming_plus:orange_item", 2)
hbhunger.register_food("farming:pumpkin_bread", 4)
hbhunger.register_food("farming_plus:strawberry_item", 2)
hbhunger.register_food("farming_plus:tomato_item", 2)
hbhunger.register_food("farming_plus:potato_item", 4)
hbhunger.register_food("farming_plus:rhubarb_item", 2)
end
if minetest.get_modpath("mtfoods") ~= nil then
overwrite("mtfoods:dandelion_milk", 1)
overwrite("mtfoods:sugar", 1)
overwrite("mtfoods:short_bread", 4)
overwrite("mtfoods:cream", 1)
overwrite("mtfoods:chocolate", 2)
overwrite("mtfoods:cupcake", 2)
overwrite("mtfoods:strawberry_shortcake", 2)
overwrite("mtfoods:cake", 3)
overwrite("mtfoods:chocolate_cake", 3)
overwrite("mtfoods:carrot_cake", 3)
overwrite("mtfoods:pie_crust", 3)
overwrite("mtfoods:apple_pie", 3)
overwrite("mtfoods:rhubarb_pie", 2)
overwrite("mtfoods:banana_pie", 3)
overwrite("mtfoods:pumpkin_pie", 3)
overwrite("mtfoods:cookies", 2)
overwrite("mtfoods:mlt_burger", 5)
overwrite("mtfoods:potato_slices", 2)
overwrite("mtfoods:potato_chips", 3)
hbhunger.register_food("mtfoods:dandelion_milk", 1)
hbhunger.register_food("mtfoods:sugar", 1)
hbhunger.register_food("mtfoods:short_bread", 4)
hbhunger.register_food("mtfoods:cream", 1)
hbhunger.register_food("mtfoods:chocolate", 2)
hbhunger.register_food("mtfoods:cupcake", 2)
hbhunger.register_food("mtfoods:strawberry_shortcake", 2)
hbhunger.register_food("mtfoods:cake", 3)
hbhunger.register_food("mtfoods:chocolate_cake", 3)
hbhunger.register_food("mtfoods:carrot_cake", 3)
hbhunger.register_food("mtfoods:pie_crust", 3)
hbhunger.register_food("mtfoods:apple_pie", 3)
hbhunger.register_food("mtfoods:rhubarb_pie", 2)
hbhunger.register_food("mtfoods:banana_pie", 3)
hbhunger.register_food("mtfoods:pumpkin_pie", 3)
hbhunger.register_food("mtfoods:cookies", 2)
hbhunger.register_food("mtfoods:mlt_burger", 5)
hbhunger.register_food("mtfoods:potato_slices", 2)
hbhunger.register_food("mtfoods:potato_chips", 3)
--mtfoods:medicine
overwrite("mtfoods:casserole", 3)
overwrite("mtfoods:glass_flute", 2)
overwrite("mtfoods:orange_juice", 2)
overwrite("mtfoods:apple_juice", 2)
overwrite("mtfoods:apple_cider", 2)
overwrite("mtfoods:cider_rack", 2)
hbhunger.register_food("mtfoods:casserole", 3)
hbhunger.register_food("mtfoods:glass_flute", 2)
hbhunger.register_food("mtfoods:orange_juice", 2)
hbhunger.register_food("mtfoods:apple_juice", 2)
hbhunger.register_food("mtfoods:apple_cider", 2)
hbhunger.register_food("mtfoods:cider_rack", 2)
end
if minetest.get_modpath("fruit") ~= nil then
overwrite("fruit:apple", 2)
overwrite("fruit:pear", 2)
overwrite("fruit:bananna", 3)
overwrite("fruit:orange", 2)
hbhunger.register_food("fruit:apple", 2)
hbhunger.register_food("fruit:pear", 2)
hbhunger.register_food("fruit:bananna", 3)
hbhunger.register_food("fruit:orange", 2)
end
if minetest.get_modpath("mush45") ~= nil then
overwrite("mush45:meal", 4)
hbhunger.register_food("mush45:meal", 4)
end
if minetest.get_modpath("seaplants") ~= nil then
overwrite("seaplants:kelpgreen", 1)
overwrite("seaplants:kelpbrown", 1)
overwrite("seaplants:seagrassgreen", 1)
overwrite("seaplants:seagrassred", 1)
overwrite("seaplants:seasaladmix", 6)
overwrite("seaplants:kelpgreensalad", 1)
overwrite("seaplants:kelpbrownsalad", 1)
overwrite("seaplants:seagrassgreensalad", 1)
overwrite("seaplants:seagrassgreensalad", 1)
hbhunger.register_food("seaplants:kelpgreen", 1)
hbhunger.register_food("seaplants:kelpbrown", 1)
hbhunger.register_food("seaplants:seagrassgreen", 1)
hbhunger.register_food("seaplants:seagrassred", 1)
hbhunger.register_food("seaplants:seasaladmix", 6)
hbhunger.register_food("seaplants:kelpgreensalad", 1)
hbhunger.register_food("seaplants:kelpbrownsalad", 1)
hbhunger.register_food("seaplants:seagrassgreensalad", 1)
hbhunger.register_food("seaplants:seagrassgreensalad", 1)
end
if minetest.get_modpath("mobfcooking") ~= nil then
overwrite("mobfcooking:cooked_pork", 6)
overwrite("mobfcooking:cooked_ostrich", 6)
overwrite("mobfcooking:cooked_beef", 6)
overwrite("mobfcooking:cooked_chicken", 6)
overwrite("mobfcooking:cooked_lamb", 6)
overwrite("mobfcooking:cooked_venison", 6)
overwrite("mobfcooking:cooked_fish", 6)
hbhunger.register_food("mobfcooking:cooked_pork", 6)
hbhunger.register_food("mobfcooking:cooked_ostrich", 6)
hbhunger.register_food("mobfcooking:cooked_beef", 6)
hbhunger.register_food("mobfcooking:cooked_chicken", 6)
hbhunger.register_food("mobfcooking:cooked_lamb", 6)
hbhunger.register_food("mobfcooking:cooked_venison", 6)
hbhunger.register_food("mobfcooking:cooked_fish", 6)
end
if minetest.get_modpath("creatures") ~= nil then
overwrite("creatures:meat", 6)
overwrite("creatures:flesh", 3)
overwrite("creatures:rotten_flesh", 3, "", 3)
hbhunger.register_food("creatures:meat", 6)
hbhunger.register_food("creatures:flesh", 3)
hbhunger.register_food("creatures:rotten_flesh", 3, "", 3)
end
if minetest.get_modpath("ethereal") then
overwrite("ethereal:strawberry", 1)
overwrite("ethereal:banana", 4)
overwrite("ethereal:pine_nuts", 1)
overwrite("ethereal:bamboo_sprout", 0, "", 3)
overwrite("ethereal:fern_tubers", 1)
overwrite("ethereal:banana_bread", 7)
overwrite("ethereal:mushroom_plant", 2)
overwrite("ethereal:coconut_slice", 2)
overwrite("ethereal:golden_apple", 4, "", nil, 10)
overwrite("ethereal:wild_onion_plant", 2)
overwrite("ethereal:mushroom_soup", 4, "ethereal:bowl")
overwrite("ethereal:mushroom_soup_cooked", 6, "ethereal:bowl")
overwrite("ethereal:hearty_stew", 6, "ethereal:bowl", 3)
overwrite("ethereal:hearty_stew_cooked", 10, "ethereal:bowl")
hbhunger.register_food("ethereal:strawberry", 1)
hbhunger.register_food("ethereal:banana", 4)
hbhunger.register_food("ethereal:pine_nuts", 1)
hbhunger.register_food("ethereal:bamboo_sprout", 0, "", 3)
hbhunger.register_food("ethereal:fern_tubers", 1)
hbhunger.register_food("ethereal:banana_bread", 7)
hbhunger.register_food("ethereal:mushroom_plant", 2)
hbhunger.register_food("ethereal:coconut_slice", 2)
hbhunger.register_food("ethereal:golden_apple", 4, "", nil, 10)
hbhunger.register_food("ethereal:wild_onion_plant", 2)
hbhunger.register_food("ethereal:mushroom_soup", 4, "ethereal:bowl")
hbhunger.register_food("ethereal:mushroom_soup_cooked", 6, "ethereal:bowl")
hbhunger.register_food("ethereal:hearty_stew", 6, "ethereal:bowl", 3)
hbhunger.register_food("ethereal:hearty_stew_cooked", 10, "ethereal:bowl")
if minetest.get_modpath("bucket") then
overwrite("ethereal:bucket_cactus", 2, "bucket:bucket_empty")
hbhunger.register_food("ethereal:bucket_cactus", 2, "bucket:bucket_empty")
end
overwrite("ethereal:fish_raw", 2)
overwrite("ethereal:fish_cooked", 5)
overwrite("ethereal:seaweed", 1)
overwrite("ethereal:yellowleaves", 1, "", nil, 1)
overwrite("ethereal:sashimi", 4)
hbhunger.register_food("ethereal:fish_raw", 2)
hbhunger.register_food("ethereal:fish_cooked", 5)
hbhunger.register_food("ethereal:seaweed", 1)
hbhunger.register_food("ethereal:yellowleaves", 1, "", nil, 1)
hbhunger.register_food("ethereal:sashimi", 4)
hbhunger.register_food("ethereal:orange", 2)
end
if minetest.get_modpath("farming") and farming.mod == "redo" then
overwrite("farming:bread", 6)
overwrite("farming:potato", 1)
overwrite("farming:baked_potato", 6)
overwrite("farming:cucumber", 4)
overwrite("farming:tomato", 4)
overwrite("farming:carrot", 3)
overwrite("farming:carrot_gold", 6, "", nil, 8)
overwrite("farming:corn", 3)
overwrite("farming:corn_cob", 5)
overwrite("farming:melon_slice", 2)
overwrite("farming:pumpkin_slice", 1)
overwrite("farming:pumpkin_bread", 9)
overwrite("farming:coffee_cup", 2, "farming:drinking_cup")
overwrite("farming:coffee_cup_hot", 3, "farming:drinking_cup", nil, 2)
overwrite("farming:cookie", 2)
overwrite("farming:chocolate_dark", 3)
overwrite("farming:donut", 4)
overwrite("farming:donut_chocolate", 6)
overwrite("farming:donut_apple", 6)
overwrite("farming:raspberries", 1)
overwrite("farming:blueberries", 1)
overwrite("farming:muffin_blueberry", 4)
hbhunger.register_food("farming:bread", 6)
hbhunger.register_food("farming:potato", 1)
hbhunger.register_food("farming:baked_potato", 6)
hbhunger.register_food("farming:cucumber", 4)
hbhunger.register_food("farming:tomato", 4)
hbhunger.register_food("farming:carrot", 3)
hbhunger.register_food("farming:carrot_gold", 6, "", nil, 8)
hbhunger.register_food("farming:corn", 3)
hbhunger.register_food("farming:corn_cob", 5)
hbhunger.register_food("farming:melon_slice", 2)
hbhunger.register_food("farming:pumpkin_slice", 1)
hbhunger.register_food("farming:pumpkin_bread", 9)
hbhunger.register_food("farming:coffee_cup", 2, "farming:drinking_cup")
hbhunger.register_food("farming:coffee_cup_hot", 3, "farming:drinking_cup", nil, 2)
hbhunger.register_food("farming:cookie", 2)
hbhunger.register_food("farming:chocolate_dark", 3)
hbhunger.register_food("farming:donut", 4)
hbhunger.register_food("farming:donut_chocolate", 6)
hbhunger.register_food("farming:donut_apple", 6)
hbhunger.register_food("farming:raspberries", 1)
hbhunger.register_food("farming:blueberries", 1)
hbhunger.register_food("farming:muffin_blueberry", 4)
if minetest.get_modpath("vessels") then
overwrite("farming:smoothie_raspberry", 2, "vessels:drinking_glass")
hbhunger.register_food("farming:smoothie_raspberry", 2, "vessels:drinking_glass")
end
overwrite("farming:rhubarb", 1)
overwrite("farming:rhubarb_pie", 6)
hbhunger.register_food("farming:rhubarb", 1)
hbhunger.register_food("farming:rhubarb_pie", 6)
hbhunger.register_food("farming:beans", 1)
end
if minetest.get_modpath("kpgmobs") ~= nil then
overwrite("kpgmobs:uley", 3)
overwrite("kpgmobs:meat", 6)
overwrite("kpgmobs:rat_cooked", 5)
overwrite("kpgmobs:med_cooked", 4)
hbhunger.register_food("kpgmobs:uley", 3)
hbhunger.register_food("kpgmobs:meat", 6)
hbhunger.register_food("kpgmobs:rat_cooked", 5)
hbhunger.register_food("kpgmobs:med_cooked", 4)
if minetest.get_modpath("bucket") then
overwrite("kpgmobs:bucket_milk", 4, "bucket:bucket_empty")
hbhunger.register_food("kpgmobs:bucket_milk", 4, "bucket:bucket_empty")
end
end
if minetest.get_modpath("jkfarming") ~= nil then
overwrite("jkfarming:carrot", 3)
overwrite("jkfarming:corn", 3)
overwrite("jkfarming:melon_part", 2)
overwrite("jkfarming:cake", 3)
hbhunger.register_food("jkfarming:carrot", 3)
hbhunger.register_food("jkfarming:corn", 3)
hbhunger.register_food("jkfarming:melon_part", 2)
hbhunger.register_food("jkfarming:cake", 3)
end
if minetest.get_modpath("jkanimals") ~= nil then
overwrite("jkanimals:meat", 6)
hbhunger.register_food("jkanimals:meat", 6)
end
if minetest.get_modpath("jkwine") ~= nil then
overwrite("jkwine:grapes", 2)
overwrite("jkwine:winebottle", 1)
hbhunger.register_food("jkwine:grapes", 2)
hbhunger.register_food("jkwine:winebottle", 1)
end
if minetest.get_modpath("cooking") ~= nil then
overwrite("cooking:meat_beef_cooked", 4)
overwrite("cooking:fish_bluewhite_cooked", 3)
overwrite("cooking:fish_clownfish_cooked", 1)
overwrite("cooking:meat_chicken_cooked", 2)
overwrite("cooking:meat_cooked", 2)
overwrite("cooking:meat_pork_cooked", 3)
overwrite("cooking:meat_toxic_cooked", -3)
overwrite("cooking:meat_venison_cooked", 3)
overwrite("cooking:meat_undead_cooked", 1)
hbhunger.register_food("cooking:meat_beef_cooked", 4)
hbhunger.register_food("cooking:fish_bluewhite_cooked", 3)
hbhunger.register_food("cooking:fish_clownfish_cooked", 1)
hbhunger.register_food("cooking:meat_chicken_cooked", 2)
hbhunger.register_food("cooking:meat_cooked", 2)
hbhunger.register_food("cooking:meat_pork_cooked", 3)
hbhunger.register_food("cooking:meat_toxic_cooked", -3)
hbhunger.register_food("cooking:meat_venison_cooked", 3)
hbhunger.register_food("cooking:meat_undead_cooked", 1)
end
-- ferns mod of plantlife_modpack
if minetest.get_modpath("ferns") ~= nil then
overwrite("ferns:fiddlehead", 1, "", 1)
overwrite("ferns:fiddlehead_roasted", 3)
overwrite("ferns:ferntuber_roasted", 3)
overwrite("ferns:horsetail_01", 1)
hbhunger.register_food("ferns:fiddlehead", 1, "", 1)
hbhunger.register_food("ferns:fiddlehead_roasted", 3)
hbhunger.register_food("ferns:ferntuber_roasted", 3)
hbhunger.register_food("ferns:horsetail_01", 1)
end
if minetest.get_modpath("pizza") ~= nil then
hbhunger.register_food("pizza:pizza", 30, "", nil, 30)
hbhunger.register_food("pizza:pizzaslice", 5, "", nil, 5)
end
if minetest.get_modpath("nssm") then
hbhunger.register_food("nssm:werewolf_leg", 3)
hbhunger.register_food("nssm:heron_leg", 2)
hbhunger.register_food("nssm:chichibios_heron_leg", 4)
hbhunger.register_food("nssm:crocodile_tail", 3)
hbhunger.register_food("nssm:duck_legs", 1)
hbhunger.register_food("nssm:ant_leg", 1)
hbhunger.register_food("nssm:spider_leg", 1)
hbhunger.register_food("nssm:tentacle", 2)
hbhunger.register_food("nssm:worm_flesh", 2, "", 2) -- poisonous
hbhunger.register_food("nssm:amphibian_heart", 1)
hbhunger.register_food("nssm:raw_scrausics_wing", 1)
-- superfoods
hbhunger.register_food("nssm:phoenix_nuggets", 20, "", nil, 20)
hbhunger.register_food("nssm:phoenix_tear", 20, "", nil, 20)
end
-- player-action based hunger changes
function hbhunger.handle_node_actions(pos, oldnode, player, ext)
if not player or not player:is_player() then
-- is_fake_player comes from the pipeworks, we are not interested in those
if not player or not player:is_player() or player.is_fake_player == true then
return
end
local name = player:get_player_name()
local exhaus = hbhunger.exhaustion[name]
local new = HUNGER_EXHAUST_PLACE
if exhaus == nil then return end
local new = hbhunger.EXHAUST_PLACE
-- placenode event
if not ext then
new = HUNGER_EXHAUST_DIG
new = hbhunger.EXHAUST_DIG
end
-- assume its send by main timer when movement detected
if not pos and not oldnode then
new = HUNGER_EXHAUST_MOVE
new = hbhunger.EXHAUST_MOVE
end
exhaus = exhaus + new
if exhaus > HUNGER_EXHAUST_LVL then
if exhaus > hbhunger.EXHAUST_LVL then
exhaus = 0
local h = tonumber(hbhunger.hunger[name])
h = h - 1
if h < 0 then h = 0 end
hbhunger.hunger[name] = h
hbhunger.set_hunger(player)
hbhunger.set_hunger_raw(player)
end
hbhunger.exhaustion[name] = exhaus
end

View File

@ -1,24 +1,35 @@
if minetest.setting_getbool("enable_damage") then
local S
if (minetest.get_modpath("intllib")) then
S = intllib.Getter()
else
S = function ( s ) return s end
end
if minetest.settings:get_bool("enable_damage") then
hbhunger = {}
hbhunger.food = {}
-- HUD statbar values
hbhunger.hunger = {}
hbhunger.hunger_out = {}
-- Count number of poisonings a player has at once
hbhunger.poisonings = {}
-- HUD item ids
local hunger_hud = {}
HUNGER_HUD_TICK = 0.1
hbhunger.HUD_TICK = 0.1
--Some hunger settings
hbhunger.exhaustion = {} -- Exhaustion is experimental!
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 satiation gets lowerd
hbhunger.HUNGER_TICK = 800 -- time in seconds after that 1 hunger point is taken
hbhunger.EXHAUST_DIG = 3 -- exhaustion increased this value after digged node
hbhunger.EXHAUST_PLACE = 1 -- exhaustion increased this value after placed
hbhunger.EXHAUST_MOVE = 0.3 -- exhaustion increased this value if player movement detected
hbhunger.EXHAUST_LVL = 160 -- at what exhaustion player satiation gets lowerd
--load custom settings
@ -29,13 +40,13 @@ if set then
end
local function custom_hud(player)
hb.init_hudbar(player, "satiation", hbhunger.get_hunger(player))
hb.init_hudbar(player, "satiation", hbhunger.get_hunger_raw(player))
end
dofile(minetest.get_modpath("hbhunger").."/hunger.lua")
-- register satiation hudbar
hb.register_hudbar("satiation", 0xFFFFFF, "Satiation", { icon = "hbhunger_icon.png", bar = "hbhunger_bar.png" }, 20, 30, false)
hb.register_hudbar("satiation", 0xFFFFFF, S("Satiation"), { icon = "hbhunger_icon.png", bgicon = "hbhunger_bgicon.png", bar = "hbhunger_bar.png" }, 20, 30, false)
-- update hud elemtens if value has changed
local function update_hud(player)
@ -49,7 +60,7 @@ local function update_hud(player)
end
end
hbhunger.get_hunger = function(player)
hbhunger.get_hunger_raw = function(player)
local inv = player:get_inventory()
if not inv then return nil end
local hgp = inv:get_stack("hunger", 1):get_count()
@ -62,7 +73,7 @@ hbhunger.get_hunger = function(player)
return hgp-1
end
hbhunger.set_hunger = function(player)
hbhunger.set_hunger_raw = function(player)
local inv = player:get_inventory()
local name = player:get_player_name()
local value = hbhunger.hunger[name]
@ -79,18 +90,19 @@ minetest.register_on_joinplayer(function(player)
local name = player:get_player_name()
local inv = player:get_inventory()
inv:set_size("hunger",1)
hbhunger.hunger[name] = hbhunger.get_hunger(player)
hbhunger.hunger[name] = hbhunger.get_hunger_raw(player)
hbhunger.hunger_out[name] = hbhunger.hunger[name]
hbhunger.exhaustion[name] = 0
hbhunger.poisonings[name] = 0
custom_hud(player)
hbhunger.set_hunger(player)
hbhunger.set_hunger_raw(player)
end)
minetest.register_on_respawnplayer(function(player)
-- reset hunger (and save)
local name = player:get_player_name()
hbhunger.hunger[name] = 20
hbhunger.set_hunger(player)
hbhunger.set_hunger_raw(player)
hbhunger.exhaustion[name] = 0
end)
@ -101,8 +113,8 @@ minetest.register_globalstep(function(dtime)
main_timer = main_timer + dtime
timer = timer + dtime
timer2 = timer2 + dtime
if main_timer > HUNGER_HUD_TICK or timer > 4 or timer2 > HUNGER_HUNGER_TICK then
if main_timer > HUNGER_HUD_TICK then main_timer = 0 end
if main_timer > hbhunger.HUD_TICK or timer > 4 or timer2 > hbhunger.HUNGER_TICK then
if main_timer > hbhunger.HUD_TICK then main_timer = 0 end
for _,player in ipairs(minetest.get_connected_players()) do
local name = player:get_player_name()
@ -118,11 +130,11 @@ minetest.register_globalstep(function(dtime)
end
end
-- lower satiation by 1 point after xx seconds
if timer2 > HUNGER_HUNGER_TICK then
if timer2 > hbhunger.HUNGER_TICK then
if h > 0 then
h = h-1
hbhunger.hunger[name] = h
hbhunger.set_hunger(player)
hbhunger.set_hunger_raw(player)
end
end
@ -137,7 +149,7 @@ minetest.register_globalstep(function(dtime)
end
end
if timer > 4 then timer = 0 end
if timer2 > HUNGER_HUNGER_TICK then timer2 = 0 end
if timer2 > hbhunger.HUNGER_TICK then timer2 = 0 end
end)
end

1
locale/de.txt Normal file
View File

@ -0,0 +1 @@
Satiation = Sättigung

1
locale/it.txt Normal file
View File

@ -0,0 +1 @@
Satiation = Sazietà

1
locale/ms.txt Normal file
View File

@ -0,0 +1 @@
Satiation = Kekenyangan

1
locale/pt.txt Normal file
View File

@ -0,0 +1 @@
Satiation = Saciedade

1
locale/template.txt Normal file
View File

@ -0,0 +1 @@
Satiation

1
mod.conf Normal file
View File

@ -0,0 +1 @@
name = hbhunger

BIN
screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 417 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B