Skip to content

Commit 4771284

Browse files
pickardjoesfan5
authored andcommittedJan 22, 2016
Added a WorldEdit wand item that can be used to select areas with worldedit.
1 parent 2bd4d6f commit 4771284

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed
 

‎worldedit/init.lua

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ load_module(path .. "/visualization.lua")
3636
load_module(path .. "/serialization.lua")
3737
load_module(path .. "/code.lua")
3838
load_module(path .. "/compatibility.lua")
39+
load_module(path .. "/wand.lua")
3940

4041

4142
if minetest.setting_getbool("log_mods") then

‎worldedit/textures/worldedit_wand.png

442 Bytes
Loading

‎worldedit/wand.lua

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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

Comments
 (0)
Please sign in to comment.