Skip to content

Commit

Permalink
Wand: select node under or above depending on pressed sneak key.
Browse files Browse the repository at this point in the history
  • Loading branch information
beyondlimits authored and sfan5 committed Aug 6, 2018
1 parent 99fa0eb commit f725663
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions worldedit_commands/wand.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
local function above_or_under(placer, pointed_thing)
if placer:get_player_control().sneak then
return pointed_thing.above
else
return pointed_thing.under
end
end

minetest.register_tool(":worldedit:wand", {
description = "WorldEdit Wand tool, Left-click to set 1st position, right-click to set 2nd",
inventory_image = "worldedit_wand.png",
Expand All @@ -7,7 +15,7 @@ minetest.register_tool(":worldedit:wand", {
on_use = function(itemstack, placer, pointed_thing)
if placer ~= nil and pointed_thing ~= nil and pointed_thing.type == "node" then
local name = placer:get_player_name()
worldedit.pos1[name] = pointed_thing.under
worldedit.pos1[name] = above_or_under(placer, pointed_thing)
worldedit.mark_pos1(name)
end
return itemstack -- nothing consumed, nothing changed
Expand All @@ -16,7 +24,7 @@ minetest.register_tool(":worldedit:wand", {
on_place = function(itemstack, placer, pointed_thing) -- Left Click
if placer ~= nil and pointed_thing ~= nil and pointed_thing.type == "node" then
local name = placer:get_player_name()
worldedit.pos2[name] = pointed_thing.under
worldedit.pos2[name] = above_or_under(placer, pointed_thing)
worldedit.mark_pos2(name)
end
return itemstack -- nothing consumed, nothing changed
Expand Down

0 comments on commit f725663

Please sign in to comment.