From eba6f42678dbdb4837a30908b0627bee6f35440a Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Thu, 2 Feb 2017 21:36:23 -0500 Subject: update moreblocks, technic, roads, worldedit --- worldedit_commands/init.lua | 24 +++++++++++++++++++++--- worldedit_commands/safe.lua | 15 ++++++--------- 2 files changed, 27 insertions(+), 12 deletions(-) (limited to 'worldedit_commands') diff --git a/worldedit_commands/init.lua b/worldedit_commands/init.lua index d47c6e2..12c296c 100644 --- a/worldedit_commands/init.lua +++ b/worldedit_commands/init.lua @@ -13,7 +13,7 @@ end dofile(minetest.get_modpath("worldedit_commands") .. "/cuboid.lua") dofile(minetest.get_modpath("worldedit_commands") .. "/mark.lua") dofile(minetest.get_modpath("worldedit_commands") .. "/wand.lua") -local safe_region, check_region = dofile(minetest.get_modpath("worldedit_commands") .. "/safe.lua") +local safe_region, check_region, reset_pending = dofile(minetest.get_modpath("worldedit_commands") .. "/safe.lua") local function get_position(name) --position 1 retrieval function for when not using `safe_region` local pos1 = worldedit.pos1[name] @@ -162,12 +162,28 @@ minetest.register_chatcommand("/inspect", { end, }) +local function get_node_rlight(pos) + local vecs = { -- neighboring nodes + {x= 1, y= 0, z= 0}, + {x=-1, y= 0, z= 0}, + {x= 0, y= 1, z= 0}, + {x= 0, y=-1, z= 0}, + {x= 0, y= 0, z= 1}, + {x= 0, y= 0, z=-1}, + } + local ret = 0 + for _, v in ipairs(vecs) do + ret = math.max(ret, minetest.get_node_light(vector.add(pos, v))) + end + return ret +end + minetest.register_on_punchnode(function(pos, node, puncher) local name = puncher:get_player_name() if worldedit.inspect[name] then local axis, sign = worldedit.player_axis(name) - message = string.format("inspector: %s at %s (param1=%d, param2=%d, light=%d) punched facing the %s axis", - node.name, minetest.pos_to_string(pos), node.param1, node.param2, minetest.get_node_light(pos), axis .. (sign > 0 and "+" or "-")) + message = string.format("inspector: %s at %s (param1=%d, param2=%d, received light=%d) punched facing the %s axis", + node.name, minetest.pos_to_string(pos), node.param1, node.param2, get_node_rlight(pos), axis .. (sign > 0 and "+" or "-")) worldedit.player_notify(name, message) end end) @@ -182,6 +198,8 @@ minetest.register_chatcommand("/reset", { worldedit.mark_pos1(name) worldedit.mark_pos2(name) worldedit.set_pos[name] = nil + --make sure the user does not try to confirm an operation after resetting pos: + reset_pending(name) worldedit.player_notify(name, "region reset") end, }) diff --git a/worldedit_commands/safe.lua b/worldedit_commands/safe.lua index e640853..a93e393 100644 --- a/worldedit_commands/safe.lua +++ b/worldedit_commands/safe.lua @@ -30,6 +30,10 @@ local function safe_region(callback, nodes_needed) end end +local function reset_pending(name) + safe_region_callback[name], safe_region_param[name] = nil, nil +end + minetest.register_chatcommand("/y", { params = "", description = "Confirm a pending operation", @@ -40,15 +44,8 @@ minetest.register_chatcommand("/y", { return end - --obtain positions - local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name] - if pos1 == nil or pos2 == nil then - worldedit.player_notify(name, "no region selected") - return - end - safe_region_callback[name], safe_region_param[name] = nil, nil --reset pending operation - callback(name, param, pos1, pos2) + callback(name, param) end, }) @@ -64,5 +61,5 @@ minetest.register_chatcommand("/n", { end, }) -return safe_region, check_region +return safe_region, check_region, reset_pending -- cgit v1.2.3