nodecore-cd2025/mods/nc_api/item_touch_hurt.lua
Aaron Suen 920fba34ee Separate node stand/touch/radiant damage types
Don't reuse damage_per_second for damage on punch and radiant
damage.  This allows these to be defined separately, i.e. no longer
assuming that all damage is from "heat" and can radiate.  This
allows for things like thorny plants that hurt if you touch them
or stand in them but not if you stand near them.

Thanks to WintersKnight94 for reporting this.
2020-04-09 06:56:18 -04:00

30 lines
869 B
Lua

-- LUALOCALS < ---------------------------------------------------------
local minetest, nodecore
= minetest, nodecore
-- LUALOCALS > ---------------------------------------------------------
nodecore.register_on_register_item(function(_, def)
local dmg = def.groups and def.groups.damage_touch
if not (dmg and dmg > 0) then return end
def.on_punch = def.on_punch or function(pos, node, puncher, ...)
if puncher and puncher:is_player() then
nodecore.addphealth(puncher, -dmg, {
nc_type = "node_touch_hurt",
node = node
})
end
return minetest.node_punch(pos, node, puncher, ...)
end
def.on_scaling = def.on_scaling or function(_, _, player, node)
if player and player:is_player() then
nodecore.addphealth(player, -dmg, {
nc_type = "node_touch_hurt",
node = node
})
end
return true
end
end)