add config/user-props.toml combined object

This commit is contained in:
MihailRis 2024-11-26 11:21:04 +03:00
parent b3ac1bd8f4
commit 1cd890ff88
2 changed files with 17 additions and 1 deletions

View File

@ -0,0 +1 @@
"base:durability" = {}

View File

@ -1,4 +1,19 @@
function make_read_only(t)
local user_props = file.read_combined_object("config/user-props.toml")
local names = {}
for name, _ in pairs(user_props) do
table.insert(names, name)
end
-- remove undefined properties
for id, blockprops in pairs(block.properties) do
for propname, value in pairs(blockprops) do
if propname:find(':') and not table.has(names, propname) then
print("erase property", propname)
blockprops[propname] = nil
end
end
end
local function make_read_only(t)
setmetatable(t, {
__newindex = function()
error("table is read-only")