Open Ezhh opened 6 years ago
minetest.register_node (name..":bush", {
description = "Spike bush",
tiles = {"spiky_bush.png"},
drawtype = "plantlike",
groups = {cracky=1},
walkable =false,
on_timer = function(pos)
local objs = minetest.get_objects_inside_radius(pos, 0.8)
for _, player in pairs(objs) do
local hp = player:get_hp ()
if player:is_player() then
if hp > 0 then
player:set_hp(hp-1)
end
break
end
end
return true
end,
on_construct = function(pos)
local timer = minetest.get_node_timer(pos)
timer:start(0.6)
end,
})
Code for spiky bush hurts faster than normal inside block damage Can be adjusted using the timer:start value NOTE: may be a bit messy
No need for node timers. It's much better to directly add damage. :)
Have you given it a try yet? I'm quite satisfied with how it came out
It's just that it's inefficient to run nodetimers without any purpose. You only need:
damage_per_second = 1
(as an example. I might make the damage 2 or 3 instead)
OK but the point was that it hurts faster So you can't just walk straight through without gaining damage...
Code I've added to the main game version:
minetest.register_node ("plants:dark_thorns", {
description = "Dark Thorns",
drawtype = "plantlike",
tiles = {"plants_dark_thorns.png"},
inventory_image = "plants_dark_thorns.png",
paramtype = "light",
paramtype2 = "meshoptions",
place_param2 = 8,
sunlight_propagstes = true,
buildable_to = true,
walkable = false,
groups = {snappy = 3, attached_node = 1, flora = 1},
selection_box = {
type = "fixed",
fixed = {-6/16, -0.5, -6/16, 6/16, -3/16, 6/16},
},
damage_per_second = 2,
})
You can't walk through without taking damage. This is the whole point of damage_per_second
.
(I may make further adjustments to groups, especially once we finish tools.)
No what I was saying is that sometimes ppl can get through the block faster than 1 second
Like I've managed to fall into lava and get out again without getting damaged
It's immediate. It doesn't fire after one second.
There should be painful things to stumble into in the dark.