burli wrote:I want to edit schematics. Can I convert them to Lua schematics and back to binary?
paramat wrote:Default tree (and logs, bushes, corals, large cactus, papyrus, waterliiy) schematic files are created from simple Lua tables using this mod https://github.com/minetest-mods/saveschems
Worldedit cannot set certain parameters so is of limited use.
burli wrote:Thank you. But why using the binary format? Just because file size?
burli wrote:Hmm, I just want to know why we need the binary format if there is the lua format.
I think, schematics are not the worst thing. I don't know if they should be used for trees, but I have other things in mind where I can use them, but I would always use the lua table.
I don't know what could be an alternative for trees. The old v6 method is complicated and slow, but more flexible. It has it's own charm.
ExeterDad wrote:Also... if we distribute binaries... where is the source code for the tree's? In another mod? Unless I've missed something somewhere.
burli wrote:ExeterDad wrote:Also... if we distribute binaries... where is the source code for the tree's? In another mod? Unless I've missed something somewhere.
The source for the default trees is in the saveschem mod
burli wrote:Hmm, I just want to know why we need the binary format if there is the lua format.
I think, schematics are not the worst thing. I don't know if they should be used for trees, but I have other things in mind where I can use them, but I would always use the lua table.
I don't know what could be an alternative for trees. The old v6 method is complicated and slow, but more flexible. It has it's own charm.
paramat wrote:<snip>
minetest.serialize_schematic can create a lua table string from a .mts file https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L2601
More schematic info https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L947
<more snip>
paramat wrote:The priority is fast placing in the world, most large structures in the world are schematics and are placed at mapgen time. Mapgen speed has priority, file size is of little importance, but it being less helps.
function ai_library.build:build_tree(self)
local building = minetest.get_modpath("open_ai").."/schematics/jungle_tree.mts"
if self.schem == nil then
local str = minetest.serialize_schematic(building, "lua", {lua_use_comments = false, lua_num_indent_spaces = 0}).." return(schematic)"
local schematic = loadstring(str)()
print(dump(schematic))
end
end
paramat wrote:Hmm of course, sorry i misunderstood, you both mean storing them in a subgame as a Lua table as opposed to an mts file. So once a Lua table is converted to mts it will be just as fast in mapgen.
Maybe the saveschems mod should be included in the MTGame repo somehow.
TumeniNodes, no problem :]
Indeed a schematic editing mod could possibly be written.
I was discussing the conversion of mts to lua with a modder and they came up with this to convert the mts to a block of lua code:Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
function ai_library.build:build_tree(self)
local building = minetest.get_modpath("open_ai").."/schematics/jungle_tree.mts"
if self.schem == nil then
local str = minetest.serialize_schematic(building, "lua", {lua_use_comments = false, lua_num_indent_spaces = 0}).." return(schematic)"
local schematic = loadstring(str)()
print(dump(schematic))
end
end
Users browsing this forum: No registered users and 4 guests