Page 1 of 1

[Mod] Convert table schematic to .mts [0.2.0] [saveschems]

PostPosted: Wed Apr 29, 2015 19:34
by paramat
For Minetest 0.4.13 and later
Depends default
Licenses: Code WTFPL. Schematics CC BY-SA

Download https://github.com/paramat/saveschems/archive/master.zip rename to 'saveschems'
Code https://github.com/paramat/saveschems

Example of how to use the recently added 'minetest.serialize_schematic' function to convert a lua-table defined schematic to a .mts file saved in a mod folder.
Create your schematic in lua table form, edit the names used in the code below the table, then just run the mod in any world, when the mod loads at game startup the .mts files are written to the schematics folder.

If using globally force-placed schematics you will often need to make sure air nodes are not force-placed, otherwise they will eat chunks out of the terrain, do this by using "air" with prob1 = 0 (probability zero).

This uses the recently added 'per-node force-place' feature of Minetest schematic format v4. This is used for tree trunk nodes so they replace the leaves of any other close trees they pass through, without the tree's leaves also being force-placed and replacing trunk nodes of any other close trees. Until now close-packed trees would inevitably have chopped trunks.

The lua tables have been simplified by removing any optional parameters that have these default values:
param2 = 0 (normal rotation).
force_place = false.

The format of the lua tables is:
Vertical slices of the structure in order of increasing z (here labelled -2, -1, 0, 1, 2), composed of ..
Horizontal lines of nodes in order of increasing y, composed of ..
Nodes in order of increasing x.

Re: [Mod] Convert table schematic to .mts [0.1.1] [saveschem

PostPosted: Thu Apr 30, 2015 03:55
by philipbenr
Nice and looks pretty simple

Re: [Mod] Convert table schematic to .mts [0.1.1] [saveschem

PostPosted: Thu Apr 30, 2015 09:09
by TenPlus1
Thanks Paramat, this'll save me 17kb for a banana tree... lol

Re: [Mod] Convert table schematic to .mts [0.1.2] [saveschem

PostPosted: Tue May 05, 2015 23:39
by paramat
Updated.
When using force-placed schematics you will often need to make sure air nodes are not force-placed, otherwise they will eat chunks out of the terrain, do this by using "air" with param1 = 0 (probability zero).
Previously in 0.1.1 i was using "ignore" nodes to do this but this is no longer possible.

Centre slice of appletree as an example:
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
         -- 0

         {name="air", param1=0, param2=0},
         {name="air", param1=0, param2=0},
         {name="default:tree", param1=255, param2=0},
         {name="air", param1=0, param2=0},
         {name="air", param1=0, param2=0},

         {name="air", param1=0, param2=0},
         {name="air", param1=0, param2=0},
         {name="default:tree", param1=255, param2=0},
         {name="air", param1=0, param2=0},
         {name="air", param1=0, param2=0},

         {name="air", param1=0, param2=0},
         {name="air", param1=0, param2=0},
         {name="default:tree", param1=255, param2=0},
         {name="air", param1=0, param2=0},
         {name="air", param1=0, param2=0},

         {name="air", param1=0, param2=0},
         {name="air", param1=0, param2=0},
         {name="default:tree", param1=255, param2=0},
         {name="air", param1=0, param2=0},
         {name="air", param1=0, param2=0},

         {name="default:leaves", param1=255, param2=0},
         {name="default:tree", param1=191, param2=16},
         {name="default:tree", param1=255, param2=0},
         {name="default:tree", param1=191, param2=12},
         {name="default:leaves", param1=255, param2=0},

         {name="default:leaves", param1=223, param2=0},
         {name="default:leaves", param1=255, param2=0},
         {name="default:tree", param1=191, param2=0},
         {name="default:leaves", param1=255, param2=0},
         {name="default:leaves", param1=223, param2=0},

         {name="air", param1=0, param2=0},
         {name="default:leaves", param1=223, param2=0},
         {name="default:leaves", param1=255, param2=0},
         {name="default:leaves", param1=223, param2=0},
         {name="air", param1=0, param2=0},

Re: [Mod] Convert table schematic to .mts [0.1.3] [saveschem

PostPosted: Mon May 18, 2015 04:20
by paramat
Version 0.1.3 uses the recently added 'per-node force-place' feature of Minetest schematic format v4. This is used for tree trunk nodes so they replace the leaves of any other close trees they pass through, without the tree's leaves also being force-placed and replacing trunk nodes of any other close trees. Until now close-packed trees would inevitably have chopped trunks.
Note 'param1' can now be replaced by 'prob', both are supported.
The lua tables have been sinplified by removing any optional parameters that have these default values:
param2 = 0 (normal rotation).
force_place = false.

See https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L781 from line 781
and https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L2201 from line 2201

Re: [Mod] Convert table schematic to .mts [0.2.0] [saveschem

PostPosted: Sat Sep 05, 2015 05:19
by paramat
Version 0.2.0
Updated to match the 10 schematics used in latest Minetest Game, including the second set of tree schematics that grow from saplings, these do not have force-placed trunks to preserve valuable player-placed nodes, per-node force-place is used only to replace the sapling.