~fgaz/minetest-extruder

c4d52f90792ea0c6d1748b8ef1af44a85f7303f1 — Francesco Gazzetta 2 years ago 986b658
on_use: move node check to top conditions
1 files changed, 6 insertions(+), 8 deletions(-)

M init.lua
M init.lua => init.lua +6 -8
@@ 86,15 86,13 @@ minetest.register_tool(modname .. ":extruder", {
  liquids_pointable = true,
  -- MAYBE switch to on_place since a node should be pointed?
  on_use = function(_, placer, pointed_thing)
    if placer == nil or pointed_thing == nil then return end
    if placer == nil or pointed_thing == nil or pointed_thing.type ~= "node" then return end
    if not check_privs_with_msg(placer) then return end
    if pointed_thing.type == "node" then
      local direction = vector.direction(pointed_thing.under, pointed_thing.above)
      local surface = visit(pointed_thing.under, direction)
      -- TODO ask for confirmation if surface is too big (block limit field/checkbox in formspec?)
      -- confirmation can be "click again" (store previous above and under)
      extrude(surface, direction)
    end
    local direction = vector.direction(pointed_thing.under, pointed_thing.above)
    local surface = visit(pointed_thing.under, direction)
    -- TODO ask for confirmation if surface is too big (block limit field/checkbox in formspec?)
    -- confirmation can be "click again" (store previous above and under)
    extrude(surface, direction)
  end,

  -- TODO add formspec with "amount" field and "go/select through vertices" checkbox