mirror of
https://github.com/minetest-mods/technic.git
synced 2024-11-10 20:40:27 +01:00
@t4im overwrite a function instead of adding functions to a table
on_damaging -> on_damage fix lead radiation resistance, fixes #226
This commit is contained in:
parent
a5b5ef9818
commit
1901aa8ae2
|
@ -584,11 +584,26 @@ local cache_scaled_shielding = {}
|
||||||
local damage_enabled = minetest.setting_getbool("enable_damage")
|
local damage_enabled = minetest.setting_getbool("enable_damage")
|
||||||
|
|
||||||
if damage_enabled then
|
if damage_enabled then
|
||||||
local registered_on_radiation_damaging = {}
|
local function change_radiation_damage(dmg, ...)
|
||||||
function technic.register_on_radiation_damaging(func)
|
return dmg
|
||||||
registered_on_radiation_damaging[#registered_on_radiation_damaging+1] = func
|
|
||||||
end
|
end
|
||||||
--[[technic.register_on_radiation_damaging(function(dmg, player, pos, node, strength)
|
function technic.register_on_radiation_damage(func)
|
||||||
|
local old_changing = change_radiation_damage
|
||||||
|
function change_radiation_damage(dmg, ...)
|
||||||
|
dmg = old_changing(dmg, ...)
|
||||||
|
if not dmg then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local newdmg = func(dmg, ...)
|
||||||
|
if newdmg == false then
|
||||||
|
dmg = false
|
||||||
|
elseif newdmg then
|
||||||
|
dmg = newdmg > 0 and newdmg
|
||||||
|
end
|
||||||
|
return dmg
|
||||||
|
end
|
||||||
|
end
|
||||||
|
--[[technic.register_on_radiation_damage(function(dmg, player, pos, node, strength)
|
||||||
return -- do nothing
|
return -- do nothing
|
||||||
return dmg*2 -- change damage
|
return dmg*2 -- change damage
|
||||||
return false -- do not damage player
|
return false -- do not damage player
|
||||||
|
@ -628,20 +643,8 @@ if damage_enabled then
|
||||||
dmg_int = dmg_int + 1
|
dmg_int = dmg_int + 1
|
||||||
end
|
end
|
||||||
if dmg_int > 0 then
|
if dmg_int > 0 then
|
||||||
for _,func in ipairs(registered_on_radiation_damaging) do
|
dmg_int = change_radiation_damage(dmg_int, o, pos, node, strength)
|
||||||
local newdmg = func(dmg_int, o, pos, node, strength)
|
if dmg_int then
|
||||||
if newdmg == false then
|
|
||||||
dmg_int = 0
|
|
||||||
break
|
|
||||||
elseif newdmg then
|
|
||||||
if newdmg <= 0 then
|
|
||||||
dmg_int = 0
|
|
||||||
break
|
|
||||||
end
|
|
||||||
dmg_int = newdmg
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if dmg_int ~= 0 then
|
|
||||||
o:set_hp(math.max(o:get_hp() - dmg_int, 0))
|
o:set_hp(math.max(o:get_hp() - dmg_int, 0))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -100,7 +100,7 @@ minetest.register_node(":technic:lead_block", {
|
||||||
is_ground_content = true,
|
is_ground_content = true,
|
||||||
groups = {cracky=1, level=2},
|
groups = {cracky=1, level=2},
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
radiation_resistance = 500
|
radiation_resistance = 80
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_alias("technic:wrought_iron_block", "default:steelblock")
|
minetest.register_alias("technic:wrought_iron_block", "default:steelblock")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user