Add a command to rip nearby in radius
This is useful for "things used by a scematic" sorts of scenarios. Always block air/ignore just in case they end up in the export list somehow.
This commit is contained in:
parent
241e79647f
commit
8a137ec91f
30
commands.lua
30
commands.lua
@ -42,3 +42,33 @@ minetest.register_chatcommand(modname .. "_inv", {
|
||||
return true, "exported " .. exportall()
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand(modname .. "_here", {
|
||||
description = "Rip all nodes within a radius",
|
||||
params = "[radius = 100]",
|
||||
privs = {server = true},
|
||||
func = function(name, param)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if not player then return false, "invalid player" end
|
||||
|
||||
local radius = tonumber(param) or 100
|
||||
local pos = player:get_pos()
|
||||
|
||||
local foundids = {}
|
||||
do
|
||||
local vm = minetest.get_voxel_manip(
|
||||
vector.subtract(pos, radius),
|
||||
vector.add(pos, radius))
|
||||
local data = vm:get_data()
|
||||
for i = 1, #data do foundids[data[i]] = true end
|
||||
end
|
||||
|
||||
for k in pairs(foundids) do
|
||||
local n = minetest.get_name_from_content_id(k)
|
||||
if n then exportdb[n] = true end
|
||||
end
|
||||
|
||||
savedb()
|
||||
return true, "exported " .. exportall()
|
||||
end
|
||||
})
|
||||
|
@ -38,6 +38,11 @@ local nodekeys = {
|
||||
wield_image = true,
|
||||
}
|
||||
|
||||
local blocked = {
|
||||
air = true,
|
||||
ignore = true
|
||||
}
|
||||
|
||||
local function exportall()
|
||||
local count = 0
|
||||
|
||||
@ -48,7 +53,7 @@ local function exportall()
|
||||
|
||||
local filtered = {}
|
||||
for k, v in pairs(minetest.registered_items) do
|
||||
if exportdb[k] and v.liquidtype ~= "flowing" then
|
||||
if not blocked[k] and exportdb[k] and v.liquidtype ~= "flowing" then
|
||||
local t = {}
|
||||
for k2, v2 in pairs(v) do
|
||||
local keydef = nodekeys[k2]
|
||||
|
Loading…
x
Reference in New Issue
Block a user