This is an object that is placed on the ground and has an area of influence that gives an effect (I have this working). While it is providing the effect, I would like to remove the node from play.
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
minetest.register_node("somenode", {
description = "somenode",
tile_images = {"somenode.png"},
inventory_image = "somenode.png",
paramtype2 = "facedir",
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
})
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
minetest.register_abm(
{nodenames = {"somenode"},
interval = 1.0,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local objs = minetest.env:get_objects_inside_radius(pos, 5)
for k, obj in pairs(objs) do
obj:set_somefunctionthat is providing an effect on the player
-->obj:add_wear(1)
end
end,
})
The above add_wear crashes the server and gives the below. I may not be calling it correctly either.
init.lua:32: attempt to call method 'add_wear' (a nil value)
My questions are:
- Can I add_wear on a node from a function?
- Does the node have to be a tool for add_wear to work? <- I believe yes from documentation
- Is there a better way (within the above function) to do this?