Move HUD and armor to default, add sprinting

master
BlockMen 2014-05-12 04:30:35 +02:00
parent 53eb0e9025
commit e208290d29
77 changed files with 807 additions and 1266 deletions

125
mods/default/armor.lua Normal file
View File

@ -0,0 +1,125 @@
default.player.armor = {}
local elements = {"head", "torso", "legs", "feet"}
default.armor_update_visual = function(player)
local name = player:get_player_name()
--local list = dump(default.player[name].armor)
local textures = ""
for _,v in ipairs(elements) do
local element = default.player[name].armor["armor_"..v]
if element ~= nil then
textures = textures .. "^"..element:gsub("%:", "_")..".png"
end
end
if textures == "" then textures = "default_armor_trans.png" end
default.player_set_textures(player, {"character.png",
textures:sub(1),
"default_trans.png",--to show no wielded items
})
end
-- called by hud when hp changed
default.armor_update = function(player, heal, list, old_hp)
if not player then
return
end
local name = player:get_player_name()
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 now_hp = player:get_hp()
local heal_max = 0
local state = 0
local items = 0
for _,v in ipairs(elements) do
local stack = armor_inv:get_stack("armor_"..v, 1)
if stack:get_count() > 0 then
if heal and old_hp~=nil and now_hp < old_hp then
local use = stack:get_definition().groups["armor_use"] or 0
local heal_p = stack:get_definition().groups["armor_heal"] or 0
local item = stack:get_name()
local damage_amount = (old_hp-now_hp)/2
use = use * damage_amount
stack:add_wear(use)
armor_inv:set_stack("armor_"..v, 1, stack)
player_inv:set_stack("armor_"..v, 1, stack)
heal_max = heal_max + heal_p
end
if list then
default.player[name].armor["armor_"..v] = stack:get_name()
end
if stack:get_wear() < 1 and stack:get_count() == 0 then
default.player[name].armor["armor_"..v] = nil
else
state = state + stack:get_wear()
items = items + 1
end
end
end
default.player[name].armor["wear"] = state
default.player[name].armor["cnt"] = items
local max = 4*65535
local lvl = max - state
lvl = lvl/max
if state == 0 and items == 0 then
lvl = 0
end
if default.hud ~= nil then
default.hud.armor[name] = lvl*(items*5)
end
default.armor_update_visual(player)
if heal and heal_max > math.random(100) and player:get_hp() > 0 then
--player:set_hp(old_hp)
return true
end
--default.armor_update_visual(player)
end
minetest.register_on_joinplayer(function(player)
local name = player:get_player_name()
default.player[name].armor = {}
default.player[name].armor["cnt"] = 0
default.player[name].armor["wear"] = 0
local player_inv = player:get_inventory()
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)
default.player[name].armor[listname] = stack:get_name()
default.player[name].armor["cnt"] = default.player[name].armor["cnt"] + 1
default.armor_update(player)
end,
on_take = function(inv, listname, index, stack, player)
player:get_inventory():set_stack(listname, index, nil)
default.player[name].armor[listname] = nil
default.player[name].armor["cnt"] = default.player[name].armor["cnt"] - 1
default.armor_update(player)--armor:set_player_armor(player)
end,
allow_put = function(inv, listname, index, stack, player)
local field = minetest.registered_items[stack:get_name()]
if (field and field.groups[listname] and field.groups[listname] ~= 0) and inv:is_empty(listname) then
return 1
end
return 0
end,
allow_take = function(inv, listname, index, stack, player)
return stack:get_count()
end,
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
return 0
end,
})
for _,v in ipairs(elements) do
local list = "armor_"..v
player_inv:set_size(list, 1)
armor_inv:set_size(list, 1)
armor_inv:set_stack(list, 1, player_inv:get_stack(list, 1))
end
default.armor_update(player, false, true)
end)

499
mods/default/hud.lua Normal file
View File

@ -0,0 +1,499 @@
default.hud = {}
-- HUD statbar values
default.hud.health = {}
default.hud.hunger = {}
default.hud.air = {}
default.hud.armor = {}
default.hud.hunger_out = {}
default.hud.armor_out = {}
-- HUD item ids
local health_hud = {}
local hunger_hud = {}
local air_hud = {}
local armor_hud = {}
local armor_hud_bg = {}
-- default settings
-- statbar positions
HUD_HEALTH_POS = {x=0.5,y=0.9}
HUD_HEALTH_OFFSET = {x=-175, y=2}
HUD_HUNGER_POS = {x=0.5,y=0.9}
HUD_HUNGER_OFFSET = {x=15, y=2}
HUD_AIR_POS = {x=0.5,y=0.9}
HUD_AIR_OFFSET = {x=15,y=-15}
HUD_ARMOR_POS = {x=0.5,y=0.9}
HUD_ARMOR_OFFSET = {x=-175, y=-15}
HUD_TICK = 0.2
HUD_HUNGER_TICK = 300
HUD_ENABLE_HUNGER = minetest.setting_getbool("hud_hunger_enable")
if HUD_ENABLE_HUNGER == nil then
HUD_ENABLE_HUNGER = minetest.setting_getbool("enable_damage")
end
HUD_SHOW_ARMOR = false
if minetest.get_modpath("3d_armor") ~= nil then
HUD_SHOW_ARMOR = true
end
local function hide_builtin(player)
player:hud_set_flags({crosshair = true, hotbar = true, healthbar = false, wielditem = true, breathbar = false})
end
local function custom_hud(player)
local name = player:get_player_name()
-- fancy hotbar (only when no crafting mod present)
if minetest.get_modpath("crafting") == nil then
player:hud_set_hotbar_image("default_hud_hotbar.png")
player:hud_set_hotbar_selected_image("default_hud_hotbar_selected.png")
end
if minetest.setting_getbool("enable_damage") then
--hunger
if HUD_ENABLE_HUNGER then
player:hud_add({
hud_elem_type = "statbar",
position = HUD_HUNGER_POS,
size = {x=16, y=16},
text = "default_hud_hunger_bg.png",
number = 20,
alignment = {x=-1,y=-1},
offset = HUD_HUNGER_OFFSET,
})
local h = default.hud.hunger[name]
if h == nil or h > 20 then h = 20 end
hunger_hud[name] = player:hud_add({
hud_elem_type = "statbar",
position = HUD_HUNGER_POS,
size = {x=16, y=16},
text = "default_hud_hunger_fg.png",
number = h,
alignment = {x=-1,y=-1},
offset = HUD_HUNGER_OFFSET,
})
end
--health
player:hud_add({
hud_elem_type = "statbar",
position = HUD_HEALTH_POS,
size = {x=16, y=16},
text = "default_hud_heart_bg.png",
number = 20,
alignment = {x=-1,y=-1},
offset = HUD_HEALTH_OFFSET,
})
health_hud[name] = player:hud_add({
hud_elem_type = "statbar",
position = HUD_HEALTH_POS,
size = {x=16, y=16},
text = "default_hud_heart_fg.png",
number = player:get_hp(),
alignment = {x=-1,y=-1},
offset = HUD_HEALTH_OFFSET,
})
--air
air_hud[name] = player:hud_add({
hud_elem_type = "statbar",
position = HUD_AIR_POS,
scale = {x=1, y=1},
text = "default_hud_air_fg.png",
number = 0,
alignment = {x=-1,y=-1},
offset = HUD_AIR_OFFSET,
})
--armor
if HUD_SHOW_ARMOR then
armor_hud_bg[name] = player:hud_add({
hud_elem_type = "statbar",
position = HUD_ARMOR_POS,
scale = {x=1, y=1},
text = "default_hud_armor_bg.png",
number = 0,
alignment = {x=-1,y=-1},
offset = HUD_ARMOR_OFFSET,
})
armor_hud[name] = player:hud_add({
hud_elem_type = "statbar",
position = HUD_ARMOR_POS,
scale = {x=1, y=1},
text = "default_hud_armor_fg.png",
number = 0,
alignment = {x=-1,y=-1},
offset = HUD_ARMOR_OFFSET,
})
end
end
end
--needs to be defined for older version of 3darmor
function default.hud.set_armor()
end
--if HUD_ENABLE_HUNGER then dofile(minetest.get_modpath("hud").."/hunger.lua") end
if HUD_SHOW_ARMOR then dofile(minetest.get_modpath("hud").."/armor.lua") end
-- update hud elemtens if value has changed
local function update_hud(player)
local name = player:get_player_name()
--air
local air = tonumber(default.hud.air[name])
if player:get_breath() ~= air then
air = player:get_breath()
default.hud.air[name] = air
if air > 10 then air = 0 end
player:hud_change(air_hud[name], "number", air*2)
end
--health
local hp = tonumber(default.hud.health[name])
if player:get_hp() ~= hp then
if default.armor_update(player, true, false, hp) and hp > 0 then
player:set_hp(hp)
else
hp = player:get_hp()
default.hud.health[name] = hp
player:hud_change(health_hud[name], "number", hp)
end
end
--armor
local arm_out = tonumber(default.hud.armor_out[name])
if not arm_out then arm_out = 0 end
local arm = tonumber(default.hud.armor[name])
if not arm then arm = 0 end
if arm_out ~= arm then
default.hud.armor_out[name] = arm
player:hud_change(armor_hud[name], "number", arm)
if (default.player[name].armor["cnt"] == 0) and arm == 0 then
player:hud_change(armor_hud_bg[name], "number", 0)
else
player:hud_change(armor_hud_bg[name], "number", 20)
end
end
--hunger
local h_out = tonumber(default.hud.hunger_out[name])
local h = tonumber(default.hud.hunger[name])
if h_out ~= h then
default.hud.hunger_out[name] = h
-- bar should not have more than 10 icons
if h>20 then h=20 end
player:hud_change(hunger_hud[name], "number", h)
end
end
default.hud.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
default.hud.set_hunger = function(player)
local inv = player:get_inventory()
local name = player:get_player_name()
local value = default.hud.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)
default.hud.health[name] = player:get_hp()
if HUD_ENABLE_HUNGER then
default.hud.hunger[name] = default.hud.get_hunger(player)
default.hud.hunger_out[name] = default.hud.hunger[name]
end
default.hud.armor[name] = 0
default.hud.armor_out[name] = 0
local air = player:get_breath()
default.hud.air[name] = air
minetest.after(0.5, function()
hide_builtin(player)
custom_hud(player)
if HUD_ENABLE_HUNGER then default.hud.set_hunger(player) end
default.armor_update(player)
end)
end)
minetest.register_on_respawnplayer(function(player)
-- reset player breath since the engine doesnt
player:set_breath(11)
-- reset hunger (and save)
default.hud.hunger[player:get_player_name()] = 20
if HUD_ENABLE_HUNGER then
minetest.after(0.5, default.hud.set_hunger, player)
end
default.armor_update(player)
end)
local main_timer = 0
local timer = 0
local timer2 = 0
minetest.after(2.5, function()
minetest.register_globalstep(function(dtime)
main_timer = main_timer + dtime
timer = timer + dtime
timer2 = timer2 + dtime
if main_timer > HUD_TICK or timer > 4 or timer2 > HUD_HUNGER_TICK then
if main_timer > HUD_TICK then main_timer = 0 end
for _,player in ipairs(minetest.get_connected_players()) do
local name = player:get_player_name()
-- only proceed if damage is enabled
if minetest.setting_getbool("enable_damage") then
local h = tonumber(default.hud.hunger[name])
local hp = player:get_hp()
if HUD_ENABLE_HUNGER and timer > 4 then
-- heal player by 1 hp if not dead and saturation is > 15 (of 30)
if h > 15 and hp > 0 and default.hud.air[name] > 0 then
player:set_hp(hp+1)
-- or damage player by 1 hp if saturation is < 2 (of 30)
elseif h <= 1 and minetest.setting_getbool("enable_damage") then
if hp-1 >= 0 then player:set_hp(hp-1) end
end
end
-- lower saturation by 1 point after xx seconds
if HUD_ENABLE_HUNGER and timer2 > HUD_HUNGER_TICK then
if h > 0 then
h = h-1
default.hud.hunger[name] = h
default.hud.set_hunger(player)
end
end
-- update current armor level
if HUD_SHOW_ARMOR then default.hud.get_armor(player) end
-- update all hud elements
update_hud(player)
end
end
end
if timer > 4 then timer = 0 end
if timer2 > HUD_HUNGER_TICK then timer2 = 0 end
end)
end)
--[[
local function costum_hud(player)
local name = player:get_player_name()
--fancy hotbar
if minetest.get_modpath("crafting") == nil then
player:hud_set_hotbar_image("default_hud_hotbar.png")
player:hud_set_hotbar_selected_image("default_hud_hotbar_selected.png")
end
if minetest.setting_getbool("enable_damage") then
--hunger
if HUD_ENABLE_HUNGER then
player:hud_add({
hud_elem_type = "statbar",
position = HUD_HUNGER_POS,
scale = {x=1, y=1},
text = "default_hud_hunger_bg.png",
number = 20,
alignment = {x=-1,y=-1},
offset = HUD_HUNGER_OFFSET,
})
hunger_hud[name] = player:hud_add({
hud_elem_type = "statbar",
position = HUD_HUNGER_POS,
scale = {x=1, y=1},
text = "default_hud_hunger_fg.png",
number = 20,
alignment = {x=-1,y=-1},
offset = HUD_HUNGER_OFFSET,
})
end
--health
player:hud_add({
hud_elem_type = "statbar",
position = HUD_HEALTH_POS,
scale = {x=1, y=1},
text = "default_hud_heart_bg.png",
number = 20,
alignment = {x=-1,y=-1},
offset = HUD_HEALTH_OFFSET,
})
health_hud[name] = player:hud_add({
hud_elem_type = "statbar",
position = HUD_HEALTH_POS,
scale = {x=1, y=1},
text = "default_hud_heart_fg.png",
number = player:get_hp(),
alignment = {x=-1,y=-1},
offset = HUD_HEALTH_OFFSET,
})
--air
air_hud[name] = player:hud_add({
hud_elem_type = "statbar",
position = HUD_AIR_POS,
scale = {x=1, y=1},
text = "default_hud_air_fg.png",
number = 0,
alignment = {x=-1,y=-1},
offset = HUD_AIR_OFFSET,
})
--armor
if HUD_SHOW_ARMOR then
armor_hud_bg[name] = player:hud_add({
hud_elem_type = "statbar",
position = HUD_ARMOR_POS,
scale = {x=1, y=1},
text = "default_hud_armor_bg.png",
number = 0,
alignment = {x=-1,y=-1},
offset = HUD_ARMOR_OFFSET,
})
armor_hud[name] = player:hud_add({
hud_elem_type = "statbar",
position = HUD_ARMOR_POS,
scale = {x=1, y=1},
text = "default_hud_armor_fg.png",
number = 0,
alignment = {x=-1,y=-1},
offset = HUD_ARMOR_OFFSET,
})
end
end
end
local function update_hud(player)
local name = player:get_player_name()
--air
local air = tonumber(default.hud.air[name])
if player:get_breath() ~= air then
air = player:get_breath()
default.hud.air[name] = air
if air > 10 then air = 0 end
player:hud_change(air_hud[name], "number", air*2)
end
--health
local hp = tonumber(default.hud.health[name])
if player:get_hp() ~= hp then
if default.armor_update(player, true, false, hp) and hp > 0 then
player:set_hp(hp)
else
hp = player:get_hp()
default.hud.health[name] = hp
player:hud_change(health_hud[name], "number", hp)
end
end
--armor
local arm_out = tonumber(default.hud.armor_out[name])
if not arm_out then arm_out = 0 end
local arm = tonumber(default.hud.armor[name])
if not arm then arm = 0 end
if arm_out ~= arm then
default.hud.armor_out[name] = arm
player:hud_change(armor_hud[name], "number", arm)
if (default.player[name].armor["cnt"] == 0) and arm == 0 then
player:hud_change(armor_hud_bg[name], "number", 0)
else
player:hud_change(armor_hud_bg[name], "number", 20)
end
end
--hunger
local h_out = tonumber(default.hud.hunger_out[name])
local h = tonumber(default.hud.hunger[name])
if h_out ~= h then
default.hud.hunger_out[name] = h
-- bar should not have more than 10 icons
if h>20 then h=20 end
player:hud_change(hunger_hud[name], "number", h)
end
end
minetest.register_on_joinplayer(function(player)
local name = player:get_player_name()
default.hud.health[name] = player:get_hp()
local air = player:get_breath()
default.hud.air[name] = air
--if HUD_ENABLE_HUNGER then default.hud.hunger[name] = default.hud.load_hunger(player) end
if not default.hud.hunger[name] then
default.hud.hunger[name] = 20
end
default.hud.hunger_out[name] = default.hud.hunger[name]
default.hud.armor[name] = 0
default.hud.armor_out[name] = 0
minetest.after(0.5, function()
hide_builtin(player)
costum_hud(player)
--if HUD_ENABLE_HUNGER then default.hud.save_hunger(player) end
default.armor_update(player)
end)
end)
minetest.register_on_respawnplayer(function(player)
default.hud.hunger[player:get_player_name()] = 20
minetest.after(0.5, function()
--if HUD_ENABLE_HUNGER then default.hud.save_hunger(player) end
end)
end)
local timer = 0
local timer2 = 0
minetest.after(2.5, function()
minetest.register_globalstep(function(dtime)
timer = timer + dtime
timer2 = timer2 + dtime
for _,player in ipairs(minetest.get_connected_players()) do
local name = player:get_player_name()
-- only proceed if damage is enabled
if minetest.setting_getbool("enable_damage") then
local h = tonumber(default.hud.hunger[name])
local hp = player:get_hp()
if HUD_ENABLE_HUNGER and timer > 4 then
-- heal player by 1 hp if not dead and saturation is > 15 (of 30)
if h > 15 and hp > 0 then
player:set_hp(hp+1)
-- or damage player by 1 hp if saturation is < 2 (of 30) and player would not die
elseif h <= 1 and minetest.setting_getbool("enable_damage") then
if hp-1 >= 1 then player:set_hp(hp-1) end
end
end
-- lower saturation by 1 point after xx seconds
if HUD_ENABLE_HUNGER and timer2 > HUD_HUNGER_TICK then
if h > 1 then
h = h-1
default.hud.hunger[name] = h
--default.hud.save_hunger(player)
end
end
-- update current armor level
--if HUD_SHOW_ARMOR then default.hud.get_armor(player) end
-- update all hud elements
update_hud(player)
end
end
if timer > 4 then timer = 0 end
if timer2 > HUD_HUNGER_TICK then timer2 = 0 end
end)
end)]]

View File

@ -24,6 +24,8 @@ dofile(minetest.get_modpath("default").."/craftitems.lua")
dofile(minetest.get_modpath("default").."/crafting.lua")
dofile(minetest.get_modpath("default").."/mapgen.lua")
dofile(minetest.get_modpath("default").."/player.lua")
dofile(minetest.get_modpath("default").."/armor.lua")
dofile(minetest.get_modpath("default").."/hud.lua")
dofile(minetest.get_modpath("default").."/torches.lua")
dofile(minetest.get_modpath("default").."/trees.lua")

View File

@ -50,6 +50,10 @@ model_def = {
]]
default.player = {}
--default.player.armor = {}
-- Player animation blending
-- Note: This is currently broken due to a bug in Irrlicht, leave at 0
local animation_blend = 0
@ -65,7 +69,7 @@ end
-- Default player appearance
default.player_register_model("character.x", {
animation_speed = 30,
animation_speed = 25,
textures = {"character.png"},
animations = {
-- Standard animations.
@ -159,7 +163,9 @@ end
-- Update appearance and formspec when the player joins
minetest.register_on_joinplayer(function(player)
default.player[player:get_player_name()] = {}--player
default.player_set_model(player, "character.x")
player:set_local_animation({x=0, y=79}, {x=168, y=187}, {x=189, y=198}, {x=200, y=219}, 22)--18 for sneaking perfect
if minetest.setting_getbool("creative_mode") then
creative.set_creative_formspec(player, 0, 1)
else
@ -209,6 +215,13 @@ minetest.register_globalstep(function(dtime)
else
player_set_animation(player, "stand", animation_speed_mod)
end
-- sprint
if controls.up and controls.left and controls.right then
player:set_physics_override(1.8, 1, 1)
else
player:set_physics_override(1, 1, 1)
end
end
end
end)

View File

Before

Width:  |  Height:  |  Size: 216 B

After

Width:  |  Height:  |  Size: 216 B

View File

Before

Width:  |  Height:  |  Size: 632 B

After

Width:  |  Height:  |  Size: 632 B

View File

Before

Width:  |  Height:  |  Size: 629 B

After

Width:  |  Height:  |  Size: 629 B

View File

Before

Width:  |  Height:  |  Size: 609 B

After

Width:  |  Height:  |  Size: 609 B

View File

Before

Width:  |  Height:  |  Size: 565 B

After

Width:  |  Height:  |  Size: 565 B

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 933 B

After

Width:  |  Height:  |  Size: 933 B

View File

Before

Width:  |  Height:  |  Size: 878 B

After

Width:  |  Height:  |  Size: 878 B

View File

Before

Width:  |  Height:  |  Size: 858 B

After

Width:  |  Height:  |  Size: 858 B

View File

Before

Width:  |  Height:  |  Size: 863 B

After

Width:  |  Height:  |  Size: 863 B

View File

Before

Width:  |  Height:  |  Size: 213 B

After

Width:  |  Height:  |  Size: 213 B

View File

Before

Width:  |  Height:  |  Size: 212 B

After

Width:  |  Height:  |  Size: 212 B

View File

Before

Width:  |  Height:  |  Size: 209 B

After

Width:  |  Height:  |  Size: 209 B

View File

Before

Width:  |  Height:  |  Size: 213 B

After

Width:  |  Height:  |  Size: 213 B

View File

Before

Width:  |  Height:  |  Size: 258 B

After

Width:  |  Height:  |  Size: 258 B

View File

Before

Width:  |  Height:  |  Size: 244 B

After

Width:  |  Height:  |  Size: 244 B

View File

Before

Width:  |  Height:  |  Size: 232 B

After

Width:  |  Height:  |  Size: 232 B

View File

Before

Width:  |  Height:  |  Size: 232 B

After

Width:  |  Height:  |  Size: 232 B

View File

Before

Width:  |  Height:  |  Size: 229 B

After

Width:  |  Height:  |  Size: 229 B

View File

Before

Width:  |  Height:  |  Size: 232 B

After

Width:  |  Height:  |  Size: 232 B

View File

Before

Width:  |  Height:  |  Size: 239 B

After

Width:  |  Height:  |  Size: 239 B

View File

Before

Width:  |  Height:  |  Size: 242 B

After

Width:  |  Height:  |  Size: 242 B

View File

Before

Width:  |  Height:  |  Size: 234 B

After

Width:  |  Height:  |  Size: 234 B

View File

Before

Width:  |  Height:  |  Size: 237 B

After

Width:  |  Height:  |  Size: 237 B

View File

Before

Width:  |  Height:  |  Size: 639 B

After

Width:  |  Height:  |  Size: 639 B

View File

Before

Width:  |  Height:  |  Size: 622 B

After

Width:  |  Height:  |  Size: 622 B

View File

Before

Width:  |  Height:  |  Size: 578 B

After

Width:  |  Height:  |  Size: 578 B

View File

Before

Width:  |  Height:  |  Size: 577 B

After

Width:  |  Height:  |  Size: 577 B

View File

Before

Width:  |  Height:  |  Size: 146 B

After

Width:  |  Height:  |  Size: 146 B

View File

Before

Width:  |  Height:  |  Size: 579 B

After

Width:  |  Height:  |  Size: 579 B

View File

Before

Width:  |  Height:  |  Size: 424 B

After

Width:  |  Height:  |  Size: 424 B

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Before

Width:  |  Height:  |  Size: 302 B

After

Width:  |  Height:  |  Size: 302 B

View File

Before

Width:  |  Height:  |  Size: 369 B

After

Width:  |  Height:  |  Size: 369 B

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

View File

Before

Width:  |  Height:  |  Size: 417 B

After

Width:  |  Height:  |  Size: 417 B

View File

Before

Width:  |  Height:  |  Size: 522 B

After

Width:  |  Height:  |  Size: 522 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 B

View File

@ -388,3 +388,170 @@ minetest.register_tool("default:hoe_diamond", {
return default.hoe_on_use(itemstack, user, pointed_thing, 500)
end,
})
--armor
-- Regisiter Head Armor
minetest.register_tool("default:armor_helmet_wood", {
description = "Wood Helmet",
inventory_image = "default_armor_inv_helmet_wood.png",
groups = {armor_head=5, armor_heal=0, armor_use=2000},
wear = 0,
})
minetest.register_tool("default:armor_helmet_steel", {
description = "Steel Helmet",
inventory_image = "default_armor_inv_helmet_steel.png",
groups = {armor_head=10, armor_heal=0, armor_use=500},
wear = 0,
})
minetest.register_tool("default:armor_helmet_bronze", {
description = "Bronze Helmet",
inventory_image = "default_armor_inv_helmet_bronze.png",
groups = {armor_head=10, armor_heal=6, armor_use=250},
wear = 0,
})
minetest.register_tool("default:armor_helmet_diamond", {
description = "Diamond Helmet",
inventory_image = "default_armor_inv_helmet_diamond.png",
groups = {armor_head=15, armor_heal=12, armor_use=100},
wear = 0,
})
-- Regisiter Torso Armor
minetest.register_tool("default:armor_chestplate_wood", {
description = "Wood Chestplate",
inventory_image = "default_armor_inv_chestplate_wood.png",
groups = {armor_torso=10, armor_heal=0, armor_use=2000},
wear = 0,
})
minetest.register_tool("default:armor_chestplate_steel", {
description = "Steel Chestplate",
inventory_image = "default_armor_inv_chestplate_steel.png",
groups = {armor_torso=15, armor_heal=0, armor_use=500},
wear = 0,
})
minetest.register_tool("default:armor_chestplate_bronze", {
description = "Bronze Chestplate",
inventory_image = "default_armor_inv_chestplate_bronze.png",
groups = {armor_torso=15, armor_heal=6, armor_use=250},
wear = 0,
})
minetest.register_tool("default:armor_chestplate_diamond", {
description = "Diamond Chestplate",
inventory_image = "default_armor_inv_chestplate_diamond.png",
groups = {armor_torso=20, armor_heal=12, armor_use=100},
wear = 0,
})
-- Regisiter Leg Armor
minetest.register_tool("default:armor_leggings_wood", {
description = "Wood Leggings",
inventory_image = "default_armor_inv_leggings_wood.png",
groups = {armor_legs=5, armor_heal=0, armor_use=2000},
wear = 0,
})
minetest.register_tool("default:armor_leggings_steel", {
description = "Steel Leggings",
inventory_image = "default_armor_inv_leggings_steel.png",
groups = {armor_legs=15, armor_heal=0, armor_use=500},
wear = 0,
})
minetest.register_tool("default:armor_leggings_bronze", {
description = "Bronze Leggings",
inventory_image = "default_armor_inv_leggings_bronze.png",
groups = {armor_legs=15, armor_heal=6, armor_use=250},
wear = 0,
})
minetest.register_tool("default:armor_leggings_diamond", {
description = "Diamond Leggings",
inventory_image = "default_armor_inv_leggings_diamond.png",
groups = {armor_legs=20, armor_heal=12, armor_use=100},
wear = 0,
})
-- Regisiter Boots
minetest.register_tool("default:armor_boots_wood", {
description = "Wood Boots",
inventory_image = "default_armor_inv_boots_wood.png",
groups = {armor_feet=5, armor_heal=0, armor_use=2000},
wear = 0,
})
minetest.register_tool("default:armor_boots_steel", {
description = "Steel Boots",
inventory_image = "default_armor_inv_boots_steel.png",
groups = {armor_feet=10, armor_heal=0, armor_use=500},
wear = 0,
})
minetest.register_tool("default:armor_boots_bronze", {
description = "Bronze Boots",
inventory_image = "default_armor_inv_boots_bronze.png",
groups = {armor_feet=10, armor_heal=6, armor_use=250},
wear = 0,
})
minetest.register_tool("default:armor_boots_diamond", {
description = "Diamond Boots",
inventory_image = "default_armor_inv_boots_diamond.png",
groups = {armor_feet=15, armor_heal=12, armor_use=100},
wear = 0,
})
-- Register Craft Recipies default:armor_helmet_wood
local craft_ingreds = {
wood = "default:wood",
steel = "default:steel_ingot",
bronze = "default:bronze_ingot",
diamond = "default:diamond",
}
for k, v in pairs(craft_ingreds) do
minetest.register_craft({
output = "default:armor_helmet_"..k,
recipe = {
{v, v, v},
{v, "", v},
{"", "", ""},
},
})
minetest.register_craft({
output = "default:armor_chestplate_"..k,
recipe = {
{v, "", v},
{v, v, v},
{v, v, v},
},
})
minetest.register_craft({
output = "default:armor_leggings_"..k,
recipe = {
{v, v, v},
{v, "", v},
{v, "", v},
},
})
minetest.register_craft({
output = "default:armor_boots_"..k,
recipe = {
{v, "", v},
{v, "", v},
},
})
end

View File

@ -1,63 +0,0 @@
Minetest mod "Better HUD"
=========================
version: 1.1
License of source code: WTFPL
-----------------------------
(c) Copyright BlockMen (2013)
License of textures:
--------------------
hud_heart_fg.png - celeron55 (CC BY-SA 3.0), modified by BlockMen
hud_heart_bg.png - celeron55 (CC BY-SA 3.0), modified by BlockMen
hud_hunger_fg.png - PilzAdam (WTFPL), modified by BlockMen
hud_hunger_bg.png - PilzAdam (WTFPL), modified by BlockMen
wieldhand.png (from character.png) - Jordach (CC BY-SA 3.0), modified by BlockMen
hud_air_fg.png - kaeza (WTFPL), modified by BlockMen
hud_armor_fg.png - Stu (CC BY-SA 3.0), modified by BlockMen
hud_armor_bg.png - Stu (CC BY-SA 3.0), modified by BlockMen
everything else is WTFPL:
(c) Copyright BlockMen (2013)
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.
Using the mod:
--------------
This mod changes the HUD of Minetest.
It improves the apperance of the health and breath bar and adds a more fancy hotbar. Furthermore it adds a
costum crosshair, an armor bar (only for 3darmor mod) and a hunger bar. It includes also a mechanic for hunger.
You can create a "hud.conf" to costumize the positions of health, hunger, armor and breath bar. Take a look at "hud.conf.example" to get more infos.
!!NOTICE: Keep in mind if running a server with this mod, that the costum position should be displayed correct on every screen size!!
Hunger:
This mod adds hunger to the game. You can disable this by setting "HUD_HUNGER_ENABLE = false" in "hud.conf", or "hud_hunger_enable = false" in minetest.conf. In case of conflict hud.conf configuration is dominant.
Currently supported food:
- Apples (default)
- Bread (default)
- Drawves (beer and such)
- Mooretrees
- Simple mobs
- Animalmaterials (mobf modpack)
- Fishing
- Glooptest
- Bushes
- Docfarming
- Farming plus
- Mtfoods
Example: 1 apple fills up the hunger bar by 1 bread, 1 bread (from farming) 2 breads in bar.
Altough it show 20 hunger points (10 breads) in hunger bar you can fill it up to 30 points. (5 breads not shown then)

View File

@ -1,31 +0,0 @@
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 hud.get_armor(player)
if not player or not armor.def then
return
end
local name = player:get_player_name()
hud.set_armor(player, armor.def[name].state, armor.def[name].count)
end
function hud.set_armor(player, ges_state, items)
if not player then return end
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
hud.armor[player:get_player_name()] = lvl*(items*(20/max_items))
end

View File

@ -1,47 +0,0 @@
0.2 Beta
--------
- added support of costum 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)

View File

@ -1 +0,0 @@
default

View File

@ -1,33 +0,0 @@
--##Better HUD example config file##
------------------------------------
-- This example moves the health bar in the top left corner and the hunger bar in the top right corner
--
-- general settings
--
HUD_ENABLE_HUNGER = true --enables/disables hunger
HUD_HUNGER_TICK = 300 --sets time for loosing 1/2 bread (of 10) (in seconds)
--!NOTICE!--
-- >>if damage is disabled neither health bar nor hunger bar or breath bar is shown
--
-- health bar
--
HUD_HEALTH_POS = {x=0,y=0} --min 0, max 1
HUD_HEALTH_OFFSET = {x=5,y=30} --offset in pixel
--
-- hunger bar
--
HUD_HUNGER_POS = {x=1,y=0} --min 0, max 1
HUD_HUNGER_OFFSET = {x=-175,y=30} --offset in pixel
--
-- breath bar
--
HUD_AIR_POS = {x=0.5,y=1} --min 0, max 1
HUD_AIR_OFFSET = {x=15,y=-75} --offset in pixel

View File

@ -1,167 +0,0 @@
function hud.save_hunger(player)
local file = io.open(minetest.get_worldpath().."/hud_"..player:get_player_name().."_hunger", "w+")
if file then
file:write(hud.hunger[player:get_player_name()])
file:close()
end
end
function hud.load_hunger(player)
local file = io.open(minetest.get_worldpath().."/hud_"..player:get_player_name().."_hunger", "r")
if file then
hud.hunger[player:get_player_name()] = file:read("*all")
file:close()
return hud.hunger[player:get_player_name()]
else
return
end
end
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)
end
if player:get_hp()-1 > 0 then
player:set_hp(player:get_hp()-1)
end
end
function hud.item_eat(hunger_change, replace_with_item, poisen)
return function(itemstack, user, pointed_thing)
if itemstack:take_item() ~= nil then
local h = tonumber(hud.hunger[user:get_player_name()])
h=h+hunger_change
if h>30 then h=30 end
hud.hunger[user:get_player_name()]=h
hud.save_hunger(user)
itemstack:add_item(replace_with_item) -- note: replace_with_item is optional
--sound:eat
if poisen then
poisenp(1.0, poisen, 0, user)
end
end
return itemstack
end
end
local function overwrite(name, hunger_change, replace_with_item, poisen)
local tab = minetest.registered_items[name]
if tab == nil then return end
tab.on_use = hud.item_eat(hunger_change, replace_with_item, poisen)
minetest.registered_items[name] = tab
end
minetest.after(0.5, function()--ensure all other mods get loaded
overwrite("default:apple", 2)
if minetest.get_modpath("farming") ~= nil then
overwrite("farming:bread", 4)
end
if minetest.get_modpath("mobs") ~= nil then
overwrite("mobs:meat", 6)
overwrite("mobs:meat_raw", 3)
overwrite("mobs:rat_cooked", 5)
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", 4)
overwrite("fishing:sushi", 6)
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("docfarming") ~= nil then
overwrite("docfarming:carrot", 2)
overwrite("docfarming:cucumber", 2)
overwrite("docfarming:corn", 2)
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_plus:pumpkin_bread", 4)
overwrite("farming_plus:strawberry_item", 2)
overwrite("farming_plus:tomato_item", 2)
overwrite("farming_plus:potatoe_item", 4)
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
end)

View File

@ -1,226 +0,0 @@
hud = {}
local health_hud = {}
hud.hunger = {}
local hunger_hud = {}
local air_hud = {}
hud.armor = {}
local armor_hud = {}
local armor_hud_bg = {}
local SAVE_INTERVAL = 0.5*60--currently useless
--default settings
HUD_ENABLE_HUNGER = minetest.setting_getbool("hud_hunger_enable")
HUD_SHOW_ARMOR = false
if minetest.get_modpath("3d_armor") ~= nil then HUD_SHOW_ARMOR = true end
if HUD_ENABLE_HUNGER == nil then HUD_ENABLE_HUNGER = FALSE end
HUD_HUNGER_TICK = 300
HUD_HEALTH_POS = {x=0.5,y=0.9}
HUD_HEALTH_OFFSET = {x=-175, y=2}
HUD_HUNGER_POS = {x=0.5,y=0.9}
HUD_HUNGER_OFFSET = {x=15, y=2}
HUD_AIR_POS = {x=0.5,y=0.9}
HUD_AIR_OFFSET = {x=15,y=-15}
HUD_ARMOR_POS = {x=0.5,y=0.9}
HUD_ARMOR_OFFSET = {x=-175, y=-15}
--load costum settings
local set = io.open(minetest.get_modpath("hud").."/hud.conf", "r")
if set then
dofile(minetest.get_modpath("hud").."/hud.conf")
set:close()
else
if not HUD_ENABLE_HUNGER then
HUD_AIR_OFFSET = HUD_ARMOR_OFFSET
HUD_AIR_POS = HUD_ARMOR_POS
HUD_ARMOR_OFFSET = HUD_HUNGER_OFFSET
HUD_ARMOR_POS = HUD_HUNGER_POS
end
end
--minetest.after(SAVE_INTERVAL, timer, SAVE_INTERVAL)
local function hide_builtin(player)
player:hud_set_flags({crosshair = true, hotbar = true, healthbar = false, wielditem = true, breathbar = false})
end
local function costum_hud(player)
--fancy hotbar
player:hud_set_hotbar_image("hud_hotbar.png")
player:hud_set_hotbar_selected_image("hud_hotbar_selected.png")
if minetest.setting_getbool("enable_damage") then
--hunger
if HUD_ENABLE_HUNGER then
player:hud_add({
hud_elem_type = "statbar",
position = HUD_HUNGER_POS,
scale = {x=1, y=1},
text = "hud_hunger_bg.png",
number = 20,
alignment = {x=-1,y=-1},
offset = HUD_HUNGER_OFFSET,
})
hunger_hud[player:get_player_name()] = player:hud_add({
hud_elem_type = "statbar",
position = HUD_HUNGER_POS,
scale = {x=1, y=1},
text = "hud_hunger_fg.png",
number = 20,
alignment = {x=-1,y=-1},
offset = HUD_HUNGER_OFFSET,
})
end
--health
player:hud_add({
hud_elem_type = "statbar",
position = HUD_HEALTH_POS,
scale = {x=1, y=1},
text = "hud_heart_bg.png",
number = 20,
alignment = {x=-1,y=-1},
offset = HUD_HEALTH_OFFSET,
})
health_hud[player:get_player_name()] = player:hud_add({
hud_elem_type = "statbar",
position = HUD_HEALTH_POS,
scale = {x=1, y=1},
text = "hud_heart_fg.png",
number = player:get_hp(),
alignment = {x=-1,y=-1},
offset = HUD_HEALTH_OFFSET,
})
--air
air_hud[player:get_player_name()] = player:hud_add({
hud_elem_type = "statbar",
position = HUD_AIR_POS,
scale = {x=1, y=1},
text = "hud_air_fg.png",
number = 0,
alignment = {x=-1,y=-1},
offset = HUD_AIR_OFFSET,
})
--armor
if HUD_SHOW_ARMOR then
armor_hud_bg[player:get_player_name()] = player:hud_add({
hud_elem_type = "statbar",
position = HUD_ARMOR_POS,
scale = {x=1, y=1},
text = "hud_armor_bg.png",
number = 0,
alignment = {x=-1,y=-1},
offset = HUD_ARMOR_OFFSET,
})
armor_hud[player:get_player_name()] = player:hud_add({
hud_elem_type = "statbar",
position = HUD_ARMOR_POS,
scale = {x=1, y=1},
text = "hud_armor_fg.png",
number = 0,
alignment = {x=-1,y=-1},
offset = HUD_ARMOR_OFFSET,
})
end
end
end
--needs to be set always(for 3darmor)
function hud.set_armor()
end
if HUD_ENABLE_HUNGER then dofile(minetest.get_modpath("hud").."/hunger.lua") end
if HUD_SHOW_ARMOR then dofile(minetest.get_modpath("hud").."/armor.lua") end
local function update_hud(player)
local name = player:get_player_name()
--air
local air = player:get_breath()*2
if player:get_breath() > 10 then air = 0 end
player:hud_change(air_hud[name], "number", air)
--health
player:hud_change(health_hud[name], "number", player:get_hp())
--armor
local arm = tonumber(hud.armor[name])
if not arm then arm = 0 end
player:hud_change(armor_hud[name], "number", arm)
if (not armor.def[name].count or armor.def[name].count == 0) and hud.armor[name] == 0 then
player:hud_change(armor_hud_bg[name], "number", 0)
else
player:hud_change(armor_hud_bg[name], "number", 20)
end
--hunger
local h = tonumber(hud.hunger[name])
if h>20 then h=20 end
player:hud_change(hunger_hud[name], "number", h)
end
local function timer(interval, player)
if interval > 0 then
hud.save_hunger(player)
minetest.after(interval, timer, interval, player)
end
end
minetest.register_on_joinplayer(function(player)
hud.armor[player:get_player_name()] = 0
if HUD_ENABLE_HUNGER then hud.hunger[player:get_player_name()] = hud.load_hunger(player) end
if not hud.hunger[player:get_player_name()] then
hud.hunger[player:get_player_name()] = 20
end
minetest.after(0.5, function()
hide_builtin(player)
costum_hud(player)
if HUD_ENABLE_HUNGER then hud.save_hunger(player) end
end)
end)
minetest.register_on_respawnplayer(function(player)
hud.hunger[player:get_player_name()] = 20
minetest.after(0.5, function()
if HUD_ENABLE_HUNGER then hud.save_hunger(player) end
end)
end)
local timer = 0
local timer2 = 0
minetest.after(2.5, function()
minetest.register_globalstep(function(dtime)
timer = timer + dtime
timer2 = timer2 + dtime
for _,player in ipairs(minetest.get_connected_players()) do
if minetest.setting_getbool("enable_damage") then
local h = tonumber(hud.hunger[player:get_player_name()])
if HUD_ENABLE_HUNGER and timer > 4 then
if h>=16 and player:get_hp() > 0 then
player:set_hp(player:get_hp()+1)
elseif h<=1 and minetest.setting_getbool("enable_damage") then
if player:get_hp()-1 >= 1 then player:set_hp(player:get_hp()-1) end
end
end
if HUD_ENABLE_HUNGER and timer2>HUD_HUNGER_TICK then
if h>1 then
h=h-1
hud.hunger[player:get_player_name()]=h
hud.save_hunger(player)
end
end
if HUD_SHOW_ARMOR then hud.get_armor(player) end
update_hud(player)
end
end
if timer>4 then timer=0 end
if timer2>HUD_HUNGER_TICK then timer2=0 end
end)
end)

View File

@ -1,16 +0,0 @@
[mod] Visible Player Armor [3d_armor]
=====================================
depends: default, inventory_plus
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.
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.
default settings: [minetest.conf]
# Set number of seconds between armor updates.
3d_armor_update_time = 1

View File

@ -1,248 +0,0 @@
local time = 0
local update_time = tonumber(minetest.setting_get("3d_armor_update_time"))
if not update_time then
update_time = 1
minetest.setting_set("3d_armor_update_time", tostring(update_time))
end
armor = {
player_hp = {},
elements = {"head", "torso", "legs", "feet"},
formspec = "size[8,8.5]button[0,0;2,0.5;main;Back]"
.."list[current_player;main;0,4.5;8,4;]"
.."list[detached:player_name_armor;armor_head;3,0;1,1;]"
.."list[detached:player_name_armor;armor_torso;3,1;1,1;]"
.."list[detached:player_name_armor;armor_legs;3,2;1,1;]"
.."list[detached:player_name_armor;armor_feet;3,3;1,1;]",
textures = {},
default_skin = "character.png",
}
-- armor.def - Added by BlockMen for HUD integration
armor.def = {
state = 0,
count = 0,
}
armor.update_player_visuals = function(self, player)
if not player then
return
end
local name = player:get_player_name()
if self.textures[name] then
default.player_set_textures(player, {
self.textures[name].skin,
self.textures[name].armor,
self.textures[name].wielditem,
})
end
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()
local armor_texture = "3d_armor_trans.png"
local armor_level = 0
local state = 0
local items = 0
local textures = {}
local elements = {}
for i, v in ipairs(self.elements) do
local stack = player_inv:get_stack("armor_"..v, 1)
local level = stack:get_definition().groups["armor_"..v]
local item = stack:get_name()
elements[i] = string.match(item, "%:.+_(.+)$")
if level then
table.insert(textures, item:gsub("%:", "_")..".png")
armor_level = armor_level + level
state = state + stack:get_wear()
items = items + 1
end
end
if minetest.get_modpath("shields") then
armor_level = armor_level * 0.9
end
if elements[1] == elements[2] and
elements[1] == elements[3] and
elements[1] == elements[4] then
armor_level = armor_level * 1.1
end
if #textures > 0 then
armor_texture = table.concat(textures, "^")
end
local armor_groups = {fleshy=100}
if armor_level > 0 then
armor_groups.level = math.floor(armor_level / 20)
armor_groups.fleshy = 100 - armor_level
end
player:set_armor_groups(armor_groups)
self.textures[name].armor = armor_texture
self.def[name].state = state
self.def[name].count = items
self:update_player_visuals(player)
end
armor.update_armor = function(self, player)
if not player 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
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 _,v in ipairs(self.elements) do
local stack = armor_inv:get_stack("armor_"..v, 1)
if stack:get_count() > 0 then
local use = stack:get_definition().groups["armor_use"] or 0
local heal = stack:get_definition().groups["armor_heal"] or 0
local item = stack:get_name()
stack:add_wear(use)
armor_inv:set_stack("armor_"..v, 1, stack)
player_inv:set_stack("armor_"..v, 1, stack)
state = state + stack:get_wear()
items = items + 1
if stack:get_count() == 0 then
local desc = minetest.registered_items[item].description
if desc then
minetest.chat_send_player(name, "Your "..desc.." got destroyed!")
end
self:set_player_armor(player)
end
heal_max = heal_max + heal
end
end
self.def[name].state = state
self.def[name].count = items
if heal_max > math.random(100) then
player:set_hp(self.player_hp[name])
return
end
end
self.player_hp[name] = hp
end
-- Register Player Model
default.player_register_model("character.x", {
animation_speed = 30,
textures = {
armor.default_skin,
"3d_armor_trans.png",
"3d_armor_trans.png",
},
animations = {
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 fields.armor then
local formspec = armor.formspec:gsub("player_name", name)
--inventory_plus.set_inventory_formspec(player, formspec)
return
end
for field, _ in pairs(fields) do
if string.find(field, "^skins_set_") then
minetest.after(0, function(player)
armor.textures[name].skin = skins.skins[name]..".png"
armor:update_player_visuals(player)
end, player)
end
end
end)
minetest.register_on_joinplayer(function(player)
default.player_set_model(player, "character.x")
--inventory_plus.register_button(player,"armor", "Armor")
local player_inv = player:get_inventory()
local name = player:get_player_name()
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)
end,
on_take = function(inv, listname, index, stack, player)
player:get_inventory():set_stack(listname, index, nil)
armor:set_player_armor(player)
end,
allow_put = function(inv, listname, index, stack, player)
local field = minetest.registered_items[stack:get_name()]
if (field and field.groups[listname] and field.groups[listname] ~= 0) and inv:is_empty(listname) then
return 1
end
return 0
end,
allow_take = function(inv, listname, index, stack, player)
return stack:get_count()
end,
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
return 0
end,
})
for _,v in ipairs(armor.elements) do
local list = "armor_"..v
player_inv:set_size(list, 1)
armor_inv:set_size(list, 1)
armor_inv:set_stack(list, 1, player_inv:get_stack(list, 1))
end
armor.player_hp[name] = 0
armor.def[name] = {
state = 0,
count = 0,
}
armor.textures[name] = {
skin = armor.default_skin,
armor = "3d_armor_trans.png",
wielditem = "3d_armor_trans.png",
}
if minetest.get_modpath("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
end
if minetest.get_modpath("player_textures") then
local filename = minetest.get_modpath("player_textures").."/textures/player_"..name
local f = io.open(filename..".png")
if f then
f:close()
armor.textures[name].skin = "player_"..name..".png"
end
end
minetest.after(0, function(player)
armor:set_player_armor(player)
end, player)
end)
minetest.register_globalstep(function(dtime)
time = time + dtime
if time > update_time then
for _,player in ipairs(minetest.get_connected_players()) do
armor:update_armor(player)
end
time = 0
end
end)

View File

@ -1,67 +0,0 @@
3d_armor -- Crafting Guide
--------------------------
Helmets:
+---+---+---+
| X | X | X |
+---+---+---+
| X | | X |
+---+---+---+
| | | |
+---+---+---+
[3d_armor:helmet_wood] X = [default:wood]
[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_mithril] X = [moreores:mithril_ingot] *
Chestplates:
+---+---+---+
| X | | X |
+---+---+---+
| X | X | X |
+---+---+---+
| X | X | X |
+---+---+---+
[3d_armor:chestplate_wood] X = [default:wood]
[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_mithril] X = [moreores:mithril_ingot] *
Leggings:
+---+---+---+
| X | X | X |
+---+---+---+
| X | | X |
+---+---+---+
| X | | X |
+---+---+---+
[3d_armor:leggings_wood] X = [default:wood]
[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_mithril] X = [moreores:mithril_ingot] *
Boots:
+---+---+---+
| X | | X |
+---+---+---+
| X | | X |
+---+---+---+
[3d_armor:boots_wood] X = [default:wood]
[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_mithril] X = [moreores:mithril_ingot] *
* Requires moreores mod by Calinou - https://forum.minetest.net/viewtopic.php?id=549

View File

@ -1 +0,0 @@
default

View File

@ -1,206 +0,0 @@
dofile(minetest.get_modpath(minetest.get_current_modname()).."/armor.lua")
local use_moreores = minetest.get_modpath("moreores")
-- Regisiter Head Armor
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: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: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: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,
})
if use_moreores 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},
wear = 0,
})
end
-- Regisiter Torso Armor
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: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,
})
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},
wear = 0,
})
end
-- Regisiter Leg Armor
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: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,
})
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},
wear = 0,
})
end
-- Regisiter Boots
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,
})
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,
})
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},
wear = 0,
})
end
-- Register Craft Recipies
local craft_ingreds = {
wood = "default:wood",
steel = "default:steel_ingot",
bronze = "default:bronze_ingot",
diamond = "default:diamond",
}
if use_moreores then
craft_ingreds.mithril = "moreores:mithril_ingot"
end
for k, v in pairs(craft_ingreds) do
minetest.register_craft({
output = "3d_armor:helmet_"..k,
recipe = {
{v, v, v},
{v, "", v},
{"", "", ""},
},
})
minetest.register_craft({
output = "3d_armor:chestplate_"..k,
recipe = {
{v, "", v},
{v, v, v},
{v, v, v},
},
})
minetest.register_craft({
output = "3d_armor:leggings_"..k,
recipe = {
{v, v, v},
{v, "", v},
{v, "", v},
},
})
minetest.register_craft({
output = "3d_armor:boots_"..k,
recipe = {
{v, "", v},
{v, "", v},
},
})
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 472 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 203 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 237 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 760 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 723 B

View File

@ -1,11 +0,0 @@
3D Armor - Visible Player Armor
===============================
Default Item Textures (C) Cisoun - WTFPL
Armor Textures: Copyright (C) 2013 Ryan Jones - CC-BY-SA
Source Code: Copyright (C) 2013 Stuart Jones - LGPL
Special credit to Jordach and MirceaKitsune for providing the default 3d character model.

View File

@ -1,32 +0,0 @@
Modpack - 3d Armor [0.4.0]
==========================
[mod] Visible Player Armor [3d_armor]
-------------------------------------
depends: default, inventory_plus
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.
Armor takes damage when a player is hurt, however, many armor items offer a 'stackable'
percentage chance of restoring the lost health points. Overall armor level is boosted by 10%
when wearing a full matching set (helmet, chestplate, leggings and boots of the same material)
Compatible with player skins [skins] by Zeg9 and Player Textures [player_textures] by PilzAdam.
[mod] Visible Wielded Items [wieldview]
---------------------------------------
depends: 3d_armor
Makes hand wielded items visible to other players.
[mod] Shields [shields]
-------------------------------------
depends: 3d_armor
Originally a part of 3d_armor, shields have been re-included as an optional extra.
If you do not want shields then simply remove the shields folder from the modpack.

View File

@ -1,15 +0,0 @@
[mod] visible wielded items [wieldview]
=======================================
depends: default, 3d_armor
Makes hand wielded items visible to other players.
default settings: [minetest.conf]
# Set number of seconds between visible wielded item updates.
wieldview_update_time = 2
# Show nodes as tiles, disabled by default
wieldview_node_tiles = false

View File

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

View File

@ -1,75 +0,0 @@
local time = 0
local update_time = tonumber(minetest.setting_get("wieldview_update_time"))
if not update_time then
update_time = 2
minetest.setting_set("wieldview_update_time", tostring(update_time))
end
local node_tiles = minetest.setting_getbool("wieldview_node_tiles")
if not node_tiles then
node_tiles = false
minetest.setting_set("wieldview_node_tiles", "false")
end
wieldview = {
wielded_item = {},
transform = {},
}
dofile(minetest.get_modpath(minetest.get_current_modname()).."/transform.lua")
wieldview.get_item_texture = function(self, item)
local texture = "3d_armor_trans.png"
if item ~= "" then
if minetest.registered_items[item] then
if minetest.registered_items[item].inventory_image then
texture = minetest.registered_items[item].inventory_image
elseif node_tiles == true and minetest.registered_items[item].tiles then
texture = minetest.registered_items[item].tiles[1]
--texture = minetest.inventorycube(minetest.registered_items[item].tiles[1])
end
end
if wieldview.transform[item] then
texture = texture.."^[transform"..wieldview.transform[item]
end
end
return texture
end
wieldview.update_wielded_item = function(self, player)
if not player then
return
end
local name = player:get_player_name()
local stack = player:get_wielded_item()
local item = stack:get_name()
if not item then
return
end
if self.wielded_item[name] then
if self.wielded_item[name] == item then
return
end
armor.textures[name].wielditem = self:get_item_texture(item)
armor:update_player_visuals(player)
end
self.wielded_item[name] = item
end
minetest.register_on_joinplayer(function(player)
local name = player:get_player_name()
wieldview.wielded_item[name] = ""
minetest.after(0, function(player)
wieldview:update_wielded_item(player)
end, player)
end)
minetest.register_globalstep(function(dtime)
time = time + dtime
if time > update_time then
for _,player in ipairs(minetest.get_connected_players()) do
wieldview:update_wielded_item(player)
end
time = 0
end
end)

View File

@ -1,24 +0,0 @@
-- Wielded Item Transformations - http://dev.minetest.net/texture
wieldview.transform = {
["default:torch"]="R270",
["default:sapling"]="R270",
["flowers:dandelion_white"]="R270",
["flowers:dandelion_yellow"]="R270",
["flowers:geranium"]="R270",
["flowers:rose"]="R270",
["flowers:tulip"]="R270",
["flowers:viola"]="R270",
["bucket:bucket_empty"]="R270",
["bucket:bucket_water"]="R270",
["bucket:bucket_lava"]="R270",
["screwdriver:screwdriver"]="R270",
["screwdriver:screwdriver1"]="R270",
["screwdriver:screwdriver2"]="R270",
["screwdriver:screwdriver3"]="R270",
["screwdriver:screwdriver4"]="R270",
["vessels:glass_bottle"]="R270",
["vessels:drinking_glass"]="R270",
["vessels:steel_bottle"]="R270",
}