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:
Aaron Suen 2022-11-23 12:04:58 -05:00
parent 241e79647f
commit 8a137ec91f
2 changed files with 36 additions and 1 deletions

View File

@ -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
})

View File

@ -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]