2020-05-02 23:37:18 +00:00
-- ██████ ██ ██ ███████ ██████ ██ █████ ██ ██
-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
-- ██ ██ ██ ██ █████ ██████ ██ ███████ ████
-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
-- ██████ ████ ███████ ██ ██ ███████ ██ ██ ██
2022-05-19 21:10:09 +00:00
worldeditadditions_core.register_command ( " overlay " , {
2020-06-07 19:46:46 +00:00
params = " <replace_node_a> [<chance_a>] <replace_node_b> [<chance_b>] [<replace_node_N> [<chance_N>]] ... " ,
description = " Places <replace_node_a> in the last contiguous air space encountered above the first non-air node. In other words, overlays all top-most nodes in the specified area with <replace_node_a>. Optionally supports a mix of nodes and chances, as in //mix and //replacemix. " ,
2020-05-02 23:37:18 +00:00
privs = { worldedit = true } ,
2020-05-10 20:32:01 +00:00
require_pos = 2 ,
parse = function ( params_text )
2021-03-20 01:48:56 +00:00
local success , node_list = worldeditadditions.parse . weighted_nodes (
2021-07-31 15:03:04 +00:00
worldeditadditions.split_shell ( params_text )
2020-06-07 19:46:46 +00:00
)
return success , node_list
2020-05-10 20:32:01 +00:00
end ,
nodes_needed = function ( name )
-- //overlay only modifies up to 1 node per column in the selected region
local pos1 , pos2 = worldedit.sort_pos ( worldedit.pos1 [ name ] , worldedit.pos2 [ name ] )
return ( pos2.x - pos1.x ) * ( pos2.y - pos1.y )
end ,
2020-06-07 19:46:46 +00:00
func = function ( name , node_list )
2020-06-26 19:46:35 +00:00
local start_time = worldeditadditions.get_ms_time ( )
2020-06-07 19:46:46 +00:00
local changes = worldeditadditions.overlay ( worldedit.pos1 [ name ] , worldedit.pos2 [ name ] , node_list )
2020-06-26 19:46:35 +00:00
local time_taken = worldeditadditions.get_ms_time ( ) - start_time
2020-05-02 23:37:18 +00:00
minetest.log ( " action " , name .. " used //overlay at " .. worldeditadditions.vector . tostring ( worldedit.pos1 [ name ] ) .. " , replacing " .. changes.updated .. " nodes and skipping " .. changes.skipped_columns .. " columns in " .. time_taken .. " s " )
2021-03-20 01:48:56 +00:00
return true , changes.updated .. " nodes replaced and " .. changes.skipped_columns .. " columns skipped in " .. worldeditadditions.format . human_time ( time_taken )
2020-05-10 20:32:01 +00:00
end
2020-05-02 23:37:18 +00:00
} )