[Mod] Schematic Editor [1.8.0] [schemedit]

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

Re: [Mod] Schematic Editor [1.4.3] [schemedit]

by Wuzzy » Post

What are you talking about? I don't have a Debian server, and this mod has nothing to do with textures.

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

Version 1.5.0 released!

by Wuzzy » Post

Version 1.5.0 released!

Changelog:
  • Add /listschems command to list currently saved schematics
  • Add -c switch to /placeschem to allow clearing the target area first
  • Fix typos
  • Update mod metadata
  • Proper Z-sorting for the numbers displayed in the HUD by the Schematic Node Probability Tool
  • Automatically close the slice edit panel if there are no slices

0siribix
Member
Posts: 123
Joined: Tue Nov 17, 2020 20:54
GitHub: 0siribix
In-game: 0siribix

Re: [Mod] Schematic Editor [1.5.0] [schemedit]

by 0siribix » Post

I'm truly surprised that no one else has brought up an alternative to the guys wanting to share the schems folder between mods. This doesn't need to be nor should it be supported by this mod. For linux you could use symlinks with 'ln -s' and on windows you can make directory junctions using 'mklink /j'. This would work across mods or worlds and in linux could even work across drives or even remote filesystems. In essence, folders in two locations would point to the same data.

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

Version 1.5.1 released!

by Wuzzy » Post

Version 1.5.1 released!

This is an important bugfix release. I noticed that when you export a schematic, the Y slices were exported incorrectly. The wrong Y values might be stored into the schematic. This is fixed now. The mistake was that the absolute Y coordinate was stored, rather than the relative Y offset.

This means, if you have used Y slices for your schematics before, you need to re-investigate them again. Just import them with the schematic creator and fix the Y slices by hand.

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

Re: [Mod] Schematic Editor [1.5.1] [schemedit]

by Wuzzy » Post

Effective immediately, this mod's repository was moved to Codeberg. This is the new repository URL:

https://codeberg.org/Wuzzy/minetest_schemedit

Icalasari
Member
Posts: 166
Joined: Tue Sep 23, 2014 05:29
IRC: Icalasari
In-game: Icalasari

Re: [Mod] Schematic Editor [1.5.1] [schemedit]

by Icalasari » Post

So encountered a bug. Having a 32 node tall schematic, trying to make it have a very low chance (15 for y 3, 7 for y 2, 3 for y 1, and 1 for y 0) of cutting off the bottom most slices

Except it's treating these low chances as a 100% chance

Total of 8 slices can be potentially removed. Schematic size is 21x32x21

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

Re: [Mod] Schematic Editor [1.5.1] [schemedit]

by Wuzzy » Post

Due to the way that schematic probabilities work (they are a little weird), a probability value of 1 is actually converted to 0. This mod treats probability values from the Lua perspective, not from the file perspective, i.e. the probabilities are as if you would have entered them in Lua code.

So, values 0 to 255 are used, but Minetest will convert them to 0 to 127 internally.

Please refer to lua_api.txt to learn more about schematic probabilities, and reasons.

User avatar
j0j0n4th4n
Member
Posts: 249
Joined: Tue Jan 26, 2021 06:45

Re: [Mod] Schematic Editor [1.5.1] [schemedit]

by j0j0n4th4n » Post

I wanna my schematics to be partly buried underground, is that possible?
cdb_894a100ddd76

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

Re: [Mod] Schematic Editor [1.5.1] [schemedit]

by Wuzzy » Post

Yes. In schemedit, you need to replace every node that you want to not be overwritten when placing the schematic with a schematic void.

The rest is stuff that you don't need schemedit for: You need to set force_placement to true when placing the schematic. And then I believe there is an y_offset option in the place_schematic function as well, which you need to adjust as well (read lua_api.txt for details).

AlienHunter
New member
Posts: 7
Joined: Sun Nov 07, 2021 19:25
GitHub: alienhunter3010
In-game: Alienhunter3010

Re: [Mod] Schematic Editor [1.5.1] [schemedit]

by AlienHunter » Post

Issue about blocks with inventories.

I created an house with some shelfs, bookshelfs and chests inside. No one is working.

Shelfs and bookshelfs do not trigger any dialog,

Chest is opening but the dialog is empty (look at the screenshot).

Other interactive blocks, w/o inventory, are working (eg. doors).

Thank you.
Screenshot from 2022-11-02 21-18-53.png
Screenshot from 2022-11-02 21-18-53.png (336.57 KiB) Viewed 2169 times

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

Re: [Mod] Schematic Editor [1.5.1] [schemedit]

by Wuzzy » Post

This is because schematics in Minetest do NOT include node metadata like node inventories. So mods that place such a schematic need to manually call on_construct on those nodes. This mod still works as intended, as it just works with the schematic files, and that's it. The job of this mod is to store and load the nodes, param2 values and probabilities correctly, because that's what schematics store. Metadata and on_construct is out of scope.

This mod is a schematic editor for developers first and foremost, not a schematic placement mod for players. The placement feature is only for quick testing/verification. This is by design. In Repixture, when I place the house schematics, I call on_construct on all nodes that need it, like chests and furnaces.

If you want to place a schematic correctly initialized, you need to do it in a mod.

The reason why MTG doors work is because they don't need metadata and on_construct initialization, but chests, vessels shelves and bookshelves do.

AlienHunter
New member
Posts: 7
Joined: Sun Nov 07, 2021 19:25
GitHub: alienhunter3010
In-game: Alienhunter3010

Re: [Mod] Schematic Editor [1.5.1] [schemedit]

by AlienHunter » Post

I see. Looking into the code I try to export in lua format but there are no metadata too.
Signs are also losing text.

Looking at the `minetest.serialize_schematic()` seems that there are no easy ways to solve. Thank you

User avatar
Blockhead
Member
Posts: 1602
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
IRC: Blockhead256
In-game: Blockhead Blockhead256
Location: Land Down Under
Contact:

Re: [Mod] Schematic Editor [1.5.1] [schemedit]

by Blockhead » Post

Aren't there any 'smarter' schematic formats that can serialize metadata as well? I hate to suggest making 'yet another standard' to compete with MTS and worldedit schems.. but..
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

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

Re: [Mod] Schematic Editor [1.5.1] [schemedit]

by Wuzzy » Post

MTS does not support metadata at all, so a Lua export isn't going to magically make it appear.

You don't actually need to store the metadata of chests, bookshelves, furnaces, etc. anyway. Those are initialized in on_construct. Note I think the fact that nodes need metadata to store formspecs in the first place isn't great, as they often never change afterwards (as with chests). That's why I suggested to the core devs to add static node formspecs and infotexts that are stored in the node definition itself. I don't think it is a good idea to store node metadata that are supposed to stay the same forever anyway in the schematic file.

However, where metadata does matter is with stuff like sign texts. So I see at least *some* use case for this.

In any case, I am not going to amend the MTS file format or invent a new format. This mod is exclusively working with MTS files as-is, because this is the only official schematic file format for Minetest. If you want more MTS features, this mod is the wrong place to ask for it. If the MTS file format ever gains new features, I am willing to update this mod accordingly.

The goal of this mod is allow editing of MTS files in a clean and simple fashion. This mod supports all features of the MTS file format, including node probabilities, force_place and Y slice probabilities. Any "fancy" features on top of that would be simply out of scope.

I am willing to accept suggestions WRT general usability or compability, but if it goes beyong MTS' capabilities, it is out of scope.

Personally, I think before we even consider adding metadata support to MTS (officially!), I strongly suggest to add static node formspec/infotext because it's annoying that chests must have the formspec in metadata, even if the formspec never changes.

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

Re: [Mod] Schematic Editor [1.5.1] [schemedit]

by Wuzzy » Post

If you like this mod, please nominate it for the Sammy Awards 2022. :P

viewtopic.php?f=3&t=28695

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

Re: [Mod] Schematic Editor [1.6.0] [schemedit]

by Wuzzy » Post

Version 1.6.0 is released!

Changelog:
  • Proability tool now shows the probability value in the item image if < 255 (needs a recent Minetest version)
  • Add a new border style "checkers" (similar to WorldEdit), can be activated in settings
  • Bugfix: Probability tool was confused by the use of the "force placement" checkbox
  • Bugfix: Exporting schematic failed to export nodes outside of the loaded area (this can happen if working with large schematics)

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

Version 1.7.1 released!

by Wuzzy » Post

Version 1.7.0 released!
Version 1.7.1 released!

The "/placeschem" command now supports the tilde notation, e.g. if you place a tilde before a coordinate, the placement position will be relative to your position. The tilde alone stands for the current coordinate.

Example: "/placeschem my_schematic ~ ~10 ~" will place my_schematic.mts 10 nodes above your current position.


(The tilde notation was introduced in the built-in Minetest 5.5.0 commands and thus needs Minetest 5.5.0 or later to work. See https://wiki.minetest.net/Server_commands for details.)

binshaden
Member
Posts: 48
Joined: Sat Oct 07, 2017 22:05
In-game: binshaden

Re: [Mod] Schematic Editor [1.7.1] [schemedit]

by binshaden » Post

Would you consider adding a rotation parameter to /placeschem?

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

Re: [Mod] Schematic Editor [1.7.1] [schemedit]

by Wuzzy » Post

This is a good idea, I've added it to the issue list but I'm not planning to do it soon. I'm more or less taking a break from Minetest right now.

User avatar
Neuromancer
Member
Posts: 958
Joined: Tue Jun 12, 2012 22:28
GitHub: Neuromancer56

Re: [Mod] Schematic Editor [1.7.1] [schemedit]

by Neuromancer » Post

I want to convert all the wood nodes in a schematic to stone nodes. I converted the .mts to a lua file. I can replace the nodes there but then how do I convert it back to an .mts file? Or is there a better way of doing this?

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

Re: [Mod] Schematic Editor [1.7.1] [schemedit]

by Wuzzy » Post

This is out of the scope for this mod. But there is a way to do it manually.
The MTS file format stores the node names in plain text and only once for the entire file. So if you have a hex editor, you can change the node name in the file directly. But please backup the file before you break it.
However, you also must update the 2 bytes before the node name. These two bytes say how long the node name is, stored in a 16-bit unsigned integer, big-endian.

See here for details: https://dev.minetest.net/Minetest_Schematic_File_Format

User avatar
Neuromancer
Member
Posts: 958
Joined: Tue Jun 12, 2012 22:28
GitHub: Neuromancer56

Re: [Mod] Schematic Editor [1.7.1] [schemedit]

by Neuromancer » Post

Thanks. Though I think this would be a very useful addition to your mod. The following code from here https://github.com/minetest-mods/savesc ... r/init.lua should get you 90% of the way there. I've been playing around with it for a while now but just can't figure out how to load the .lua file into the schematic parameter.

Code: Select all

local mts_save = function(name, schematic)
	local s = minetest.serialize_schematic(schematic, "mts", {})
	if not s then
		return false, S("Failed to serialize schematic.")
	end
	--local path = minetest.get_modpath("saveschems") .. "/schematics"
	--local filename = path .. "/" .. name .. ".mts"
	local schem_lua = name:gsub("%.lua$", "")  -- Remove .lua extension
	local mts_path = export_path_full .. DIR_DELIM .. schem_lua .. ".mts"
	--filename = filename:gsub("\"", "\\\""):gsub("\\", "\\\\")
	filename = mts_path
	local file, err = io.open(filename, "wb")
	if not mts_file then
		return false, S("Failed to create MTS file.")
	end
	if err == nil then
		file:write(s)
		file:flush()
		file:close()
	end
	print("Wrote: " .. filename)
end


mts_save("acacia_log", {
	size = {x = 5, y = 1, z = 1},
	data = {
		{name = "default:acacia_tree", param2 = 12, prob = 127},
		{name = "default:acacia_tree", param2 = 12},
		{name = "default:acacia_tree", param2 = 12},
		{name = "default:acacia_tree", param2 = 12},
		{name = "default:acacia_tree", param2 = 12, prob = 127},
	},
})
Last edited by Neuromancer on Sun Jul 02, 2023 02:01, edited 1 time in total.

User avatar
Neuromancer
Member
Posts: 958
Joined: Tue Jun 12, 2012 22:28
GitHub: Neuromancer56

Re: [Mod] Schematic Editor [1.7.1] [schemedit]

by Neuromancer » Post

The question when loading the .lua schematic file into a table, do I use "loadfile" "dofile" or something else? These load the .lua as code, and I'm not sure that's even necessary. But if it is, I'm thinking I would need to add a little something to get that code to execute and return a table that I could pass to the mts_save function.

Code: Select all

-- [chatcommand] Convert .lua file to MTS schematic file
minetest.register_chatcommand("lua2mts", {
	description = S("Convert .lua file to .mts schematic file"),
	privs = {server = true},
	params = S("<lua file>"),
	func = function(name, param)
		local lua_file = param

		if not lua_file then
			return false, S("No Lua file specified.")
		end

		local lua_path = export_path_full .. DIR_DELIM .. lua_file
		local load_func, err = loadfile(lua_path)--.." return(schematic)"
		if not load_func then
			return false, S("Failed to load Lua file: ") .. err
		end

		local success, schematic2 = pcall(load_func)
		if not success or type(schematic2) ~= "table" then
			return false, S("Invalid schematic data in Lua file.")
		end
		minetest.log("success:", "success:" .. tostring(success))
		logTable(schematic2)
		mts_save(lua_file, schematic2)
		--return true, S("Exported schematic to @1", mts_path)
	end,
})

User avatar
Neuromancer
Member
Posts: 958
Joined: Tue Jun 12, 2012 22:28
GitHub: Neuromancer56

Re: [Mod] Schematic Editor [1.7.1] [schemedit]

by Neuromancer » Post

I got a little bit further, I updated the mts_save function and the chatcommand "lua2mts" in the 2 posts above. I also found out that the .lua input file needs to be surrounded by a return{...} like this:

Code: Select all

return{schematic = {
	size = {x=2, y=2, z=2},
	yslice_prob = {
		{ypos=0, prob=254},
		{ypos=1, prob=254},
	},
	data = {
		{name="air", prob=254, param2=0},
		{name="air", prob=254, param2=0},
		{name="air", prob=254, param2=0},
		{name="badland:badland_leaves_2", prob=254, param2=0},
		{name="air", prob=254, param2=0},
		{name="badland:badland_tree", prob=254, param2=0},
		{name="badland:badland_leaves_2", prob=254, param2=0},
		{name="badland:badland_tree", prob=254, param2=0},
	},
}}
I still get an error:

Code: Select all

AsyncErr: Lua: Runtime error from mod 'schemedit' in callback on_chat_message(): ...es\minetest-5.7.0-win64\bin\..\builtin\common\vector.lua:374: attempt to index local 'v' (a nil value)
stack traceback:
	...es\minetest-5.7.0-win64\bin\..\builtin\common\vector.lua:374: in function <...es\minetest-5.7.0-win64\bin\..\builtin\common\vector.lua:373>
But I think it's close even though it's about as far as I think I can take it.

User avatar
Blockhead
Member
Posts: 1602
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
IRC: Blockhead256
In-game: Blockhead Blockhead256
Location: Land Down Under
Contact:

Re: [Mod] Schematic Editor [1.7.1] [schemedit]

by Blockhead » Post

Neuromancer wrote:
Sat Jul 01, 2023 21:13
The question when loading the .lua schematic file into a table, do I use "loadfile" "dofile" or something else?
You should be able to load Lua schematics, without the modification that you mention in your following post. Just use minetest.read_schematic(filename, options). You can load them from the mod directory or world directory - there are API functions to get those, too. minetest.read_schematic is the inverse of minetest.seralize_schematic.

Also, I don't think we are really on-topic for Wuzzy's mod here, so I would suggest this should go in a Modding Discussion thread.
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 17 guests