2018-09-08 12:12:15 -04:00
|
|
|
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
|
|
|
|
|
update areas, basic_signs, street_signs, farming_redo, maptools,
mesecons, moreblocks, moretrees, pipeworks, signs_lib, worldedit
2019-10-03 14:25:32 -04:00
|
|
|
local punched_air_time = {}
|
|
|
|
|
Huge update - lots of mods:
areas, biome_lib, blox, bobblocks, boost_cart, homedecor, mobs,
coloredwood, ilights, inbox, item_tweaks, moreblocks, moreores,
pipeworks, plasticbox, signs_lib, stainedglass, roads, unifieddyes,
vines, worldedit, xban2, maybe some others I didn't think about ;-)
2017-01-31 19:39:31 -05:00
|
|
|
minetest.register_tool(":worldedit:wand", {
|
update areas, basic_signs, street_signs, farming_redo, maptools,
mesecons, moreblocks, moretrees, pipeworks, signs_lib, worldedit
2019-10-03 14:25:32 -04:00
|
|
|
description = "WorldEdit Wand tool\nLeft-click to set 1st position, right-click to set 2nd",
|
Huge update - lots of mods:
areas, biome_lib, blox, bobblocks, boost_cart, homedecor, mobs,
coloredwood, ilights, inbox, item_tweaks, moreblocks, moreores,
pipeworks, plasticbox, signs_lib, stainedglass, roads, unifieddyes,
vines, worldedit, xban2, maybe some others I didn't think about ;-)
2017-01-31 19:39:31 -05:00
|
|
|
inventory_image = "worldedit_wand.png",
|
|
|
|
stack_max = 1, -- there is no need to have more than one
|
|
|
|
liquids_pointable = true, -- ground with only water on can be selected as well
|
|
|
|
|
|
|
|
on_use = function(itemstack, placer, pointed_thing)
|
update plantlife, castles, basic_materials, cool_trees, currency,
digistuff, farming_redo, technic, glooptest, homedecor, maptools,
mesecons, moreblocks, moreores, pipeworks, teleport_request,
unified_inventory, unifieddyes, worldedit, and xban
2020-02-16 01:45:23 -05:00
|
|
|
if placer == nil or pointed_thing == nil then return end
|
update areas, basic_signs, street_signs, farming_redo, maptools,
mesecons, moreblocks, moretrees, pipeworks, signs_lib, worldedit
2019-10-03 14:25:32 -04:00
|
|
|
local name = placer:get_player_name()
|
|
|
|
if pointed_thing.type == "node" then
|
|
|
|
-- set and mark pos1
|
2018-09-08 12:12:15 -04:00
|
|
|
worldedit.pos1[name] = above_or_under(placer, pointed_thing)
|
Huge update - lots of mods:
areas, biome_lib, blox, bobblocks, boost_cart, homedecor, mobs,
coloredwood, ilights, inbox, item_tweaks, moreblocks, moreores,
pipeworks, plasticbox, signs_lib, stainedglass, roads, unifieddyes,
vines, worldedit, xban2, maybe some others I didn't think about ;-)
2017-01-31 19:39:31 -05:00
|
|
|
worldedit.mark_pos1(name)
|
update areas, basic_signs, street_signs, farming_redo, maptools,
mesecons, moreblocks, moretrees, pipeworks, signs_lib, worldedit
2019-10-03 14:25:32 -04:00
|
|
|
elseif pointed_thing.type == "nothing" then
|
|
|
|
local now = minetest.get_us_time()
|
|
|
|
if now - (punched_air_time[name] or 0) < 1000 * 1000 then
|
|
|
|
-- reset markers
|
update plantlife, castles, basic_materials, cool_trees, currency,
digistuff, farming_redo, technic, glooptest, homedecor, maptools,
mesecons, moreblocks, moreores, pipeworks, teleport_request,
unified_inventory, unifieddyes, worldedit, and xban
2020-02-16 01:45:23 -05:00
|
|
|
worldedit.registered_commands["reset"].func(name)
|
update areas, basic_signs, street_signs, farming_redo, maptools,
mesecons, moreblocks, moretrees, pipeworks, signs_lib, worldedit
2019-10-03 14:25:32 -04:00
|
|
|
end
|
|
|
|
punched_air_time[name] = now
|
|
|
|
elseif pointed_thing.type == "object" then
|
|
|
|
local entity = pointed_thing.ref:get_luaentity()
|
|
|
|
if entity and entity.name == "worldedit:pos2" then
|
|
|
|
-- set pos1 = pos2
|
|
|
|
worldedit.pos1[name] = worldedit.pos2[name]
|
|
|
|
worldedit.mark_pos1(name)
|
|
|
|
end
|
Huge update - lots of mods:
areas, biome_lib, blox, bobblocks, boost_cart, homedecor, mobs,
coloredwood, ilights, inbox, item_tweaks, moreblocks, moreores,
pipeworks, plasticbox, signs_lib, stainedglass, roads, unifieddyes,
vines, worldedit, xban2, maybe some others I didn't think about ;-)
2017-01-31 19:39:31 -05:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
update areas, basic_signs, street_signs, farming_redo, maptools,
mesecons, moreblocks, moretrees, pipeworks, signs_lib, worldedit
2019-10-03 14:25:32 -04:00
|
|
|
on_place = function(itemstack, placer, pointed_thing)
|
update plantlife, castles, basic_materials, cool_trees, currency,
digistuff, farming_redo, technic, glooptest, homedecor, maptools,
mesecons, moreblocks, moreores, pipeworks, teleport_request,
unified_inventory, unifieddyes, worldedit, and xban
2020-02-16 01:45:23 -05:00
|
|
|
if placer == nil or (pointed_thing or {}).type ~= "node" then
|
|
|
|
return itemstack
|
|
|
|
end
|
update areas, basic_signs, street_signs, farming_redo, maptools,
mesecons, moreblocks, moretrees, pipeworks, signs_lib, worldedit
2019-10-03 14:25:32 -04:00
|
|
|
local name = placer:get_player_name()
|
update plantlife, castles, basic_materials, cool_trees, currency,
digistuff, farming_redo, technic, glooptest, homedecor, maptools,
mesecons, moreblocks, moreores, pipeworks, teleport_request,
unified_inventory, unifieddyes, worldedit, and xban
2020-02-16 01:45:23 -05:00
|
|
|
-- set and mark pos2
|
|
|
|
worldedit.pos2[name] = above_or_under(placer, pointed_thing)
|
|
|
|
worldedit.mark_pos2(name)
|
|
|
|
return itemstack -- nothing consumed, nothing changed
|
|
|
|
end,
|
|
|
|
|
|
|
|
on_secondary_use = function(itemstack, user, pointed_thing)
|
|
|
|
if user == nil or (pointed_thing or {}).type ~= "object" then
|
|
|
|
return itemstack
|
|
|
|
end
|
|
|
|
local name = user:get_player_name()
|
|
|
|
local entity = pointed_thing.ref:get_luaentity()
|
|
|
|
if entity and entity.name == "worldedit:pos1" then
|
|
|
|
-- set pos2 = pos1
|
|
|
|
worldedit.pos2[name] = worldedit.pos1[name]
|
Huge update - lots of mods:
areas, biome_lib, blox, bobblocks, boost_cart, homedecor, mobs,
coloredwood, ilights, inbox, item_tweaks, moreblocks, moreores,
pipeworks, plasticbox, signs_lib, stainedglass, roads, unifieddyes,
vines, worldedit, xban2, maybe some others I didn't think about ;-)
2017-01-31 19:39:31 -05:00
|
|
|
worldedit.mark_pos2(name)
|
|
|
|
end
|
|
|
|
return itemstack -- nothing consumed, nothing changed
|
|
|
|
end,
|
|
|
|
})
|