mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-28 13:53:45 +01:00
Add setting for damage_enabled
This commit is contained in:
parent
d8af2d4ced
commit
75565e7118
@ -34,7 +34,9 @@ mcl_damage = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
local damage_enabled = minetest.settings:get_bool("enabled_damage",true)
|
local damage_enabled = vl_tuning.setting("damage_enabled", "bool",{
|
||||||
|
default = minetest.settings:get_bool("enabled_damage",true)
|
||||||
|
})
|
||||||
|
|
||||||
function mcl_damage.register_modifier(func, priority)
|
function mcl_damage.register_modifier(func, priority)
|
||||||
table.insert(mcl_damage.modifiers, {func = func, priority = priority or 0})
|
table.insert(mcl_damage.modifiers, {func = func, priority = priority or 0})
|
||||||
@ -142,7 +144,7 @@ function mcl_damage.register_type(name, def)
|
|||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_player_hpchange(function(player, hp_change, mt_reason)
|
minetest.register_on_player_hpchange(function(player, hp_change, mt_reason)
|
||||||
if not damage_enabled then return 0 end
|
if not damage_enabled[1] then return 0 end
|
||||||
if hp_change < 0 then
|
if hp_change < 0 then
|
||||||
if player:get_hp() <= 0 then
|
if player:get_hp() <= 0 then
|
||||||
return 0
|
return 0
|
||||||
@ -153,7 +155,7 @@ minetest.register_on_player_hpchange(function(player, hp_change, mt_reason)
|
|||||||
end, true)
|
end, true)
|
||||||
|
|
||||||
minetest.register_on_player_hpchange(function(player, hp_change, mt_reason)
|
minetest.register_on_player_hpchange(function(player, hp_change, mt_reason)
|
||||||
if not damage_enabled then return 0 end
|
if not damage_enabled[1] then return 0 end
|
||||||
if player:get_hp() > 0 then
|
if player:get_hp() > 0 then
|
||||||
if hp_change < 0 then
|
if hp_change < 0 then
|
||||||
mcl_damage.run_damage_callbacks(player, -hp_change, mcl_damage.from_mt(mt_reason))
|
mcl_damage.run_damage_callbacks(player, -hp_change, mcl_damage.from_mt(mt_reason))
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
name = mcl_damage
|
name = mcl_damage
|
||||||
author = Fleckenstein
|
author = Fleckenstein
|
||||||
description = Minecraft-like damage reason system
|
description = Minecraft-like damage reason system
|
||||||
|
depends = vl_tuning
|
||||||
|
Loading…
Reference in New Issue
Block a user