mirror of
https://codeberg.org/AntumLuanti/mod-cleaner.git
synced 2025-03-21 15:41:22 +00:00
Re-add functionality to clean nodes:
Nodes to clean can be listed in 'clean_nodes.txt' file in world path.
This commit is contained in:
parent
04338946da
commit
388e5481e7
3 changed files with 48 additions and 2 deletions
|
@ -4,7 +4,7 @@
|
||||||
---
|
---
|
||||||
### **Description:**
|
### **Description:**
|
||||||
|
|
||||||
Fork of [PilzAdam's ***clean*** mod][f.pilzadam] for Minetest.
|
A simple Minetest mod that can be used to remove unknown entities & nodes. Forked from [PilzAdam's ***clean*** mod][f.pilzadam].
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
A simple mod that can be used to remove unknown entities.
|
A simple mod that can be used to remove unknown entities & nodes.
|
||||||
|
|
46
init.lua
46
init.lua
|
@ -19,6 +19,8 @@ local function logDebug(msg)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- ENTITIES
|
||||||
|
|
||||||
local old_entities = {}
|
local old_entities = {}
|
||||||
|
|
||||||
-- Populate entities list from file in world path
|
-- Populate entities list from file in world path
|
||||||
|
@ -54,3 +56,47 @@ for _, entity_name in ipairs(old_entities) do
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- NODES
|
||||||
|
|
||||||
|
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')
|
||||||
|
if n_file then
|
||||||
|
n_list = n_file:read('*a')
|
||||||
|
n_file:close()
|
||||||
|
else
|
||||||
|
-- Create empty file
|
||||||
|
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')
|
||||||
|
for _, node_name in ipairs(n_list) do
|
||||||
|
table.insert(old_nodes, node_name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, node_name in ipairs(old_nodes) do
|
||||||
|
core.register_node(':' .. node_name, {
|
||||||
|
groups = {old=1},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
core.register_abm({
|
||||||
|
nodenames = {'group:old'},
|
||||||
|
interval = 1,
|
||||||
|
chance = 1,
|
||||||
|
action = function(pos, node)
|
||||||
|
core.remove_node(pos)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
Loading…
Add table
Reference in a new issue