[Solved] Modifying and using schematics

User avatar
Wuzzy
Member
 
Posts: 3616
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

[Solved] Modifying and using schematics

by Wuzzy » Thu Mar 09, 2017 00:46

I feel really dumb now but I can't get started with Minetest schematics (.mts files).
There does not seem much information on the file format.

I want to modify a schematic file but I don't know how. WorldEdit can only load .we files. So how can I modify an existing schematic file or somehow load it into WorldEdit so that I can actually use it?

And finally, can I find any more documentation on schematics other than the 2 Lua API functions?
Last edited by Wuzzy on Tue Dec 05, 2017 10:25, edited 1 time in total.
My creations. I gladly accept bitcoins: 17fsUywHxeMHKG41UFfu34F1rAxZcrVoqH
 

User avatar
burli
Member
 
Posts: 1641
Joined: Fri Apr 10, 2015 13:18

Re: Modifying and using schematics

by burli » Thu Mar 09, 2017 06:37

There is no mts "editor". You have to convert mts to lua. Look at my code for an example

https://github.com/MarkuBu/minetest_mod ... e/init.lua

I would recommend to use the lua schematics cause they are more flexible to use. Take a look at this code how I use them
 

sofar
Developer
 
Posts: 2064
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: Modifying and using schematics

by sofar » Thu Mar 09, 2017 06:56

saveschems is how we do this for minetest_game's tree schematics. We use a simple lua table to describe, and "easily " edit tree shapes, and then write them as .mts. We never go from .mts to lua, although it is possible. You lose too much annotation to make it easy to work with.

https://github.com/minetest-mods/saveschems/
 

bell07
Member
 
Posts: 570
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07

Re: Modifying and using schematics

by bell07 » Thu Mar 09, 2017 16:18

handle_schematics does have working mts parser written in lua. https://github.com/Sokomine/handle_schematics/blob/master/analyze_mts_file.lua. In the file you find a store_mts_file function to save mts files too, I did not tried it.

A slightly modified version (parser only) you can find in my schemlib mod https://github.com/bell07/minetest-schemlib/blob/master/schematics.lua I'll check if I change it to minetest.serialize_schematic if I find time again for this project. Currently I did not tried the minetest.serialize_schematic() at the time.
 

User avatar
Wuzzy
Member
 
Posts: 3616
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: Modifying and using schematics

by Wuzzy » Thu Mar 09, 2017 18:50

Meh, editing trees and other schematics by text files seems awfully tedious.
I look what WorldEdit can do for me.

What do you mean with “annotation”? MTS files just look like binary gibberish to me.

Is there maybe a way to go from the WorldEdit format (.we) to schematics and vice-versa?
My creations. I gladly accept bitcoins: 17fsUywHxeMHKG41UFfu34F1rAxZcrVoqH
 

sofar
Developer
 
Posts: 2064
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: Modifying and using schematics

by sofar » Thu Mar 09, 2017 19:14

Wuzzy wrote:Meh, editing trees and other schematics by text files seems awfully tedious.
I look what WorldEdit can do for me.

What do you mean with “annotation”? MTS files just look like binary gibberish to me.

Is there maybe a way to go from the WorldEdit format (.we) to schematics and vice-versa?


MTS files can have probabilities for slices and individual nodes, as well as a force-place flag (bool). This annotation is easily lost if you don't retain it somehow.

I don't think WE schematics handle probabilities. The way we handle this in saveschems is to make easily understandable slice maps, where you can see the probabilities for nodes more easily.

That's how we can place a random amount of side branches in the apple tree schematic, and make the tree height vary:

https://github.com/minetest-mods/savesc ... t.lua#L286
https://github.com/minetest-mods/savesc ... t.lua#L319

yes, it's not the easiest format to work with, but it works well in the end and visualizes the result really well.
 

User avatar
Wuzzy
Member
 
Posts: 3616
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: Modifying and using schematics

by Wuzzy » Fri Mar 10, 2017 00:07

OK, thanks for the help so far.
My creations. I gladly accept bitcoins: 17fsUywHxeMHKG41UFfu34F1rAxZcrVoqH
 

Sokomine
Member
 
Posts: 3869
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine

Re: Modifying and using schematics

by Sokomine » Wed Apr 05, 2017 04:01

Wuzzy wrote:Meh, editing trees and other schematics by text files seems awfully tedious.
I look what WorldEdit can do for me.

WorldEdit can place a schematic, store it, load a WorldEdit file, store that...and MT itshelf is the editor. There's no good way to handle probability that way. For that case the lua tables seem to be the easiest option. My handle_schematics mod reads .we and .mts files and uses the inbuild minetest.create_schematic(..) for creating new schematics. It is useful if you want to transfer a building from one place or world to another. In such a case it matters if all mods are installed, if the structure will fit into the landscape at the new location, if the front of the house faces in the right direction etc. With trees, there're usually less diffrent nodes to take care of, rotation will not matter, and they'll be placed randomly by mapgen anyway. WorldEdits //mtschemplace and //mtschemcreate ought to be enough for the basics.
A list of my mods can be found here.
 

User avatar
firefox
Member
 
Posts: 1489
Joined: Wed Jan 14, 2015 07:34
Location: Xanadu
In-game: Red_Fox

Re: Modifying and using schematics

by firefox » Fri Jun 02, 2017 09:00

and the big question is:

where is the documentation to lua tables?
i need it to create trees for my subgame...
building inspiration: viewtopic.php?f=3&t=15550 --- my game: viewtopic.php?f=49&t=15860 --- =(^.^)= nyan~
 

User avatar
Wuzzy
Member
 
Posts: 3616
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
 

User avatar
firefox
Member
 
Posts: 1489
Joined: Wed Jan 14, 2015 07:34
Location: Xanadu
In-game: Red_Fox

Re: Modifying and using schematics

by firefox » Fri Jun 02, 2017 13:57


meow?

and how do you use 'that' to make tree models?
(with random height and branches and stuff)
building inspiration: viewtopic.php?f=3&t=15550 --- my game: viewtopic.php?f=49&t=15860 --- =(^.^)= nyan~
 

User avatar
paramat
Developer
 
Posts: 3434
Joined: Sun Oct 28, 2012 00:05
Location: UK
GitHub: paramat
IRC: paramat

Re: Modifying and using schematics

by paramat » Sat Jun 03, 2017 19:52

Lua_api.txt https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L1111 and refer to saveschems mod for examples.
There may also be more advice in other threads in this forum.
 

User avatar
firefox
Member
 
Posts: 1489
Joined: Wed Jan 14, 2015 07:34
Location: Xanadu
In-game: Red_Fox

Re: Modifying and using schematics

by firefox » Sun Jun 04, 2017 13:58

paramat wrote:Lua_api.txt https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L1111 and refer to saveschems mod for examples.
There may also be more advice in other threads in this forum.

thanks, that helps.
now a question about "* `place_center_y`: Placement of this decoration is centered along the Y axis."
can i select a specific node or y-slice as the center or does it always choose the middle?
i mean, how can i define which part of the tree is above ground and which part is underground?
building inspiration: viewtopic.php?f=3&t=15550 --- my game: viewtopic.php?f=49&t=15860 --- =(^.^)= nyan~
 

User avatar
Casimir
Member
 
Posts: 1163
Joined: Fri Aug 03, 2012 16:59
GitHub: CasimirKaPazi

Re: Modifying and using schematics

by Casimir » Sun Jun 04, 2017 21:13

I combined the before mentioned saveschems with duanes schematic_save into Schemtools, just for the very reason that there is no such thing out there to handle schematics comfortably. Maybe it helps.

For reverence this is how a file could look like.
Code: Select all
-- Tree

local _ = {name = "air", prob = 0}
local L = {name = "default:leaves"}
local T = {name = "default:tree", force_place = true}

return = {
   yslice_prob = {
                  {ypos = 2, prob = 127},
                  {ypos = 3, prob = 127},
                  {ypos = 4, prob = 127},
   },
   size = {
      y = 10,
      x = 5,
      z = 5
   },
   data = {
_, _, _, _, _,
_, _, _, _, _,
_, _, _, _, _,
_, _, _, _, _,
_, _, _, _, _,
_, _, _, _, _,
_, _, L, _, _,
_, L, L, L, _,
_, _, L, _, _,
_, _, _, _, _,

_, _, _, _, _,
_, _, _, _, _,
_, _, _, _, _,
_, _, _, _, _,
_, _, _, _, _,
_, _, _, _, _,
_, L, L, L, _,
L, L, L, L, L,
_, L, L, L, _,
_, _, L, _, _,

_, _, T, _, _,
_, _, T, _, _,
_, _, T, _, _,
_, _, T, _, _,
_, _, T, _, _,
_, _, T, _, _,
L, L, T, L, L,
L, L, T, L, L,
L, L, L, L, L,
_, L, L, L, _,

_, _, _, _, _,
_, _, _, _, _,
_, _, _, _, _,
_, _, _, _, _,
_, _, _, _, _,
_, _, _, _, _,
_, L, L, L, _,
L, L, L, L, L,
_, L, L, L, _,
_, _, L, _, _,
_, _, _, _, _,

_, _, _, _, _,
_, _, _, _, _,
_, _, _, _, _,
_, _, _, _, _,
_, _, _, _, _,
_, _, L, _, _,
_, L, L, L, _,
_, _, L, _, _,
_, _, _, _, _,
}
}

It is easier to understand by example. Each letter is a node. I ordered them into blocks of x width and y height which gives nice sliced trough the tree - unfortunately upside down.
By default the bottom nodes are placed one node deeper than the terrain.
force_place here makes sure tree trunks are placed and not cut of by leaves of neighboring schems.
_ = {name = "air", prob = 0} makes sure no nodes are placed there. "prob" is probability (0-255).
yslice_prob removes a complete slice, the schematic then shrinks down. In this case it creates variable trunk heights.

I had to learn this all in the last days from spares documentation, form comments and some testing.
 

User avatar
paramat
Developer
 
Posts: 3434
Joined: Sun Oct 28, 2012 00:05
Location: UK
GitHub: paramat
IRC: paramat

Re: Modifying and using schematics

by paramat » Fri Jun 09, 2017 18:06

All of the previous post is correct.

> or does it always choose the middle?
i mean, how can i define which part of the tree is above ground and which part is underground?

It always chooses the middle.
What you can do is make the schematic taller than it needs to be and have some of it empty if you need a particular level to be the middle. I will be doing this with the larger jungletrees to add roots.
 

User avatar
TumeniNodes
Member
 
Posts: 2826
Joined: Fri Feb 26, 2016 19:49
Location: in the dark recesses of the mind
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes

Re: Modifying and using schematics

by TumeniNodes » Sat Jun 23, 2018 07:02

I realize this is bumping an old thread but, I had not seen this before (overlooked it).
And I just want to say...

Casimir wrote:I combined the before mentioned saveschems with duanes schematic_save into Schemtools, just for the very reason that there is no such thing out there to handle schematics comfortably. Maybe it helps.


Casimir, I love this new tool.
Very simple and easy to use/understand.
Thank you
Ich mag keine grünen Eier und Schinken, ich mag sie nicht Sam I Am
 


Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 1 guest