Here is an extract from my PlayerPlus mod that has been changed to deal damage when standing close to uranium ore...
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
local time = 0
minetest.register_globalstep(function(dtime)
time = time + dtime
-- every 1 second
if time > 1 then
-- reset time for next check
time = 0
-- check players
for _,player in ipairs(minetest.get_connected_players()) do
-- where am I?
local pos = player:getpos()
-- am I near a block of uranium?
local near = minetest.find_node_near(pos, 1, "uranium:stone_with_uranium")
if near then
-- am I touching the uranium? if so it hurts
for _,object in ipairs(minetest.get_objects_inside_radius(near, 1.0)) do
if object:get_hp() > 0 then
object:set_hp(object:get_hp()-1)
end
end
end
end
end
end)