nodecore-cd2025/mods/nc_api/item_touch_hurt.lua
Aaron Suen f37a918f0f Scaling and touch-hurt reforms
- Storeboxes are now scalable.
- Standardize touch-hurt operation.
- Touch-hurt damage on scaling.
- Now possible to alter scaling time via scaling_time
  group (percent of original scaling time)
2020-03-29 07:55:54 -04:00

29 lines
816 B
Lua

-- LUALOCALS < ---------------------------------------------------------
local minetest, nodecore
= minetest, nodecore
-- LUALOCALS > ---------------------------------------------------------
nodecore.register_on_register_item(function(_, def)
if not def.damage_per_second then return end
def.on_punch = def.on_punch or function(pos, node, puncher, ...)
if puncher and puncher:is_player() then
nodecore.addphealth(puncher, -1, {
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, -1, {
nc_type = "node_touch_hurt",
node = node
})
end
return true
end
end)