mirror of
https://codeberg.org/AntumLuanti/mod-cleaner.git
synced 2025-03-15 04:41:22 +00:00
Load entities to clean from file in world path
This commit is contained in:
parent
9200ed9c20
commit
a0a3dc370d
1 changed files with 27 additions and 0 deletions
27
init.lua
27
init.lua
|
@ -46,7 +46,34 @@ core.register_abm({
|
|||
end,
|
||||
})
|
||||
|
||||
|
||||
-- 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')
|
||||
if e_file then
|
||||
e_list = e_file:read('*a')
|
||||
e_file:close()
|
||||
else
|
||||
-- Create empty file
|
||||
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')
|
||||
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, {
|
||||
on_activate = function(self, staticdata)
|
||||
self.object:remove()
|
||||
|
|
Loading…
Add table
Reference in a new issue