mirror of
https://github.com/minetest-mods/3d_armor.git
synced 2024-11-22 20:43:43 +01:00
Make water protection optional, default true
This can save a `global_step` regisration if neither fire or water protection are enabled.
This commit is contained in:
parent
23e4d5114f
commit
1fdff7adaa
@ -63,6 +63,9 @@ armor_heal_multiplier = 1
|
|||||||
-- eg: armor_radiation_multiplier = 0 will completely disable radiation protection.
|
-- eg: armor_radiation_multiplier = 0 will completely disable radiation protection.
|
||||||
armor_radiation_multiplier = 1
|
armor_radiation_multiplier = 1
|
||||||
|
|
||||||
|
-- Enable water protection (periodically restores breath when activated)
|
||||||
|
armor_water_protect = true
|
||||||
|
|
||||||
-- Enable fire protection (defaults true if using ethereal mod)
|
-- Enable fire protection (defaults true if using ethereal mod)
|
||||||
armor_fire_protect = false
|
armor_fire_protect = false
|
||||||
|
|
||||||
@ -97,6 +100,7 @@ See armor.lua, technic_armor and shields mods for more examples.
|
|||||||
Default groups:
|
Default groups:
|
||||||
|
|
||||||
Elements: armor_head, armor_torso, armor_legs, armor_feet
|
Elements: armor_head, armor_torso, armor_legs, armor_feet
|
||||||
|
attributes: armor_heal, armor_fire, armor_water
|
||||||
Physics: physics_jump, physics_speed, physics_gravity
|
Physics: physics_jump, physics_speed, physics_gravity
|
||||||
Durability: armor_use
|
Durability: armor_use
|
||||||
|
|
||||||
|
@ -66,6 +66,7 @@ armor.config = {
|
|||||||
material_gold = true,
|
material_gold = true,
|
||||||
material_mithril = true,
|
material_mithril = true,
|
||||||
material_crystal = true,
|
material_crystal = true,
|
||||||
|
water_protect = true,
|
||||||
fire_protect = minetest.get_modpath("ethereal") ~= nil
|
fire_protect = minetest.get_modpath("ethereal") ~= nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,40 +323,44 @@ else
|
|||||||
print ("[3d_armor] Fire Nodes disabled")
|
print ("[3d_armor] Fire Nodes disabled")
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
if armor.config.water_protect == true or armor.config.fire_protect == true then
|
||||||
armor.timer = armor.timer + dtime
|
minetest.register_globalstep(function(dtime)
|
||||||
if armor.timer < armor.config.update_time then
|
armor.timer = armor.timer + dtime
|
||||||
return
|
if armor.timer < armor.config.update_time then
|
||||||
end
|
return
|
||||||
for _,player in pairs(minetest.get_connected_players()) do
|
|
||||||
local name = player:get_player_name()
|
|
||||||
local pos = player:getpos()
|
|
||||||
local hp = player:get_hp()
|
|
||||||
-- water breathing
|
|
||||||
if name and armor.def[name].water > 0 then
|
|
||||||
if player:get_breath() < 10 then
|
|
||||||
player:set_breath(10)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
-- fire protection
|
for _,player in pairs(minetest.get_connected_players()) do
|
||||||
if armor.config.fire_protect == true
|
local name = player:get_player_name()
|
||||||
and name and pos and hp then
|
local pos = player:getpos()
|
||||||
pos.y = pos.y + 1.4 -- head level
|
local hp = player:get_hp()
|
||||||
local node_head = minetest.get_node(pos).name
|
if not name or not pos or not hp then
|
||||||
pos.y = pos.y - 1.2 -- feet level
|
return
|
||||||
local node_feet = minetest.get_node(pos).name
|
end
|
||||||
-- is player inside a hot node?
|
-- water breathing
|
||||||
for _, row in pairs(armor.fire_nodes) do
|
if armor.config.water_protect == true then
|
||||||
-- check fire protection, if not enough then get hurt
|
if armor.def[name].water > 0 and player:get_breath() < 10 then
|
||||||
if row[1] == node_head or row[1] == node_feet then
|
player:set_breath(10)
|
||||||
if hp > 0 and armor.def[name].fire < row[2] then
|
end
|
||||||
hp = hp - row[3] * armor.config.update_time
|
end
|
||||||
player:set_hp(hp)
|
-- fire protection
|
||||||
break
|
if armor.config.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 pairs(armor.fire_nodes) do
|
||||||
|
-- check 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.config.update_time
|
||||||
|
player:set_hp(hp)
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
armor.timer = 0
|
||||||
armor.timer = 0
|
end)
|
||||||
end)
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user