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

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

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

by paramat » Wed Apr 29, 2015 19:34

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.
Last edited by paramat on Sat Sep 05, 2015 05:16, edited 10 times in total.
 

User avatar
philipbenr
Member
 
Posts: 1665
Joined: Fri Jun 14, 2013 01:56
GitHub: philipbenr
IRC: philipbenr
In-game: WisdomFire or philipbenr

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

by philipbenr » Thu Apr 30, 2015 03:55

Nice and looks pretty simple
 

User avatar
TenPlus1
Member
 
Posts: 1874
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

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

by TenPlus1 » Thu Apr 30, 2015 09:09

Thanks Paramat, this'll save me 17kb for a banana tree... lol
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

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

by paramat » Tue May 05, 2015 23:39

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},
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

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

by paramat » Mon May 18, 2015 04:20

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
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

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

by paramat » Sat Sep 05, 2015 05:19

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.
 


Return to WIP Mods

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 9 guests

cron