Help with my mod
I'm making a mod that adds a node that can be pushed around, moving one block whenever it's punched. It seems to work, but a lot of the time the node moves two blocks over rather than one. I can't figure out why, can someone more experienced look at it? The block only moves if hit from one angle, I haven't done the others yet.
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("pushblocks:pushstone", {
description = "Test Pushstone",
tiles = {"default_cobble.png"},
is_ground_content = true,
groups = {cracky=3},
})
minetest.register_on_punchnode(function(pos, node, puncher)
if node.name == "pushblocks:pushstone" then
if minetest.dir_to_facedir(puncher:get_look_dir()) == 0 then
pos.z = pos.z + 1
if minetest.env:get_node(pos).name == "air" then
minetest.env:add_node(pos,{name = "pushblocks:pushstone"})
pos.z = pos.z - 1
minetest.env:remove_node(pos)
end
end
end
end)