make_colorstxt/init.lua
2023-08-18 21:52:01 +02:00

25 lines
741 B
Lua

local modpath = minetest.get_modpath(minetest.get_current_modname())
local map_path = minetest.get_modpath("mcl_maps")
local col_file = io.open(map_path .. "/colors.json", "r")
local colorstxt = io.open(modpath .. "/colors.txt", "w")
local mapcolors = minetest.parse_json(col_file:read("*a"))
minetest.register_on_mods_loaded(function()
local notiles = {}
local colfile = {}
for k,v in pairs(minetest.registered_nodes) do
if v.tiles then
local mcol = mapcolors[v.tiles[1]] or mapcolors[v.tiles[1].name]
if mcol then
table.insert(colfile,k.." "..mcol[1].." "..mcol[2].." "..mcol[3])
end
else
table.insert(notiles,k)
end
end
table.sort(colfile)
colorstxt:write(table.concat(colfile,"\n"))
colorstxt:close()
end)