Page 1 of 1

how can I edit schematics?

PostPosted: Mon Feb 06, 2017 08:37
by burli
I want to edit schematics. Can I convert them to Lua schematics and back to binary?

Re: how can I edit schematics?

PostPosted: Tue Feb 07, 2017 00:04
by duane
This is why I don't use binary schematics. You're saving a trivial amount of space in exchange for making them very difficult to edit.

The schematic code is in the source. You could always cobble together something to read it back and spit out lua code. Personally, I'd just as soon not support the concept that much. I'd rather see it removed.

Re: how can I edit schematics?

PostPosted: Tue Feb 07, 2017 00:11
by TumeniNodes
burli wrote:I want to edit schematics. Can I convert them to Lua schematics and back to binary?

schematics... the necessary evil.... (for now anyway)

not sure if this helps?
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.


I have yet to use it so far so not sure if it enables editing or solely creating

Re: how can I edit schematics?

PostPosted: Tue Feb 07, 2017 06:47
by burli
So there is no converter or built-in function to convert mts files to lua. That is dump

I think, schematics are not bad, but without an editing tool the binaries are pretty useless

I need a little bit help. Is it possible to place rotated nodes in a lua schematic?

Edit: wow, the forum was gone for a long time. To answer myself: yes, nodes can be rotated with param2. Any documentation about param2 rotation or do I have to guess?

And prob stands for probability, right? 255 means, that these nodes always spawn, the lower the value the lower the chance to spawn

Re: how can I edit schematics?

PostPosted: Tue Feb 07, 2017 12:50
by TumeniNodes
I found this (still related to the last code I posted earlier)
paramat explains a bit more regarding creating mts schematics, including regarding forced place and normal rotation

I hope something here helps.
https://forum.minetest.net/viewtopic.php?f=9&t=12011

There are also some items in a search which turn up links to "supposedly" mts editors but, #1 not sure if they truly are "editors" and #2 they are windows apps.
When I was looking for the same thing just recently (which is why paramat replied giving the link to the code I posted to you) I found nothing under linux... there was an article claiming a few programs which could open them which turned out to be a bluff.

In worst case, you may need to redo the schematics you wish to edit... using your own settings

Re: how can I edit schematics?

PostPosted: Tue Feb 07, 2017 14:01
by burli
Thank you. But why using the binary format? Just because file size?

Re: how can I edit schematics?

PostPosted: Tue Feb 07, 2017 15:03
by TumeniNodes
burli wrote:Thank you. But why using the binary format? Just because file size?


probably just a very early-on choice, and by now what is required to change it, and what else may it affect? As well as, has it been an issue, or a big enough issue to make it a priority atm?

I imagine some have been thinking about a few similar aspects, and thinking of what to change. But then a list builds in the mind, in regards to like I stated above...

This should be changed
How do I change it
What is required and how much work+time
What else might it affect
Does it deserve priority attention (is it that important at this time)
What else might be more important

As we all know, there is a very small team, and much to do.

I think what you've been doing is very good, and definitely makes sense.
You have many really great ideas, and you do the work, and even nicer..., the dev team is really on-board with it all and there is momentum.
So, thank you to all of you.

I think if you are patient, use of .mts schematics may eventually be phased out. It will be just a matter of how can it be replaced, and the issue's priority level.

Keep on truckin' :D

Re: how can I edit schematics?

PostPosted: Tue Feb 07, 2017 15:50
by burli
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.

Re: how can I edit schematics?

PostPosted: Tue Feb 07, 2017 17:56
by ExeterDad
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.

Also... if we distribute binaries... where is the source code for the tree's? In another mod? Unless I've missed something somewhere.

Re: how can I edit schematics?

PostPosted: Tue Feb 07, 2017 18:09
by burli
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

Re: how can I edit schematics?

PostPosted: Tue Feb 07, 2017 20:46
by ExeterDad
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

Yes they are. But I only found them by accident, in a unrelated repo. I would think they need to be with Minetest_game sources.

Re: how can I edit schematics?

PostPosted: Tue Feb 07, 2017 22:01
by duane
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.


Aside from the tiny saving in file size, it's slightly easier and quicker to read the binary format in the C code. Of course, you still have to maintain both sets of code...

Re: how can I edit schematics?

PostPosted: Tue Feb 07, 2017 23:26
by paramat
See https://github.com/minetest-mods/saveschems for the latest and maintained version of this mod.

> This is why I don't use binary schematics. You're saving a trivial amount of space in exchange for making them very difficult to edit.

> But why using the binary format? Just because file size?

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.

> So there is no converter or built-in function to convert mts files to lua

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

> I think if you are patient, use of .mts schematics may eventually be phased out.

This is funny, as if they are seriously flawed in some way. They are very well coded by hmmmm and work very well.
They are like small bits of world database since they have content ID, param1 (prob) and param2 (various uses).

Re: how can I edit schematics?

PostPosted: Wed Feb 08, 2017 02:41
by ExeterDad
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>

A winning answer there! Thanks paramat!
I was pondering how to edit a .mts file last week and have had great interest in this thread.

Re: how can I edit schematics?

PostPosted: Wed Feb 08, 2017 04:45
by TumeniNodes
> I think if you are patient, use of .mts schematics may eventually be phased out.

This is funny, as if they are seriously flawed in some way. They are very well coded by hmmmm and work very well.
They are like small bits of world database since they have content ID, param1 (prob) and param2 (various uses).

Never used the term "flawed". I prob should have given the answer I first thought to give which was "I don't know", because I don't (or didn't know until now why use of .mts was chosen) So, foot in mouth for me.
It was not a hack of any sort towards hmmmm's work in anyway. I hope it would not be viewed that way.

I have yet to even get into making schematics for trees or anything else, I am still working on how I want the trees I'm working on to look.

I figured, "if" using a binary file such as .mts "was" an issue, "maybe" it would eventually be replaced down the rd. I should have known better than to speak outside of my tech zone.

So, a really dumb question then... is there some means to create a script which could be used to edit .mts schematics? The same as for mapgens? In order to make it a bit easier for not so technically skilled individuals?
Or is it it impossible, or simply best to just follow the documentation provided.

Re: how can I edit schematics?

PostPosted: Wed Feb 08, 2017 04:54
by TumeniNodes
nevermind, I will study up on the saveschems mod

Re: how can I edit schematics?

PostPosted: Wed Feb 08, 2017 12:17
by burli
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.

Is there a difference in performance between binary and lua schematics? I assumed that there is a difference while loading, but once the schematic is in memory there should be no difference

Re: how can I edit schematics?

PostPosted: Wed Feb 08, 2017 18:16
by paramat
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:

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

Re: how can I edit schematics?

PostPosted: Thu Feb 09, 2017 02:06
by TumeniNodes
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:

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


cool : )

Re: how can I edit schematics?

PostPosted: Thu Feb 09, 2017 05:40
by burli
Thanks paramat

Re: how can I edit schematics?

PostPosted: Sat Apr 01, 2017 03:48
by Sokomine
If you want to edit a .mts file manually, just load it in your world. WorldEdit has //mtschemplace filename.mts, and my handle_schematics mod even offers a backup of the old landscape and rotates the schematic the same way you place the build chest.

The binary format is quite practical, small and handy. It is documented well and can be read easily. If you want to, you can convert it to another format. What would you consider more practical anyway?