mirror of
https://codeberg.org/AntumLuanti/mod-cleaner.git
synced 2025-03-15 04:41:22 +00:00
Cleanup
This commit is contained in:
parent
9130ca1034
commit
5a918081e2
1 changed files with 24 additions and 24 deletions
48
init.lua
48
init.lua
|
@ -6,15 +6,15 @@
|
|||
cleaner = {}
|
||||
cleaner.name = core.get_current_modname()
|
||||
|
||||
local debug = core.settings:get_bool('enable_debug_mods')
|
||||
local debug = core.settings:get_bool("enable_debug_mods")
|
||||
|
||||
local function log(level, msg)
|
||||
core.log(level, '[' .. cleaner.name .. '] ' .. msg)
|
||||
core.log(level, "[" .. cleaner.name .. "] " .. msg)
|
||||
end
|
||||
|
||||
local function logDebug(msg)
|
||||
if debug then
|
||||
core.log('DEBUG: [' .. cleaner.name .. '] ' .. msg)
|
||||
core.log("DEBUG: [" .. cleaner.name .. "] " .. msg)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -25,32 +25,32 @@ local old_entities = {}
|
|||
|
||||
-- Populate entities list from file in world path
|
||||
local e_list = nil
|
||||
local e_path = core.get_worldpath() .. '/clean_entities.txt'
|
||||
local e_file = io.open(e_path, 'r')
|
||||
local e_path = core.get_worldpath() .. "/clean_entities.txt"
|
||||
local e_file = io.open(e_path, "r")
|
||||
if e_file then
|
||||
e_list = e_file:read('*a')
|
||||
e_list = e_file:read("*a")
|
||||
e_file:close()
|
||||
else
|
||||
-- Create empty file
|
||||
e_file = io.open(e_path, 'w')
|
||||
e_file = io.open(e_path, "w")
|
||||
if e_file then
|
||||
e_file:close()
|
||||
end
|
||||
end
|
||||
|
||||
if e_list then
|
||||
logDebug('Loading entities to clean from file ...')
|
||||
|
||||
e_list = string.split(e_list, '\n')
|
||||
logDebug("Loading entities to clean from file ...")
|
||||
|
||||
e_list = string.split(e_list, "\n")
|
||||
for _, entity_name in ipairs(e_list) do
|
||||
table.insert(old_entities, entity_name)
|
||||
end
|
||||
end
|
||||
|
||||
for _, entity_name in ipairs(old_entities) do
|
||||
logDebug('Cleaning entity: ' .. entity_name)
|
||||
|
||||
core.register_entity(':' .. entity_name, {
|
||||
logDebug("Cleaning entity: " .. entity_name)
|
||||
|
||||
core.register_entity(":" .. entity_name, {
|
||||
on_activate = function(self, staticdata)
|
||||
self.object:remove()
|
||||
end,
|
||||
|
@ -64,38 +64,38 @@ local old_nodes = {}
|
|||
|
||||
-- Populate nodes list from file in world path
|
||||
local n_list = nil
|
||||
local n_path = core.get_worldpath() .. '/clean_nodes.txt'
|
||||
local n_file = io.open(n_path, 'r')
|
||||
local n_path = core.get_worldpath() .. "/clean_nodes.txt"
|
||||
local n_file = io.open(n_path, "r")
|
||||
if n_file then
|
||||
n_list = n_file:read('*a')
|
||||
n_list = n_file:read("*a")
|
||||
n_file:close()
|
||||
else
|
||||
-- Create empty file
|
||||
n_file = io.open(n_path, 'w')
|
||||
n_file = io.open(n_path, "w")
|
||||
if n_file then
|
||||
n_file:close()
|
||||
end
|
||||
end
|
||||
|
||||
if n_list then
|
||||
logDebug('Loading nodes to clean from file ...')
|
||||
|
||||
n_list = string.split(n_list, '\n')
|
||||
logDebug("Loading nodes to clean from file ...")
|
||||
|
||||
n_list = string.split(n_list, "\n")
|
||||
for _, node_name in ipairs(n_list) do
|
||||
table.insert(old_nodes, node_name)
|
||||
end
|
||||
end
|
||||
|
||||
for _, node_name in ipairs(old_nodes) do
|
||||
logDebug('Cleaning node: ' .. node_name)
|
||||
|
||||
core.register_node(':' .. node_name, {
|
||||
logDebug("Cleaning node: " .. node_name)
|
||||
|
||||
core.register_node(":" .. node_name, {
|
||||
groups = {old=1},
|
||||
})
|
||||
end
|
||||
|
||||
core.register_abm({
|
||||
nodenames = {'group:old'},
|
||||
nodenames = {"group:old"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node)
|
||||
|
|
Loading…
Add table
Reference in a new issue