Changed armor

master
maikerumine 2015-12-06 19:08:45 -05:00
parent fd5838d8e0
commit 4457639d36
66 changed files with 1511 additions and 328 deletions

View File

@ -6,14 +6,19 @@ Depends: default
Recommends: inventory_plus or unified_inventory (use only one)
Adds craftable armor that is visible to other players. Each armor item worn contributes to
a player"s armor group level making them less vulnerable to weapons.
a player's armor group level making them less vulnerable to weapons.
Armor takes damage when a player is hurt but also offers a percentage chance of healing.
Overall level is boosted by 10% when wearing a full matching set.
Fire protection added by TenPlus1 when using crystal armor if Ethereal mod active, level 1
protects against torches, level 2 for crystal spike, level 3 for fire, level 5 for lava.
Configuration
-------------
Armor can be configured by adding a file called armor.conf in 3d_armor mod directory.
Armor can be configured by adding a file called armor.conf in 3d_armor mod and/or world directory.
see armor.conf.example for all available options.
Note: worldpath config settings override any settings made in the mod's directory.

45
mods/3d_armor/admin.lua Normal file
View File

@ -0,0 +1,45 @@
minetest.register_alias("adminboots","3d_armor:boots_admin")
minetest.register_alias("adminhelmet","3d_armor:helmet_admin")
minetest.register_alias("adminchestplate","3d_armor:chestplate_admin")
minetest.register_alias("adminlegginss","3d_armor:leggings_admin")
minetest.register_tool("3d_armor:helmet_admin", {
description = "Admin Helmet",
inventory_image = "3d_armor_inv_helmet_admin.png",
groups = {armor_head=1000, armor_heal=1000, armor_use=0, not_in_creative_inventory=1},
wear = 0,
on_drop = function(itemstack, dropper, pos)
return
end,
})
minetest.register_tool("3d_armor:chestplate_admin", {
description = "Admin Chestplate",
inventory_image = "3d_armor_inv_chestplate_admin.png",
groups = {armor_torso=1000, armor_heal=1000, armor_use=0, not_in_creative_inventory=1},
wear = 0,
on_drop = function(itemstack, dropper, pos)
return
end,
})
minetest.register_tool("3d_armor:leggings_admin", {
description = "Admin Leggings",
inventory_image = "3d_armor_inv_leggings_admin.png",
groups = {armor_legs=1000, armor_heal=1000, armor_use=0, not_in_creative_inventory=1},
wear = 0,
on_drop = function(itemstack, dropper, pos)
return
end,
})
minetest.register_tool("3d_armor:boots_admin", {
description = "Admin Boots",
inventory_image = "3d_armor_inv_boots_admin.png",
groups = {armor_feet=1000, armor_heal=1000, armor_use=0, not_in_creative_inventory=1},
wear = 0,
on_drop = function(itemstack, dropper, pos)
return
end,
})

View File

@ -1,5 +1,31 @@
-- Armor Configuration (defaults)
-- You can remove any unwanted armor materials from this table.
-- Note that existing armor that is removed will show up as an unknown item.
ARMOR_MATERIALS = {
wood = "group:wood",
cactus = "default:cactus",
steel = "default:steel_ingot",
bronze = "default:bronze_ingot",
diamond = "default:diamond",
gold = "default:gold_ingot",
mithril = "moreores:mithril_ingot",
crystal = "ethereal:crystal_ingot",
}
-- Enable fire protection (defaults true if using ethereal mod)
ARMOR_FIRE_PROTECT = false
-- Fire protection nodes, (name, protection level, damage)
ARMOR_FIRE_NODES = {
{"default:lava_source", 5, 4},
{"default:lava_flowing", 5, 4},
{"fire:basic_flame", 3, 4},
{"ethereal:crystal_spike", 2, 1},
{"bakedclay:safe_fire", 2, 1},
{"default:torch", 1, 1},
}
-- Increase this if you get initialization glitches when a player first joins.
ARMOR_INIT_DELAY = 1
@ -28,10 +54,3 @@ ARMOR_LEVEL_MULTIPLIER = 1
-- eg: ARMOR_HEAL_MULTIPLIER = 0 will disable healing altogether.
ARMOR_HEAL_MULTIPLIER = 1
-- You can also use this file to execute arbitary lua code
-- eg: Dumb the armor down if using Simple Mobs
if minetest.get_modpath("mobs") then
ARMOR_LEVEL_MULTIPLIER = 0.5
ARMOR_HEAL_MULTIPLIER = 0
end

View File

@ -2,61 +2,126 @@ ARMOR_INIT_DELAY = 1
ARMOR_INIT_TIMES = 1
ARMOR_BONES_DELAY = 1
ARMOR_UPDATE_TIME = 1
ARMOR_DROP = false
ARMOR_DROP = minetest.get_modpath("bones") ~= nil
ARMOR_DESTROY = false
ARMOR_LEVEL_MULTIPLIER = 0.65
ARMOR_HEAL_MULTIPLIER = 0
ARMOR_LEVEL_MULTIPLIER = 1
ARMOR_HEAL_MULTIPLIER = 1
ARMOR_MATERIALS = {
wood = "group:wood",
cactus = "default:cactus",
steel = "default:steel_ingot",
bronze = "default:bronze_ingot",
diamond = "default:diamond",
gold = "default:gold_ingot",
mithril = "moreores:mithril_ingot",
crystal = "ethereal:crystal_ingot",
}
ARMOR_FIRE_PROTECT = minetest.get_modpath("ethereal") ~= nil
ARMOR_FIRE_NODES = {
{"default:lava_source", 5, 4},
{"default:lava_flowing", 5, 4},
{"fire:basic_flame", 3, 4},
{"ethereal:crystal_spike", 2, 1},
{"bakedclay:safe_fire", 2, 1},
{"default:torch", 1, 1},
}
local skin_mod = nil
local inv_mod = nil
local modpath = minetest.get_modpath(ARMOR_MOD_NAME)
local worldpath = minetest.get_worldpath()
local input = io.open(modpath.."/armor.conf", "r")
if input then
dofile(modpath.."/armor.conf")
input:close()
input = nil
end
local time = 0
input = io.open(worldpath.."/armor.conf", "r")
if input then
dofile(worldpath.."/armor.conf")
input:close()
input = nil
end
if not minetest.get_modpath("moreores") then
ARMOR_MATERIALS.mithril = nil
end
if not minetest.get_modpath("ethereal") then
ARMOR_MATERIALS.crystal = nil
end
gui_slots = "listcolors[#606060AA;#808080;#101010;#202020;#FFF]"
-- override hot nodes so they do not hurt player anywhere but mod
if ARMOR_FIRE_PROTECT == true then
for _, row in ipairs(ARMOR_FIRE_NODES) do
if minetest.registered_nodes[row[1]] then
minetest.override_item(row[1], {damage_per_second = 0})
end
end
end
local time = 0
armor = {
player_hp = {},
elements = {"head", "torso", "legs", "feet"},
physics = {"jump","speed","gravity"},
formspec = "size[8,8.5]" .. gui_slots .. "list[detached:player_name_armor;armor;0,1;2,3;]"
.. "image[2,0.75;2,4;armor_preview]"
.. "list[current_player;main;0,4.25;8,4;]"
.. "list[current_player;craft;4,1;3,3;]"
.. "list[current_player;craftpreview;7,2;1,1;]"
.. default.get_hotbar_bg(0, 4.25)
.. default.get_hotbar_bg(0, 5.25),
formspec = "size[8,8.5]image[2,0.75;2,4;armor_preview]"
.."list[current_player;main;0,4.5;8,4;]"
.."list[current_player;craft;4,1;3,3;]"
.."list[current_player;craftpreview;7,2;1,1;]"
.."listring[current_player;main]"
.."listring[current_player;craft]",
textures = {},
default_skin = "character",
version = "0.4.5",
}
if inventory_plus then
if minetest.get_modpath("inventory_plus") then
inv_mod = "inventory_plus"
armor.formspec = "size[8,8.5]button[0,0;2,0.5;main;Back]"
.."list[detached:player_name_armor;armor;0,1;2,3;]"
.."image[2.5,0.75;2,4;armor_preview]"
.."label[5,1;Level: armor_level]"
.."label[5,1.5;Heal: armor_heal]"
.."label[5,2;Fire: armor_fire]"
.."list[current_player;main;0,4.5;8,4;]"
elseif unified_inventory then
if minetest.get_modpath("crafting") then
inventory_plus.get_formspec = function(player, page)
end
end
elseif minetest.get_modpath("unified_inventory") then
inv_mod = "unified_inventory"
unified_inventory.register_button("armor", {
type = "image",
image = "inventory_plus_armor.png",
})
unified_inventory.register_page("armor", {
get_formspec = function(player)
get_formspec = function(player, perplayer_formspec)
local fy = perplayer_formspec.formspec_y
local name = player:get_player_name()
local formspec = "background[0.06,0.99;7.92,7.52;3d_armor_ui_form.png]"
local formspec = "background[0.06,"..fy..";7.92,7.52;3d_armor_ui_form.png]"
.."label[0,0;Armor]"
.."list[detached:"..name.."_armor;armor;0,1;2,3;]"
.."image[2.5,0.75;2,4;"..armor.textures[name].preview.."]"
.."label[5,1;Level: "..armor.def[name].level.."]"
.."label[5,1.5;Heal: "..armor.def[name].heal.."]"
.."list[detached:"..name.."_armor;armor;0,"..fy..";2,3;]"
.."image[2.5,"..(fy - 0.25)..";2,4;"..armor.textures[name].preview.."]"
.."label[5.0,"..(fy + 0.0)..";Level: "..armor.def[name].level.."]"
.."label[5.0,"..(fy + 0.5)..";Heal: "..armor.def[name].heal.."]"
.."label[5.0,"..(fy + 1.0)..";Fire: "..armor.def[name].fire.."]"
.."listring[current_player;main]"
.."listring[detached:"..name.."_armor;armor]"
return {formspec=formspec}
end,
})
elseif minetest.get_modpath("inventory_enhanced") then
inv_mod = "inventory_enhanced"
end
if minetest.get_modpath("skins") then
skin_mod = "skins"
elseif minetest.get_modpath("simple_skins") then
skin_mod = "simple_skins"
elseif minetest.get_modpath("u_skins") then
skin_mod = "u_skins"
elseif minetest.get_modpath("wardrobe") then
skin_mod = "wardrobe"
end
armor.def = {
@ -79,28 +144,25 @@ armor.update_player_visuals = function(self, player)
end
armor.set_player_armor = function(self, player)
if not player then
return
end
local name = player:get_player_name()
local player_inv = player:get_inventory()
if not name or not player_inv then
local name, player_inv = armor:get_valid_player(player, "[set_player_armor]")
if not name then
return
end
local armor_texture = "3d_armor_trans.png"
local armor_level = 0
local armor_heal = 0
local armor_fire = 0
local state = 0
local items = 0
local elements = {}
local textures = {}
local physics_o = {speed= 1,gravity = 1,jump= 1}
local material = {type=nil, count= 1}
local preview = armor:get_player_skin(name).."_preview.png"
local physics_o = {speed=1,gravity=1,jump=1}
local material = {type=nil, count=1}
local preview = armor:get_preview(name) or "character_preview.png"
for _,v in ipairs(self.elements) do
elements[v] = false
end
for i= 1, 6 do
for i=1, 6 do
local stack = player_inv:get_stack("armor", i)
local item = stack:get_name()
if stack:get_count() == 1 then
@ -109,7 +171,7 @@ armor.set_player_armor = function(self, player)
if v == false then
local level = def.groups["armor_"..k]
if level then
local texture = item:gsub("%:", "_")
local texture = def.texture or item:gsub("%:", "_")
table.insert(textures, texture..".png")
preview = preview.."^"..texture.."_preview.png"
armor_level = armor_level + level
@ -117,6 +179,8 @@ armor.set_player_armor = function(self, player)
items = items + 1
local heal = def.groups["armor_heal"] or 0
armor_heal = armor_heal + heal
local fire = def.groups["armor_fire"] or 0
armor_fire = armor_fire + fire
for kk,vv in ipairs(self.physics) do
local o_value = def.groups["physics_"..vv]
if o_value then
@ -148,7 +212,7 @@ armor.set_player_armor = function(self, player)
if #textures > 0 then
armor_texture = table.concat(textures, "^")
end
local armor_groups = {fleshy = 100}
local armor_groups = {fleshy=100}
if armor_level > 0 then
armor_groups.level = math.floor(armor_level / 20)
armor_groups.fleshy = 100 - armor_level
@ -161,28 +225,44 @@ armor.set_player_armor = function(self, player)
self.def[name].count = items
self.def[name].level = armor_level
self.def[name].heal = armor_heal
self.def[name].jump = physics_o.jump
self.def[name].speed = physics_o.speed
self.def[name].gravity = physics_o.gravity
self.def[name].fire = armor_fire
self:update_player_visuals(player)
end
armor.update_armor = function(self, player)
if not player then
local name, player_inv, armor_inv, pos = armor:get_valid_player(player, "[update_armor]")
if not name then
return
end
local name = player:get_player_name()
local hp = player:get_hp() or 0
if hp == 0 or hp == self.player_hp[name] then
if ARMOR_FIRE_PROTECT == true then
pos.y = pos.y + 1.4 -- head level
local node_head = minetest.get_node(pos).name
pos.y = pos.y - 1.2 -- feet level
local node_feet = minetest.get_node(pos).name
-- is player inside a hot node?
for _, row in ipairs(ARMOR_FIRE_NODES) do
-- check for fire protection, if not enough then get hurt
if row[1] == node_head or row[1] == node_feet then
if hp > 0 and armor.def[name].fire < row[2] then
hp = hp - row[3] * ARMOR_UPDATE_TIME
player:set_hp(hp)
break
end
end
end
end
if hp <= 0 or hp == self.player_hp[name] then
return
end
if self.player_hp[name] > hp then
local player_inv = player:get_inventory()
local armor_inv = minetest.get_inventory({type="detached", name=name.."_armor"})
if not armor_inv then
return
end
local heal_max = 0
local state = 0
local items = 0
for i= 1, 6 do
for i=1, 6 do
local stack = player_inv:get_stack("armor", i)
if stack:get_count() > 0 then
local use = stack:get_definition().groups["armor_use"] or 0
@ -217,30 +297,53 @@ end
armor.get_player_skin = function(self, name)
local skin = nil
if skins then
if skin_mod == "skins" or skin_mod == "simple_skins" then
skin = skins.skins[name]
elseif u_skins then
elseif skin_mod == "u_skins" then
skin = u_skins.u_skins[name]
elseif skin_mod == "wardrobe" then
skin = string.gsub(wardrobe.playerSkins[name], "%.png$","")
end
return skin or armor.default_skin
end
armor.get_preview = function(self, name)
if skin_mod == "skins" then
return armor:get_player_skin(name).."_preview.png"
end
end
armor.get_armor_formspec = function(self, name)
local formspec = armor.formspec:gsub("player_name", name)
if not armor.textures[name] then
minetest.log("error", "3d_armor: Player texture["..name.."] is nil [get_armor_formspec]")
return ""
end
if not armor.def[name] then
minetest.log("error", "3d_armor: Armor def["..name.."] is nil [get_armor_formspec]")
return ""
end
local formspec = armor.formspec.."list[detached:"..name.."_armor;armor;0,1;2,3;]"
formspec = formspec:gsub("armor_preview", armor.textures[name].preview)
formspec = formspec:gsub("armor_level", armor.def[name].level)
return formspec:gsub("armor_heal", armor.def[name].heal)
formspec = formspec:gsub("armor_heal", armor.def[name].heal)
formspec = formspec:gsub("armor_fire", armor.def[name].fire)
return formspec
end
armor.update_inventory = function(self, player)
local name = player:get_player_name()
if unified_inventory then
local name = armor:get_valid_player(player, "[set_player_armor]")
if not name or inv_mod == "inventory_enhanced" then
return
end
if inv_mod == "unified_inventory" then
if unified_inventory.current_page[name] == "armor" then
unified_inventory.set_inventory_formspec(player, "armor")
end
else
local formspec = armor:get_armor_formspec(name)
if inventory_plus then
if inv_mod == "inventory_plus" then
formspec = formspec.."listring[current_player;main]"
.."listring[detached:"..name.."_armor;armor]"
local page = player:get_inventory_formspec()
if page:find("detached:"..name.."_armor") then
inventory_plus.set_inventory_formspec(player, formspec)
@ -251,36 +354,66 @@ armor.update_inventory = function(self, player)
end
end
armor.get_valid_player = function(self, player, msg)
msg = msg or ""
if not player then
minetest.log("error", "3d_armor: Player reference is nil "..msg)
return
end
local name = player:get_player_name()
if not name then
minetest.log("error", "3d_armor: Player name is nil "..msg)
return
end
local pos = player:getpos()
local player_inv = player:get_inventory()
local armor_inv = minetest.get_inventory({type="detached", name=name.."_armor"})
if not pos then
minetest.log("error", "3d_armor: Player position is nil "..msg)
return
elseif not player_inv then
minetest.log("error", "3d_armor: Player inventory is nil "..msg)
return
elseif not armor_inv then
minetest.log("error", "3d_armor: Detached armor inventory is nil "..msg)
return
end
return name, player_inv, armor_inv, pos
end
-- Register Player Model
default.player_register_model("3d_armor_character.x", {
animation_speed = 35,
default.player_register_model("3d_armor_character.b3d", {
animation_speed = 30,
textures = {
armor.default_skin..".png",
"3d_armor_trans.png",
"3d_armor_trans.png",
},
animations = {
stand = {x = 0, y = 40},
lay = {x = 162, y = 166},
walk = {x = 168, y = 187},
mine = {x = 189, y = 198},
walk_mine = {x = 200, y = 219},
sit = {x = 81, y = 160},
stand = {x=0, y=79},
lay = {x=162, y=166},
walk = {x=168, y=187},
mine = {x=189, y=198},
walk_mine = {x=200, y=219},
sit = {x=81, y=160},
},
})
-- Register Callbacks
minetest.register_on_player_receive_fields(function(player, formname, fields)
local name = player:get_player_name()
if inventory_plus and fields.armor then
local name = armor:get_valid_player(player, "[on_player_receive_fields]")
if not name or inv_mod == "inventory_enhanced" then
return
end
if inv_mod == "inventory_plus" and fields.armor then
local formspec = armor:get_armor_formspec(name)
inventory_plus.set_inventory_formspec(player, formspec)
return
end
for field, _ in pairs(fields) do
if string.find(field, "skins_set_") then
if string.find(field, "skins_set") then
minetest.after(0, function(player)
local skin = armor:get_player_skin(name)
armor.textures[name].skin = skin..".png"
@ -291,10 +424,10 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end)
minetest.register_on_joinplayer(function(player)
default.player_set_model(player, "3d_armor_character.x")
default.player_set_model(player, "3d_armor_character.b3d")
local name = player:get_player_name()
local player_inv = player:get_inventory()
local armor_inv = minetest.create_detached_inventory(name.."_armor",{
local armor_inv = minetest.create_detached_inventory(name.."_armor", {
on_put = function(inv, listname, index, stack, player)
player:get_inventory():set_stack(listname, index, stack)
armor:set_player_armor(player)
@ -323,24 +456,15 @@ minetest.register_on_joinplayer(function(player)
return count
end,
})
if inventory_plus then
if inv_mod == "inventory_plus" then
inventory_plus.register_button(player,"armor", "Armor")
end
armor_inv:set_size("armor", 6)
player_inv:set_size("armor", 6)
for i= 1, 6 do
for i=1, 6 do
local stack = player_inv:get_stack("armor", i)
armor_inv:set_stack("armor", i, stack)
end
-- Legacy support, import player"s armor from old inventory format
--[[
for _,v in pairs(armor.elements) do
local list = "armor_"..v
armor_inv:add_item("armor", player_inv:get_stack(list, 1))
player_inv:set_stack(list, 1, nil)
end
--]]
end
armor.player_hp[name] = 0
armor.def[name] = {
@ -348,6 +472,10 @@ minetest.register_on_joinplayer(function(player)
count = 0,
level = 0,
heal = 0,
jump = 1,
speed = 1,
gravity = 1,
fire = 0,
}
armor.textures[name] = {
skin = armor.default_skin..".png",
@ -355,16 +483,26 @@ minetest.register_on_joinplayer(function(player)
wielditem = "3d_armor_trans.png",
preview = armor.default_skin.."_preview.png",
}
if minetest.get_modpath("skins") then
if skin_mod == "skins" then
local skin = skins.skins[name]
if skin and skins.get_type(skin) == skins.type.MODEL then
armor.textures[name].skin = skin..".png"
end
elseif minetest.get_modpath("u_skins") then
elseif skin_mod == "simple_skins" then
local skin = skins.skins[name]
if skin then
armor.textures[name].skin = skin..".png"
end
elseif skin_mod == "u_skins" then
local skin = u_skins.u_skins[name]
if skin and u_skins.get_type(skin) == u_skins.type.MODEL then
armor.textures[name].skin = skin..".png"
end
elseif skin_mod == "wardrobe" then
local skin = wardrobe.playerSkins[name]
if skin then
armor.textures[name].skin = skin
end
end
if minetest.get_modpath("player_textures") then
local filename = minetest.get_modpath("player_textures").."/textures/player_"..name
@ -374,10 +512,10 @@ minetest.register_on_joinplayer(function(player)
armor.textures[name].skin = "player_"..name..".png"
end
end
for i= 1, ARMOR_INIT_TIMES do
for i=1, ARMOR_INIT_TIMES do
minetest.after(ARMOR_INIT_DELAY * i, function(player)
armor:set_player_armor(player)
if inventory_plus == nil and unified_inventory == nil then
if not inv_mod then
armor:update_inventory(player)
end
end, player)
@ -385,65 +523,57 @@ minetest.register_on_joinplayer(function(player)
end)
if ARMOR_DROP == true or ARMOR_DESTROY == true then
armor.drop_armor = function(pos, stack)
local obj = minetest.add_item(pos, stack)
if obj then
obj:setvelocity({x=math.random(-1, 1), y=5, z=math.random(-1, 1)})
end
end
minetest.register_on_dieplayer(function(player)
local name = player:get_player_name()
local pos = player:getpos()
if name and pos then
local drop = {}
local player_inv = player:get_inventory()
local armor_inv = minetest.get_inventory({type="detached", name=name.."_armor"})
for i= 1, player_inv:get_size("armor") do
local stack = armor_inv:get_stack("armor", i)
if stack:get_count() > 0 then
table.insert(drop, stack)
armor_inv:set_stack("armor", i, nil)
player_inv:set_stack("armor", i, nil)
end
local name, player_inv, armor_inv, pos = armor:get_valid_player(player, "[on_dieplayer]")
if not name then
return
end
local drop = {}
for i=1, player_inv:get_size("armor") do
local stack = armor_inv:get_stack("armor", i)
if stack:get_count() > 0 then
table.insert(drop, stack)
armor_inv:set_stack("armor", i, nil)
player_inv:set_stack("armor", i, nil)
end
armor:set_player_armor(player)
if unified_inventory then
unified_inventory.set_inventory_formspec(player, "craft")
elseif inventory_plus then
local formspec = inventory_plus.get_formspec(player,"main")
inventory_plus.set_inventory_formspec(player, formspec)
else
armor:update_inventory(player)
end
if ARMOR_DESTROY == false then
if minetest.get_modpath("bones") then
minetest.after(ARMOR_BONES_DELAY, function()
pos = vector.round(pos)
local node = minetest.get_node(pos)
if node.name == "bones:bones" then
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
local inv = meta:get_inventory()
if name == owner then
for _,stack in ipairs(drop) do
if inv:room_for_item("main", stack) then
inv:add_item("main", stack)
end
end
end
armor:set_player_armor(player)
if inv_mod == "unified_inventory" then
unified_inventory.set_inventory_formspec(player, "craft")
elseif inv_mod == "inventory_plus" then
local formspec = inventory_plus.get_formspec(player,"main")
inventory_plus.set_inventory_formspec(player, formspec)
else
armor:update_inventory(player)
end
if ARMOR_DESTROY == false then
minetest.after(ARMOR_BONES_DELAY, function()
local node = minetest.get_node(vector.round(pos))
if node then
if node.name == "bones:bones" then
local meta = minetest.get_meta(vector.round(pos))
local owner = meta:get_string("owner")
local inv = meta:get_inventory()
for _,stack in ipairs(drop) do
if name == owner and inv:room_for_item("main", stack) then
inv:add_item("main", stack)
else
armor.drop_armor(pos, stack)
end
end
end)
else
for _,stack in ipairs(drop) do
local obj = minetest.add_item(pos, stack)
if obj then
local x = math.random(1, 5)
if math.random(1,2) == 1 then
x = -x
end
local z = math.random(1, 5)
if math.random(1,2) == 1 then
z = -z
end
obj:setvelocity({x = 1/x, y =obj:getvelocity().y, z = 1/z})
end
end
else
for _,stack in ipairs(drop) do
armor.drop_armor(pos, stack)
end
end
end
end)
end
end)
end

View File

@ -12,10 +12,13 @@ Helmets:
+---+---+---+
[3d_armor:helmet_wood] X = [default:wood]
[3d_armor:helmet_cactus] X = [default:cactus]
[3d_armor:helmet_steel] X = [default:steel_ingot]
[3d_armor:helmet_bronze] X = [default:bronze_ingot]
[3d_armor:helmet_diamond] X = [default:diamond]
[3d_armor:helmet_gold] X = [default:gold_ingot]
[3d_armor:helmet_mithril] X = [moreores:mithril_ingot] *
[3d_armor:helmet_crystal] X = [ethereal:crystal_ingot] **
Chestplates:
@ -28,10 +31,13 @@ Chestplates:
+---+---+---+
[3d_armor:chestplate_wood] X = [default:wood]
[3d_armor:chestplate_cactus] X = [default:cactus]
[3d_armor:chestplate_steel] X = [default:steel_ingot]
[3d_armor:chestplate_bronze] X = [default:bronze_ingot]
[3d_armor:chestplate_diamond] X = [default:diamond]
[3d_armor:chestplate_gold] X = [default:gold_ingot]
[3d_armor:chestplate_mithril] X = [moreores:mithril_ingot] *
[3d_armor:chestplate_crystal] X = [ethereal:crystal_ingot] **
Leggings:
@ -44,10 +50,13 @@ Leggings:
+---+---+---+
[3d_armor:leggings_wood] X = [default:wood]
[3d_armor:leggings_cactus] X = [default:cactus]
[3d_armor:leggings_steel] X = [default:steel_ingot]
[3d_armor:leggings_bronze] X = [default:bronze_ingot]
[3d_armor:leggings_diamond] X = [default:diamond]
[3d_armor:leggings_gold] X = [default:gold_ingot]
[3d_armor:leggings_mithril] X = [moreores:mithril_ingot] *
[3d_armor:leggings_crystal] X = [ethereal:crystal_ingot] **
Boots:
@ -58,10 +67,13 @@ Boots:
+---+---+---+
[3d_armor:boots_wood] X = [default:wood]
[3d_armor:boots_cactus] X = [default:cactus]
[3d_armor:boots_steel] X = [default:steel_ingot]
[3d_armor:boots_bronze] X = [default:bronze_ingot
[3d_armor:boots_diamond] X = [default:diamond]
[3d_armor:boots_gold] X = [default:gold_ingot]
[3d_armor:boots_mithril] X = [moreores:mithril_ingot] *
[3d_armor:boots_crystal] X = [ethereal:crystal_ingot] **
* Requires moreores mod by Calinou - https://forum.minetest.net/viewtopic.php?id=549
* Requires moreores mod by Calinou - https://forum.minetest.net/viewtopic.php?id=549
** Requires ethereal mod by Chinchow & TenPlus1 - https://github.com/tenplus1/ethereal

View File

@ -1,4 +1,6 @@
default
inventory_plus?
unified_inventory?
fire?
ethereal?
bakedclay?

View File

@ -1,206 +1,224 @@
ARMOR_MOD_NAME = minetest.get_current_modname()
dofile(minetest.get_modpath(ARMOR_MOD_NAME).."/armor.lua")
local use_moreores = minetest.get_modpath("moreores")
dofile(minetest.get_modpath(ARMOR_MOD_NAME).."/admin.lua")
-- Register helmets:
if ARMOR_MATERIALS.wood then
minetest.register_tool("3d_armor:helmet_wood", {
description = "Wood Helmet",
inventory_image = "3d_armor_inv_helmet_wood.png",
groups = {armor_head=5, armor_heal=0, armor_use=2000},
wear = 0,
})
minetest.register_tool("3d_armor:chestplate_wood", {
description = "Wood Chestplate",
inventory_image = "3d_armor_inv_chestplate_wood.png",
groups = {armor_torso=10, armor_heal=0, armor_use=2000},
wear = 0,
})
minetest.register_tool("3d_armor:leggings_wood", {
description = "Wood Leggings",
inventory_image = "3d_armor_inv_leggings_wood.png",
groups = {armor_legs=5, armor_heal=0, armor_use=2000},
wear = 0,
})
minetest.register_tool("3d_armor:boots_wood", {
description = "Wood Boots",
inventory_image = "3d_armor_inv_boots_wood.png",
groups = {armor_feet=5, armor_heal=0, armor_use=2000},
wear = 0,
})
end
minetest.register_tool("3d_armor:helmet_wood", {
description = "Wooden Helmet",
inventory_image = "3d_armor_inv_helmet_wood.png",
groups = {armor_head = 5, armor_heal = 0, armor_use = 2000},
wear = 0,
})
if ARMOR_MATERIALS.cactus then
minetest.register_tool("3d_armor:helmet_cactus", {
description = "Cactuc Helmet",
inventory_image = "3d_armor_inv_helmet_cactus.png",
groups = {armor_head=5, armor_heal=0, armor_use=1000},
wear = 0,
})
minetest.register_tool("3d_armor:chestplate_cactus", {
description = "Cactus Chestplate",
inventory_image = "3d_armor_inv_chestplate_cactus.png",
groups = {armor_torso=10, armor_heal=0, armor_use=1000},
wear = 0,
})
minetest.register_tool("3d_armor:leggings_cactus", {
description = "Cactus Leggings",
inventory_image = "3d_armor_inv_leggings_cactus.png",
groups = {armor_legs=5, armor_heal=0, armor_use=1000},
wear = 0,
})
minetest.register_tool("3d_armor:boots_cactus", {
description = "Cactus Boots",
inventory_image = "3d_armor_inv_boots_cactus.png",
groups = {armor_feet=5, armor_heal=0, armor_use=2000},
wear = 0,
})
end
minetest.register_tool("3d_armor:helmet_steel", {
description = "Steel Helmet",
inventory_image = "3d_armor_inv_helmet_steel.png",
groups = {armor_head = 10, armor_heal = 0, armor_use = 500},
wear = 0,
})
if ARMOR_MATERIALS.steel then
minetest.register_tool("3d_armor:helmet_steel", {
description = "Steel Helmet",
inventory_image = "3d_armor_inv_helmet_steel.png",
groups = {armor_head=10, armor_heal=0, armor_use=500},
wear = 0,
})
minetest.register_tool("3d_armor:chestplate_steel", {
description = "Steel Chestplate",
inventory_image = "3d_armor_inv_chestplate_steel.png",
groups = {armor_torso=15, armor_heal=0, armor_use=500},
wear = 0,
})
minetest.register_tool("3d_armor:leggings_steel", {
description = "Steel Leggings",
inventory_image = "3d_armor_inv_leggings_steel.png",
groups = {armor_legs=15, armor_heal=0, armor_use=500},
wear = 0,
})
minetest.register_tool("3d_armor:boots_steel", {
description = "Steel Boots",
inventory_image = "3d_armor_inv_boots_steel.png",
groups = {armor_feet=10, armor_heal=0, armor_use=500},
wear = 0,
})
end
minetest.register_tool("3d_armor:helmet_bronze", {
description = "Bronze Helmet",
inventory_image = "3d_armor_inv_helmet_bronze.png",
groups = {armor_head = 10, armor_heal = 6, armor_use = 250},
wear = 0,
})
if ARMOR_MATERIALS.bronze then
minetest.register_tool("3d_armor:helmet_bronze", {
description = "Bronze Helmet",
inventory_image = "3d_armor_inv_helmet_bronze.png",
groups = {armor_head=10, armor_heal=6, armor_use=250},
wear = 0,
})
minetest.register_tool("3d_armor:chestplate_bronze", {
description = "Bronze Chestplate",
inventory_image = "3d_armor_inv_chestplate_bronze.png",
groups = {armor_torso=15, armor_heal=6, armor_use=250},
wear = 0,
})
minetest.register_tool("3d_armor:leggings_bronze", {
description = "Bronze Leggings",
inventory_image = "3d_armor_inv_leggings_bronze.png",
groups = {armor_legs=15, armor_heal=6, armor_use=250},
wear = 0,
})
minetest.register_tool("3d_armor:boots_bronze", {
description = "Bronze Boots",
inventory_image = "3d_armor_inv_boots_bronze.png",
groups = {armor_feet=10, armor_heal=6, armor_use=250},
wear = 0,
})
end
--[[
minetest.register_tool("3d_armor:helmet_diamond", {
description = "Diamond Helmet",
inventory_image = "3d_armor_inv_helmet_diamond.png",
groups = {armor_head = 15, armor_heal = 12, armor_use = 100},
wear = 0,
})]]
minetest.register_tool("3d_armor:helmet_gold", {
description = "Golden Helmet",
inventory_image = "3d_armor_inv_helmet_gold.png",
groups = {armor_head = 10, armor_heal = 6, armor_use = 250},
wear = 0,
})
if use_moreores then
if ARMOR_MATERIALS.diamond then
minetest.register_tool("3d_armor:helmet_diamond", {
description = "Diamond Helmet",
inventory_image = "3d_armor_inv_helmet_diamond.png",
groups = {armor_head=15, armor_heal=12, armor_use=100},
wear = 0,
})
minetest.register_tool("3d_armor:chestplate_diamond", {
description = "Diamond Chestplate",
inventory_image = "3d_armor_inv_chestplate_diamond.png",
groups = {armor_torso=20, armor_heal=12, armor_use=100},
wear = 0,
})
minetest.register_tool("3d_armor:leggings_diamond", {
description = "Diamond Leggings",
inventory_image = "3d_armor_inv_leggings_diamond.png",
groups = {armor_legs=20, armor_heal=12, armor_use=100},
wear = 0,
})
minetest.register_tool("3d_armor:boots_diamond", {
description = "Diamond Boots",
inventory_image = "3d_armor_inv_boots_diamond.png",
groups = {armor_feet=15, armor_heal=12, armor_use=100},
wear = 0,
})
end
]]
if ARMOR_MATERIALS.gold then
minetest.register_tool("3d_armor:helmet_gold", {
description = "Gold Helmet",
inventory_image = "3d_armor_inv_helmet_gold.png",
groups = {armor_head=10, armor_heal=6, armor_use=250},
wear = 0,
})
minetest.register_tool("3d_armor:chestplate_gold", {
description = "Gold Chestplate",
inventory_image = "3d_armor_inv_chestplate_gold.png",
groups = {armor_torso=15, armor_heal=6, armor_use=250},
wear = 0,
})
minetest.register_tool("3d_armor:leggings_gold", {
description = "Gold Leggings",
inventory_image = "3d_armor_inv_leggings_gold.png",
groups = {armor_legs=15, armor_heal=6, armor_use=250},
wear = 0,
})
minetest.register_tool("3d_armor:boots_gold", {
description = "Gold Boots",
inventory_image = "3d_armor_inv_boots_gold.png",
groups = {armor_feet=10, armor_heal=6, armor_use=250},
wear = 0,
})
end
--[[
if ARMOR_MATERIALS.mithril then
minetest.register_tool("3d_armor:helmet_mithril", {
description = "Mithril Helmet",
inventory_image = "3d_armor_inv_helmet_mithril.png",
groups = {armor_head = 15, armor_heal = 12, armor_use = 50},
groups = {armor_head=15, armor_heal=12, armor_use=50},
wear = 0,
})
end
-- Register chestplates:
minetest.register_tool("3d_armor:chestplate_wood", {
description = "Wooden Chestplate",
inventory_image = "3d_armor_inv_chestplate_wood.png",
groups = {armor_torso = 10, armor_heal = 0, armor_use = 2000},
wear = 0,
})
minetest.register_tool("3d_armor:chestplate_steel", {
description = "Steel Chestplate",
inventory_image = "3d_armor_inv_chestplate_steel.png",
groups = {armor_torso = 15, armor_heal = 0, armor_use = 500},
wear = 0,
})
minetest.register_tool("3d_armor:chestplate_bronze", {
description = "Bronze Chestplate",
inventory_image = "3d_armor_inv_chestplate_bronze.png",
groups = {armor_torso = 15, armor_heal = 6, armor_use = 250},
wear = 0,
})
--[[
minetest.register_tool("3d_armor:chestplate_diamond", {
description = "Diamond Chestplate",
inventory_image = "3d_armor_inv_chestplate_diamond.png",
groups = {armor_torso = 20, armor_heal = 12, armor_use = 100},
wear = 0,
})]]
minetest.register_tool("3d_armor:chestplate_gold", {
description = "Golden Chestplate",
inventory_image = "3d_armor_inv_chestplate_gold.png",
groups = {armor_torso = 15, armor_heal = 6, armor_use = 250},
wear = 0,
})
if use_moreores then
minetest.register_tool("3d_armor:chestplate_mithril", {
description = "Mithril Chestplate",
inventory_image = "3d_armor_inv_chestplate_mithril.png",
groups = {armor_torso = 20, armor_heal = 12, armor_use = 50},
groups = {armor_torso=20, armor_heal=12, armor_use=50},
wear = 0,
})
end
-- Register leggings:
minetest.register_tool("3d_armor:leggings_wood", {
description = "Wooden Leggings",
inventory_image = "3d_armor_inv_leggings_wood.png",
groups = {armor_legs = 5, armor_heal = 0, armor_use = 2000},
wear = 0,
})
minetest.register_tool("3d_armor:leggings_steel", {
description = "Steel Leggings",
inventory_image = "3d_armor_inv_leggings_steel.png",
groups = {armor_legs = 15, armor_heal = 0, armor_use = 500},
wear = 0,
})
minetest.register_tool("3d_armor:leggings_bronze", {
description = "Bronze Leggings",
inventory_image = "3d_armor_inv_leggings_bronze.png",
groups = {armor_legs = 15, armor_heal = 6, armor_use = 250},
wear = 0,
})
--[[
minetest.register_tool("3d_armor:leggings_diamond", {
description = "Diamond Leggings",
inventory_image = "3d_armor_inv_leggings_diamond.png",
groups = {armor_legs = 20, armor_heal = 12, armor_use = 100},
wear = 0,
})]]
minetest.register_tool("3d_armor:leggings_gold", {
description = "Golden Leggings",
inventory_image = "3d_armor_inv_leggings_gold.png",
groups = {armor_legs = 15, armor_heal = 6, armor_use = 250},
wear = 0,
})
if use_moreores then
minetest.register_tool("3d_armor:leggings_mithril", {
description = "Mithril Leggings",
inventory_image = "3d_armor_inv_leggings_mithril.png",
groups = {armor_legs = 20, armor_heal = 12, armor_use = 50},
groups = {armor_legs=20, armor_heal=12, armor_use=50},
wear = 0,
})
end
-- Register boots:
minetest.register_tool("3d_armor:boots_wood", {
description = "Wooden Boots",
inventory_image = "3d_armor_inv_boots_wood.png",
groups = {armor_feet = 5, armor_heal = 0, armor_use = 2000},
wear = 0,
})
minetest.register_tool("3d_armor:boots_steel", {
description = "Steel Boots",
inventory_image = "3d_armor_inv_boots_steel.png",
groups = {armor_feet = 10, armor_heal = 0, armor_use = 500},
wear = 0,
})
minetest.register_tool("3d_armor:boots_bronze", {
description = "Bronze Boots",
inventory_image = "3d_armor_inv_boots_bronze.png",
groups = {armor_feet = 10, armor_heal = 6, armor_use = 250},
wear = 0,
})
--[[
minetest.register_tool("3d_armor:boots_diamond", {
description = "Diamond Boots",
inventory_image = "3d_armor_inv_boots_diamond.png",
groups = {armor_feet = 15, armor_heal = 12, armor_use = 100},
wear = 0,
})]]
minetest.register_tool("3d_armor:boots_gold", {
description = "Golden Boots",
inventory_image = "3d_armor_inv_boots_gold.png",
groups = {armor_feet = 10, armor_heal = 6, armor_use = 250},
wear = 0,
})
if use_moreores then
minetest.register_tool("3d_armor:boots_mithril", {
description = "Mithril Boots",
inventory_image = "3d_armor_inv_boots_mithril.png",
groups = {armor_feet = 15, armor_heal = 12, armor_use = 50},
groups = {armor_feet=15, armor_heal=12, armor_use=50},
wear = 0,
})
end
-- Register crafting recipes:
local craft_ingreds = {
wood = "default:wood",
steel = "default:steel_ingot",
bronze = "default:bronze_ingot",
diamond = "default:diamond",
gold = "default:gold_ingot",
}
if use_moreores then
craft_ingreds.mithril = "moreores:mithril_ingot"
if ARMOR_MATERIALS.crystal then
minetest.register_tool("3d_armor:helmet_crystal", {
description = "Crystal Helmet",
inventory_image = "3d_armor_inv_helmet_crystal.png",
groups = {armor_head=15, armor_heal=12, armor_use=50, armor_fire=1},
wear = 0,
})
minetest.register_tool("3d_armor:chestplate_crystal", {
description = "Crystal Chestplate",
inventory_image = "3d_armor_inv_chestplate_crystal.png",
groups = {armor_torso=20, armor_heal=12, armor_use=50, armor_fire=1},
wear = 0,
})
minetest.register_tool("3d_armor:leggings_crystal", {
description = "Crystal Leggings",
inventory_image = "3d_armor_inv_leggings_crystal.png",
groups = {armor_legs=20, armor_heal=12, armor_use=50, armor_fire=1},
wear = 0,
})
minetest.register_tool("3d_armor:boots_crystal", {
description = "Crystal Boots",
inventory_image = "3d_armor_inv_boots_crystal.png",
groups = {armor_feet=15, armor_heal=12, armor_use=50, physics_speed=1, physics_jump=0.5, armor_fire=1},
wear = 0,
})
end
for k, v in pairs(craft_ingreds) do
]]
for k, v in pairs(ARMOR_MATERIALS) do
minetest.register_craft({
output = "3d_armor:helmet_"..k,
recipe = {
@ -234,6 +252,3 @@ for k, v in pairs(craft_ingreds) do
})
end
if minetest.setting_getbool("log_mods") then
minetest.log("action", "Carbone: [3d_armor] loaded.")
end

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 494 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 782 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 712 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 725 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 883 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 883 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 424 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 835 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 256 B

After

Width:  |  Height:  |  Size: 907 B

View File

@ -116,11 +116,7 @@ bp:register_mob("esmobs:sheep", {
end,
})
<<<<<<< HEAD
bp:register_spawn("esmobs:sheep", {"default:dirt_with_grass","default:dirt_with_dry_grass", "default:dry:dirt", "ethereal:green_dirt"}, 18, -1, 6000, 2, 31000)
=======
bp:register_spawn("esmobs:sheep", {"default:dirt_with_grass","default:dry_grass", "ethereal:green_dirt"}, 5, -1, 12000, 2, 31000)
>>>>>>> origin/master
--bp:register_egg("esmobs:sheep", "Sheep", "wool_white.png", 1)

View File

@ -3,7 +3,7 @@ minetest.register_on_newplayer(function(player)
minetest.log("action", "Giving initial stuff to player "..player:get_player_name())
player:get_inventory():add_item('main', 'default:sword_bronze 1')
player:get_inventory():add_item('main', 'default:torch 55')
player:get_inventory():add_item('main', 'thirsty:steel_canteen 1')
-- player:get_inventory():add_item('main', 'thirsty:steel_canteen 1')
player:get_inventory():add_item('main', 'shooter:rifle 1')
player:get_inventory():add_item('main', 'default:pick_steel 1')
player:get_inventory():add_item('main', 'default:sapling 1')

48
mods/hbarmor/README.txt Normal file
View File

@ -0,0 +1,48 @@
Minetest mod: HUD bar for armor [hbarmor]
=========================================
Version: 0.1.0
License of source code: WTFPL
-----------------------------
By Wuzzy,
forked from the mod “Better HUD (and hunger)” [hud]
by BlockMen (2013-2014).
Using the mod:
--------------
This mod adds a simple HUD bar which displays the current
damage of the player's armor (from the 3D Armor mod) as a percentage,
this number is of course rounded.
100% means the armor is in perfect shape, 0% means the armor
is almost destroyed or non-existant.
Note that to reach 100%, the player must wear at least 4 different
pieces of armor in perfect shape.
The armor bar also does not tell anything about the armor's strength,
only how worn out it already is.
By default, the armor bar is hidden if the player wears no armor.
Dependencies:
- HUD bars [hudbars], major version 1
- 3D Armor [3d_armor] (tested with 0.4.3)
License of textures:
--------------------
hbarmor_icon.png - Stu (CC BY-SA 3.0), modified by BlockMen
hbarmor_bar.png - Wuzzy (WTFPL)
everything else is WTFPL:
(c) Copyright BlockMen (2013-2014)
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.

37
mods/hbarmor/armor.lua Normal file
View File

@ -0,0 +1,37 @@
minetest.after(0, function()
if not armor.def then
minetest.after(2,minetest.chat_send_all,"#Better HUD: Please update your version of 3darmor")
HUD_SHOW_ARMOR = false
end
end)
function hbarmor.get_armor(player)
if not player or not armor.def then
return false
end
local name = player:get_player_name()
local def = armor.def[name] or nil
if def and def.state and def.count then
hbarmor.set_armor(name, def.state, def.count)
else
return false
end
return true
end
function hbarmor.set_armor(player_name, ges_state, items)
local max_items = 4
if items == 5 then
max_items = items
end
local max = max_items * 65535
local lvl = max - ges_state
lvl = lvl/max
if ges_state == 0 and items == 0 then
lvl = 0
end
hbarmor.armor[player_name] = lvl* (items * (100 / max_items))
end

View File

@ -0,0 +1,88 @@
0.2 Beta
--------
- added support of custom config files
- you can eat max. 50% more than before (although it isnt shown in hunger bar)
- you get healed with 8 breads and more (in hunger bar) now
- a bread (from farming) == 2 breads in hunger bar
0.2.1 Beta
----------
- tweaked override of food
- added support for food of dwares, moretrees and simple mobs
0.2.2 Beta
----------
- added support for food of animalmaterials (mobf modpack),fishing
0.2.3 Beta
----------
- added support for food of glooptest and bushes (commit by CheeseKeg)
0.3 Beta
----------
- added fancy borders of hud inventory bar (only for screenheight <= 800)
0.4 Beta
----------
- enabled drowning
0.5 Beta
----------
- removed the fancy borders of hud inventory bar and moved to new native support
- moved crosshair to native support too
1.0
---
- hunger is reset after death
- health and hunger bar is shown correct on all screen resolutions now
- switched to changed native hotbar image support
- fixed revival of player when drown
- hunger bar is not shown anymore if hunger is disabled
- hunger can be disabled by minetest.conf ("hud_hunger_enable = false")
1.1
---
- added support for stu's 3darmor mod
- restructured and cleaned up code
- added support for poisen food (damages player, but does not kill)
1.2
---
- Send statbar values only to client when changed
- Hide armor bar if not wearing armor
- More reliable food overrides (by CiaranG)
- Support for bushes_classic foods (plantlife modpack) (by CiaranG)
- Add support for mushroom mod food/poison (by CiaranG)
- Add support for mods: fruit and mush45
- New images for hotbar, smaller armor icons
1.3
---
- New way hunger is saved (all old files in world dirctory can get deleted [e.g. hud_BlockMen_hunger])
- Fixed healing (not while drowning, fix after death)
- Add support for mods: seaplants[sea] and mobfcooking (by Xanthin)
- Tweaked hand image
- Player can die caus of starving now
1.3.1
-----
- Add compatibility for statbar scaling
- Fix typo in depends.txt
- Lower maintimer tick
1.3.2
-----
- Fix dependecies (by Chris Beelby)
- Add support for creatures mod
- Add optional healing for food (by TenPlus1)
1.3.3
-----
- Prevent crash with armor mod and missing player
- Add support for ethereal mod (by TenPlus1)
1.4
---
- New hunger mechanics/added experimental player-action based hunger
- Better crosshair texture, switched to "new" default hand
- Added support for farming redo mod, kpgmobs and jkmod

2
mods/hbarmor/depends.txt Normal file
View File

@ -0,0 +1,2 @@
hudbars
3d_armor

View File

@ -0,0 +1,9 @@
-- If true, automatically hides the armor when the player wears no armor.
-- Otherwise, the armor bar shows “0%”.
--hbarmor.autohide = true
-- Time difference in seconds between updates to the HUD armor bar.
-- Increase this number for slow servers.
-- hbarmor.tick = 0.1

113
mods/hbarmor/init.lua Normal file
View File

@ -0,0 +1,113 @@
hbarmor = {}
-- HUD statbar values
hbarmor.armor = {}
-- Stores if player's HUD bar has been initialized so far.
hbarmor.player_active = {}
-- HUD item ids
local armor_hud = {}
hbarmor.tick = 0.1
-- If true, the armor bar is hidden when the player does not wear any armor
hbarmor.autohide = true
--load custom settings
local set = io.open(minetest.get_modpath("hbarmor").."/hbarmor.conf", "r")
if set then
dofile(minetest.get_modpath("hbarmor").."/hbarmor.conf")
set:close()
end
local must_hide = function(playername, arm)
return ((not armor.def[playername].count or armor.def[playername].count == 0) and arm == 0)
end
local arm_printable = function(arm)
return math.ceil(math.floor(arm+0.5))
end
local function custom_hud(player)
local name = player:get_player_name()
if minetest.setting_getbool("enable_damage") then
local ret = hbarmor.get_armor(player)
if ret == false then
minetest.log("error", "[hbarmor] Call to hbarmor.get_armor in custom_hud returned with false!")
end
local arm = tonumber(hbarmor.armor[name])
if not arm then arm = 0 end
local hide
if hbarmor.autohide then
hide = must_hide(name, arm)
else
hide = false
end
hb.init_hudbar(player, "armor", arm_printable(arm), nil, hide)
end
end
--register and define armor HUD bar
hb.register_hudbar("armor", 0xFFFFFF, "Armor", { icon = "hbarmor_icon.png", bar = "hbarmor_bar.png" }, 0, 100, hbarmor.autohide, "%s: %d%%")
dofile(minetest.get_modpath("hbarmor").."/armor.lua")
-- update hud elemtens if value has changed
local function update_hud(player)
local name = player:get_player_name()
--armor
local arm = tonumber(hbarmor.armor[name])
if not arm then
arm = 0
hbarmor.armor[name] = 0
end
if hbarmor.autohide then
-- hide armor bar completely when there is none
if must_hide(name, arm) then
hb.hide_hudbar(player, "armor")
else
hb.change_hudbar(player, "armor", arm_printable(arm))
hb.unhide_hudbar(player, "armor")
end
else
hb.change_hudbar(player, "armor", arm_printable(arm))
end
end
minetest.register_on_joinplayer(function(player)
local name = player:get_player_name()
custom_hud(player)
hbarmor.player_active[name] = true
end)
minetest.register_on_leaveplayer(function(player)
local name = player:get_player_name()
hbarmor.player_active[name] = false
end)
local main_timer = 0
local timer = 0
minetest.register_globalstep(function(dtime)
main_timer = main_timer + dtime
timer = timer + dtime
if main_timer > hbarmor.tick or timer > 4 then
if minetest.setting_getbool("enable_damage") then
if main_timer > hbarmor.tick then main_timer = 0 end
for _,player in ipairs(minetest.get_connected_players()) do
local name = player:get_player_name()
if hbarmor.player_active[name] == true then
local ret = hbarmor.get_armor(player)
if ret == false then
minetest.log("error", "[hbarmor] Call to hbarmor.get_armor in globalstep returned with false!")
end
-- update all hud elements
update_hud(player)
end
end
end
end
if timer > 4 then timer = 0 end
end)

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

76
mods/hbhunger/README.txt Normal file
View File

@ -0,0 +1,76 @@
Minetest mod: Hunger [hbhunger]
===============================
Version: 0.3.2
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_bgicon.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

@ -0,0 +1,22 @@
0.1.0
-----
Initial release
0.2.0
-----
- Change “saturation” to “satiation”
- Rename global table to “hbhunger” to avoid collisions
- General cleanup
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

28
mods/hbhunger/depends.txt Normal file
View File

@ -0,0 +1,28 @@
hudbars
default?
animalmaterials?
bucket?
bushes?
bushes_classic?
cooking?
creatures?
docfarming?
dwarves?
ethereal?
farming?
farming_plus?
ferns?
fishing?
fruit?
glooptest?
jkanimals?
jkfarming?
jkwine?
kpgmobs?
mobfcooking?
mobs?
moretrees?
mtfoods?
mush45?
mushroom?
seaplants?

397
mods/hbhunger/hunger.lua Normal file
View File

@ -0,0 +1,397 @@
-- Keep these for backwards compatibility
function hbhunger.save_hunger(player)
hbhunger.set_hunger(player)
end
function hbhunger.load_hunger(player)
hbhunger.get_hunger(player)
end
-- Poison player
local function poisenp(tick, time, time_left, player)
time_left = time_left + tick
if time_left < time then
minetest.after(tick, poisenp, tick, time, time_left, player)
else
--reset hud image
end
if player:get_hp()-1 > 0 then
player:set_hp(player:get_hp()-1)
end
end
function hbhunger.item_eat(hunger_change, replace_with_item, poisen, heal)
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})
-- 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)
end
-- Healing
if hp < 20 and heal then
hp = hp + heal
if hp > 20 then hp = 20 end
user:set_hp(hp)
end
-- Poison
if poisen then
--set hud-img
poisenp(1.0, poisen, 0, user)
end
--sound:eat
itemstack:add_item(replace_with_item)
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)
end
if minetest.get_modpath("farming") ~= nil then
overwrite("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)
if minetest.get_modpath("bucket") then
overwrite("mobs:bucket_milk", 3, "bucket:bucket_empty")
end
else
overwrite("mobs:meat", 6)
overwrite("mobs:meat_raw", 3)
overwrite("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)
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)
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)
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)
end
if minetest.get_modpath("glooptest") ~= nil then
overwrite("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)
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
overwrite("bushes:"..berry, 1)
end
overwrite("bushes:"..berry.."_pie_raw", 2)
overwrite("bushes:"..berry.."_pie_cooked", 5)
overwrite("bushes:basket_"..berry, 15)
end
end
if minetest.get_modpath("mushroom") ~= nil then
overwrite("mushroom:brown", 1)
overwrite("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)
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)
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)
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)
--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)
end
if minetest.get_modpath("fruit") ~= nil then
overwrite("fruit:apple", 2)
overwrite("fruit:pear", 2)
overwrite("fruit:bananna", 3)
overwrite("fruit:orange", 2)
end
if minetest.get_modpath("mush45") ~= nil then
overwrite("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)
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)
end
if minetest.get_modpath("creatures") ~= nil then
overwrite("creatures:meat", 6)
overwrite("creatures:flesh", 3)
overwrite("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")
if minetest.get_modpath("bucket") then
overwrite("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)
overwrite("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)
if minetest.get_modpath("vessels") then
overwrite("farming:smoothie_raspberry", 2, "vessels:drinking_glass")
end
overwrite("farming:rhubarb", 1)
overwrite("farming:rhubarb_pie", 6)
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)
if minetest.get_modpath("bucket") then
overwrite("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)
end
if minetest.get_modpath("jkanimals") ~= nil then
overwrite("jkanimals:meat", 6)
end
if minetest.get_modpath("jkwine") ~= nil then
overwrite("jkwine:grapes", 2)
overwrite("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)
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)
end
-- player-action based hunger changes
function hbhunger.handle_node_actions(pos, oldnode, player, ext)
if not player or not player:is_player() then
return
end
local name = player:get_player_name()
local exhaus = hbhunger.exhaustion[name]
if exhaus == nil then return end
local new = HUNGER_EXHAUST_PLACE
-- placenode event
if not ext then
new = HUNGER_EXHAUST_DIG
end
-- assume its send by main timer when movement detected
if not pos and not oldnode then
new = HUNGER_EXHAUST_MOVE
end
exhaus = exhaus + new
if exhaus > HUNGER_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)
end
hbhunger.exhaustion[name] = exhaus
end
minetest.register_on_placenode(hbhunger.handle_node_actions)
minetest.register_on_dignode(hbhunger.handle_node_actions)

143
mods/hbhunger/init.lua Normal file
View File

@ -0,0 +1,143 @@
if minetest.setting_getbool("enable_damage") then
hbhunger = {}
-- HUD statbar values
hbhunger.hunger = {}
hbhunger.hunger_out = {}
-- HUD item ids
local hunger_hud = {}
HUNGER_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
--load custom settings
local set = io.open(minetest.get_modpath("hbhunger").."/hbhunger.conf", "r")
if set then
dofile(minetest.get_modpath("hbhunger").."/hbhunger.conf")
set:close()
end
local function custom_hud(player)
hb.init_hudbar(player, "satiation", hbhunger.get_hunger(player))
end
dofile(minetest.get_modpath("hbhunger").."/hunger.lua")
-- register satiation hudbar
hb.register_hudbar("satiation", 0xFFFFFF, "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)
local name = player:get_player_name()
--hunger
local h_out = tonumber(hbhunger.hunger_out[name])
local h = tonumber(hbhunger.hunger[name])
if h_out ~= h then
hbhunger.hunger_out[name] = h
hb.change_hudbar(player, "satiation", h)
end
end
hbhunger.get_hunger = function(player)
local inv = player:get_inventory()
if not inv then return nil end
local hgp = inv:get_stack("hunger", 1):get_count()
if hgp == 0 then
hgp = 21
inv:set_stack("hunger", 1, ItemStack({name=":", count=hgp}))
else
hgp = hgp
end
return hgp-1
end
hbhunger.set_hunger = function(player)
local inv = player:get_inventory()
local name = player:get_player_name()
local value = hbhunger.hunger[name]
if not inv or not value then return nil end
if value > 30 then value = 30 end
if value < 0 then value = 0 end
inv:set_stack("hunger", 1, ItemStack({name=":", count=value+1}))
return true
end
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_out[name] = hbhunger.hunger[name]
hbhunger.exhaustion[name] = 0
custom_hud(player)
hbhunger.set_hunger(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.exhaustion[name] = 0
end)
local main_timer = 0
local timer = 0
local timer2 = 0
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
for _,player in ipairs(minetest.get_connected_players()) do
local name = player:get_player_name()
local h = tonumber(hbhunger.hunger[name])
local hp = player:get_hp()
if timer > 4 then
-- heal player by 1 hp if not dead and satiation is > 15 (of 30)
if h > 15 and hp > 0 and player:get_breath() > 0 then
player:set_hp(hp+1)
-- or damage player by 1 hp if satiation is < 2 (of 30)
elseif h <= 1 then
if hp-1 >= 0 then player:set_hp(hp-1) end
end
end
-- lower satiation by 1 point after xx seconds
if timer2 > HUNGER_HUNGER_TICK then
if h > 0 then
h = h-1
hbhunger.hunger[name] = h
hbhunger.set_hunger(player)
end
end
-- update all hud elements
update_hud(player)
local controls = player:get_player_control()
-- Determine if the player is walking
if controls.up or controls.down or controls.left or controls.right then
hbhunger.handle_node_actions(nil, nil, player)
end
end
end
if timer > 4 then timer = 0 end
if timer2 > HUNGER_HUNGER_TICK then timer2 = 0 end
end)
end

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 417 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 B

View File

@ -38,11 +38,7 @@ thirsty.config = {
thirst_per_second = 1.0 / 20.0,
-- Damage per second if completely thirsty / out of hydration
<<<<<<< HEAD
damage_per_second = 0.5 / 10.0,
=======
damage_per_second = 1.0 / 10.0,
>>>>>>> origin/master
--[[ How long in seconds you have to remain still to drink
from standing in water