mirror of
https://codeberg.org/AntumLuanti/mod-cleaner.git
synced 2025-03-15 04:41:22 +00:00
add support for unregistering ores via world path file
This commit is contained in:
parent
efc5ef2660
commit
bb36a723d3
4 changed files with 34 additions and 1 deletions
1
TODO.txt
1
TODO.txt
|
@ -1,4 +1,3 @@
|
|||
|
||||
TODO:
|
||||
- add localization support
|
||||
- add support for unregistering ores via world path file
|
||||
|
|
16
api.lua
16
api.lua
|
@ -72,6 +72,22 @@ end
|
|||
|
||||
|
||||
if cleaner.unsafe then
|
||||
local remove_ores = {}
|
||||
|
||||
--- Retrieves list of ores to be removed.
|
||||
--
|
||||
-- @treturn table Ores to be replaced.
|
||||
function cleaner.get_remove_ores()
|
||||
return remove_ores
|
||||
end
|
||||
|
||||
--- Registers an ore to be removed after server startup.
|
||||
--
|
||||
-- @tparam string src Ore technical name.
|
||||
function cleaner.register_ore_removal(src)
|
||||
table.insert(remove_ores, src)
|
||||
end
|
||||
|
||||
--- Removes an ore definition.
|
||||
--
|
||||
-- @tparam string src Ore technical name.
|
||||
|
|
1
init.lua
1
init.lua
|
@ -43,6 +43,7 @@ local scripts = {
|
|||
"entities",
|
||||
"nodes",
|
||||
"items",
|
||||
"ores",
|
||||
}
|
||||
|
||||
for _, script in ipairs(scripts) do
|
||||
|
|
17
ores.lua
Normal file
17
ores.lua
Normal file
|
@ -0,0 +1,17 @@
|
|||
|
||||
if not cleaner.unsafe then return end
|
||||
|
||||
local aux = dofile(cleaner.modpath .. "/misc_functions.lua")
|
||||
|
||||
local ores_data = aux.get_world_data().ores
|
||||
|
||||
for _, ore in ipairs(ores_data.remove) do
|
||||
cleaner.register_ore_removal(ore)
|
||||
end
|
||||
|
||||
core.register_on_mods_loaded(function()
|
||||
for _, ore in ipairs(cleaner.get_remove_ores()) do
|
||||
cleaner.log("action", "unregistering ore: " .. ore)
|
||||
cleaner.remove_ore(ore)
|
||||
end
|
||||
end)
|
Loading…
Add table
Reference in a new issue