[Solved] Modifying and using schematics

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

[Solved] Modifying and using schematics

by Wuzzy » Post

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.

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

Re: Modifying and using schematics

by burli » Post

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: 2146
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: Modifying and using schematics

by sofar » Post

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: 604
Joined: Sun Sep 04, 2016 15:15
GitHub: bell07

Re: Modifying and using schematics

by bell07 » Post

handle_schematics does have working mts parser written in lua. https://github.com/Sokomine/handle_sche ... s_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-sche ... matics.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: 4804
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: Modifying and using schematics

by Wuzzy » Post

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?

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

Re: Modifying and using schematics

by sofar » Post

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: 4804
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: Modifying and using schematics

by Wuzzy » Post

OK, thanks for the help so far.

Sokomine
Member
Posts: 4290
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

Re: Modifying and using schematics

by Sokomine » Post

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: 1709
Joined: Wed Jan 14, 2015 07:34
In-game: Red_Fox
Location: Xanadu

Re: Modifying and using schematics

by firefox » Post

and the big question is:

where is the documentation to lua tables?
i need it to create trees for my subgame...
✨🏳️‍🌈♣️✨

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

Re: Modifying and using schematics

by Wuzzy » Post


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

Re: Modifying and using schematics

by firefox » Post

meow?

and how do you use 'that' to make tree models?
(with random height and branches and stuff)
✨🏳️‍🌈♣️✨

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

Re: Modifying and using schematics

by paramat » Post

Lua_api.txt https://github.com/minetest/minetest/bl ... .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: 1709
Joined: Wed Jan 14, 2015 07:34
In-game: Red_Fox
Location: Xanadu

Re: Modifying and using schematics

by firefox » Post

paramat wrote:Lua_api.txt https://github.com/minetest/minetest/bl ... .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?
✨🏳️‍🌈♣️✨

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

Re: Modifying and using schematics

by Casimir » Post

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: 3700
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

Re: Modifying and using schematics

by paramat » Post

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: 2943
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes
Location: in the dark recesses of the mind
Contact:

Re: Modifying and using schematics

by TumeniNodes » Post

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
A Wonderful World

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests