|
| 1 | +minetest.register_tool("worldedit:wand", { |
| 2 | + description = "WorldEdit wand tool. Left-click to set the 1st position, Right-click to set the 2nd position.", |
| 3 | + groups = {}, |
| 4 | + inventory_image = "worldedit_wand.png", |
| 5 | + wield_image = "", |
| 6 | + wield_scale = {x=1,y=1,z=1}, |
| 7 | + stack_max = 1, -- there is no need to have more than one |
| 8 | + liquids_pointable = true, -- ground with only water on can be selected as well |
| 9 | + -- the tool_capabilities are completely irrelevant here - no need to dig |
| 10 | + tool_capabilities = { |
| 11 | + full_punch_interval = 1.0, |
| 12 | + max_drop_level=0, |
| 13 | + groupcaps={ |
| 14 | + fleshy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1}, |
| 15 | + snappy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1}, |
| 16 | + choppy={times={[3]=0.90}, maxwear=0.05, maxlevel=0} |
| 17 | + } |
| 18 | + }, |
| 19 | + node_placement_prediction = nil, |
| 20 | + |
| 21 | + on_use = function(itemstack, placer, pointed_thing) |
| 22 | + if placer ~= nil and pointed_thing ~= nil then |
| 23 | + local name = placer:get_player_name() |
| 24 | + local pos = minetest.get_pointed_thing_position( pointed_thing, false ) -- not above |
| 25 | + |
| 26 | + if not pos then |
| 27 | + return itemstack |
| 28 | + end |
| 29 | + |
| 30 | + worldedit.pos1[name] = pos |
| 31 | + worldedit.mark_pos1(name) |
| 32 | + |
| 33 | + end |
| 34 | + return itemstack -- nothing consumed, nothing changed |
| 35 | + end, |
| 36 | + |
| 37 | + on_place = function(itemstack, placer, pointed_thing) -- Left Click |
| 38 | + if placer ~= nil and pointed_thing ~= nil then |
| 39 | + local name = placer:get_player_name() |
| 40 | + local pos = minetest.get_pointed_thing_position( pointed_thing, false ) -- not above |
| 41 | + |
| 42 | + if not pos then |
| 43 | + return itemstack |
| 44 | + end |
| 45 | + |
| 46 | + worldedit.pos2[name] = pos |
| 47 | + worldedit.mark_pos2(name) |
| 48 | + end |
| 49 | + return itemstack -- nothing consumed, nothing changed |
| 50 | + end, |
| 51 | +}) |
0 commit comments