Minetest-WorldEditAdditions/worldeditadditions_commands/commands/selectors/scloud.lua

49 lines
1.9 KiB
Lua
Raw Permalink Normal View History

2022-09-18 21:20:04 +00:00
local wea = worldeditadditions
local wea_c = worldeditadditions_core
local Vector3 = wea_c.Vector3
-- ██████ ██████ ██ ██████ ██ ██ ██████
2021-03-12 23:47:10 +00:00
-- ██ ██ ██ ██ ██ ██ ██ ██ ██
-- ███████ ██ ██ ██ ██ ██ ██ ██ ██
-- ██ ██ ██ ██ ██ ██ ██ ██ ██
-- ██████ ██████ ███████ ██████ ██████ ██████
minetest.register_on_punchnode(function(pos, node, puncher)
local name = puncher:get_player_name()
if name ~= "" and wea.add_pos[name] ~= nil then
if wea.add_pos[name] > 0 then
2022-09-18 21:20:04 +00:00
wea.selection.add_point(name, pos)
wea.add_pos[name] = wea.add_pos[name] - 1
2024-10-17 02:22:34 +00:00
wea_c.notify.info(name, "You have "..wea.add_pos[name].." nodes left to punch")
else wea.add_pos[name] = nil end
end
end)
worldeditadditions_core.register_command("scloud", {
params = "<0-6|stop|reset>",
description = "Set and add to WorldEdit region by punching up to six nodes that define the maximums of your target",
2021-03-12 23:47:10 +00:00
privs = {worldedit=true},
parse = function(param)
return true, param
end,
func = function(name, param)
local que = tonumber(param)
if que then
if que > 0 then
wea.add_pos[name] = que < 7 and que or 6
return true, "create or add to selection by punching "..wea.add_pos[name].." nodes"
else
wea.add_pos[name] = nil
return true, "0 nodes to punch: operation canceled"
end
elseif param == "stop" then
wea.add_pos[name] = nil
return true, "selection operation stopped"
elseif param == "reset" then
wea.add_pos[name] = nil
wea.selection.clear_points(name)
2021-03-12 23:47:10 +00:00
return true, "selection cleared"
else
return false, (param == "" and "no input" or "invalid input: '"..param.."'").."! Allowed params are: 0-6, stop, or reset"
2021-03-12 23:47:10 +00:00
end
end,
})