2021-07-12 08:40:45 -07:00
|
|
|
|
2021-07-12 08:45:22 -07:00
|
|
|
--- Cleaner API
|
|
|
|
--
|
|
|
|
-- @topic api
|
|
|
|
|
|
|
|
|
2021-07-12 08:40:45 -07:00
|
|
|
local replace_items = {}
|
|
|
|
local replace_nodes = {}
|
|
|
|
|
|
|
|
|
2021-07-12 08:45:22 -07:00
|
|
|
--- Retrieves list of items to be replaced.
|
|
|
|
--
|
|
|
|
-- @treturn table Items to be replaced.
|
2021-07-12 08:40:45 -07:00
|
|
|
function cleaner.get_replace_items()
|
|
|
|
return replace_items
|
|
|
|
end
|
|
|
|
|
2021-07-12 08:45:22 -07:00
|
|
|
--- Retrieves list of nodes to be replaced.
|
|
|
|
--
|
|
|
|
-- @treturn table Nodes to be replaced.
|
2021-07-12 08:40:45 -07:00
|
|
|
function cleaner.get_replace_nodes()
|
|
|
|
return replace_nodes
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2021-07-12 08:45:22 -07:00
|
|
|
--- Registers an entity to be removed.
|
|
|
|
--
|
|
|
|
-- @tparam string src Entity technical name.
|
2021-07-12 08:40:45 -07:00
|
|
|
function cleaner.remove_entity(src)
|
|
|
|
core.register_entity(":" .. src, {
|
|
|
|
on_activate = function(self, staticdata)
|
|
|
|
self.object:remove()
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2021-07-12 08:45:22 -07:00
|
|
|
--- Registers a node to be removed.
|
|
|
|
--
|
|
|
|
-- @tparam string src Node technical name.
|
2021-07-12 08:40:45 -07:00
|
|
|
function cleaner.remove_node(src)
|
|
|
|
core.register_node(":" .. src, {
|
|
|
|
groups = {to_remove=1},
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2021-07-12 08:45:22 -07:00
|
|
|
--- Registeres an item to be replaced.
|
|
|
|
--
|
|
|
|
-- @tparam string src Technical name of item to be replaced.
|
|
|
|
-- @tparam string tgt Technical name of item to be used in place.
|
2021-07-12 08:40:45 -07:00
|
|
|
function cleaner.replace_item(src, tgt)
|
|
|
|
replace_items[src] = tgt
|
|
|
|
end
|
|
|
|
|
2021-07-12 08:45:22 -07:00
|
|
|
--- Registers a node to be replaced.
|
|
|
|
--
|
|
|
|
-- @tparam string src Technical name of node to be replaced.
|
|
|
|
-- @tparam string tgt Technical name of node to be used in place.
|
2021-07-12 08:40:45 -07:00
|
|
|
function cleaner.replace_node(src, tgt)
|
|
|
|
core.register_node(":" .. src, {
|
|
|
|
groups = {to_replace=1},
|
|
|
|
})
|
|
|
|
|
|
|
|
replace_nodes[src] = tgt
|
|
|
|
end
|