MineClone2/mods/MAPGEN/mcl_villages/convert_lua_mts.lua

30 lines
936 B
Lua
Raw Normal View History

--
function settlements.convert_mts_to_lua()
2021-01-29 19:49:33 +01:00
local building = schem_path.."townhall.mts"
local str = minetest.serialize_schematic(building, "lua", {lua_use_comments = true, lua_num_indent_spaces = 0}).." return(schematic)"
local schematic = loadstring(str)()
local file = io.open(schem_path.."church"..".lua", "w")
file:write(dump(schematic))
file:close()
print(dump(schematic))
end
function settlements.mts_save()
2021-01-29 19:49:33 +01:00
local f = assert(io.open(schem_path.."hut.lua", "r"))
local content = f:read("*all").." return(schematic2)"
f:close()
2021-01-29 19:49:33 +01:00
local schematic2 = loadstring("schematic2 = "..content)()
local seb = minetest.serialize_schematic(schematic2, "mts", {})
local filename = schem_path .. "hut2" .. ".mts"
filename = filename:gsub("\"", "\\\""):gsub("\\", "\\\\")
local file, err = io.open(filename, "wb")
if err == nil and seb then
file:write(seb)
file:flush()
file:close()
end
print("Wrote: " .. filename)
2021-01-29 19:49:33 +01:00
end