MTS Editor

bigolbug
New member
Posts: 7
Joined: Fri Sep 04, 2020 20:52
GitHub: bigolbug

Re: MTS Editor

by bigolbug » Post

This looks amazing, thank you for all of the effort you have put into this program. I am running MTSedit on Windows 10. How do I import a minecraft schematic? When I search through my files using mtsedit load screen, the only file type that shows up is .mts files. I don't see any of my .schematic files.
cdb_184073c1b234

bzt
Member
Posts: 217
Joined: Tue Sep 24, 2019 14:26

Re: MTS Editor

by bzt » Post

Thank you for the feedback!
bigolbug wrote:
Wed Jun 09, 2021 18:33
This looks amazing, thank you for all of the effort you have put into this program.
You're welcome!
bigolbug wrote:
Wed Jun 09, 2021 18:33
I am running MTSedit on Windows 10. How do I import a minecraft schematic?
From command line you can convert anything, like

Code: Select all

mtsedit.exe something.schematic something.mts
Specifying only one file also opens them in the editor correctly (that's how I use mtsedit, I've added file extension assignments so that I can open schems from File Explorer with a single click):

Code: Select all

mtsedit.exe something.schematic
bigolbug wrote:
Wed Jun 09, 2021 18:33
When I search through my files using mtsedit load screen, the only file type that shows up is .mts files. I don't see any of my .schematic files.
I've checked and I can confirm there's an issue with the file listing, it does not list all the supported file formats, I'll look into that. Thanks for letting me know! I'll fix ASAP. BTW, I reply to gitlab issues more rapidly, sorry for the delay.

Cheers,
bzt

bzt
Member
Posts: 217
Joined: Tue Sep 24, 2019 14:26

Re: MTS Editor

by bzt » Post

Ok, it should work now, please give it a try!

Cheers,
bzt

Lulgius
New member
Posts: 7
Joined: Wed Feb 27, 2019 09:21

Re: MTS Editor

by Lulgius » Post

Hi bzt !
I would like to install your program, but I think I'm too stupid, I'm stuck at the installation stage ^^"
I'm reading your tutorial to install it on Windows and I'm stuck at the "click on "Files types" tab" step. Now, in Folder options I have nothing called "Files types". I am on Windows 10, where could I have made a wrong manipulation? :/
Edit : Also, I'm French, so maybe there is difference between our translations.

Lulgius
New member
Posts: 7
Joined: Wed Feb 27, 2019 09:21

Re: MTS Editor

by Lulgius » Post

Here a screenshot of my folder option menu : https://ibb.co/FK8cMmV

bzt
Member
Posts: 217
Joined: Tue Sep 24, 2019 14:26

Re: MTS Editor

by bzt » Post

Ok, that's strictly speaking isn't installation.

To install, all you need is unzipping, nothing else. What's described there is a convenience function to open schematic files with the File Explorer (it will put MTSEdit in the right-click menu for schems). At least that's how it worked with WinXP, Vista, 7 and 8 (see this official MS answer). I'm not familiar with Win10, but this or this might help if the method changed since. Just google "win10 assign program to file type".

Alternatively you can forget about file type associations altogether, just drop the MTSEdit.lnk in the zip to your desktop (or under your Start Menu folder) and use that, leaving File Explorer entirely out.

Cheers,
bzt

Lulgius
New member
Posts: 7
Joined: Wed Feb 27, 2019 09:21

Re: Help

by Lulgius » Post

Oh right! I thought what a moron! On the other hand, I extracted the zip file from the windows version, I double click on the .exe, but nothing happens. The interface does not open.
I saw in the comments that someone had reported this problem:
avyukt wrote:
Mon Nov 16, 2020 13:47
You should specify the MTS file on the command line, like

Code: Select all

MTSEdit.exe something.mts
or you can click on the "Load" icon and browse the file system to select the file (if you specify a directory on the command line, then the GUI starts with the Open Schematics dialog). See usage manual.

Importing foreign formats just works, you can load many different schematics file. See import formats.

With the command line converter, you can specify additional parameters for converting, you can generate node palettes, blueprint pngs, preview pngs, etc. See batch mode.

Cheers,
bzt
I tried your solution of running mtsedit.exe or SDL2.ddl but the interface still does not open. Is this normal?

bzt
Member
Posts: 217
Joined: Tue Sep 24, 2019 14:26

Re: Help

by bzt » Post

Lulgius wrote:
Fri Jun 18, 2021 10:11
Oh right! I thought what a moron! On the other hand, I extracted the zip file from the windows version, I double click on the .exe, but nothing happens. The interface does not open.
Yes, this is the expected behaviour. MTSEdit is a command line conversion tool primarily, so you should execute it from cmd.exe. That's why I've said to you to use the MTSEdit.lnk on your desktop, because if you right-click on it and check its properties, you'll see that it executes "mtsedit.exe C:\" (there's a directory argument), so it will start the interface.

I've tried to explain this in the usage manual
Without an argument, or with -h it prints an usage to stdout.
...
If you start MTSEdit with a single parameter, being an MTS file's path, it will open it in the GUI editor.
If that parameter is a directory, then MTSEdit will start with the "Load Schematic from File" screen.
Yeah, seems problematic at first, but I cannot help that because you must be able to call MTSEdit from .bat or .sh files too, so it cannot start the interface right away. This isn't a problem on Linux, but under Windows you must compile the program to either be a console application or a GUI application, and you cannot choose at run-time. Yet another epic design failure in Win, use Linux ;-)

Cheers,
bzt

Lulgius
New member
Posts: 7
Joined: Wed Feb 27, 2019 09:21

Re: Help

by Lulgius » Post

bzt wrote:
Fri Jun 18, 2021 18:35
Yet another epic design failure in Win, use Linux ;-)

Cheers,
bzt
I agree that Windows has problems, but I can't change my OS. I need this software to make an animation in the media library where I work. I can't ask the IT department to migrate all the PCs to Linux.

Lulgius
New member
Posts: 7
Joined: Wed Feb 27, 2019 09:21

Re: Help

by Lulgius » Post

bzt wrote:
Fri Jun 18, 2021 18:35
Lulgius wrote:
Fri Jun 18, 2021 10:11
Oh right! I thought what a moron! On the other hand, I extracted the zip file from the windows version, I double click on the .exe, but nothing happens. The interface does not open.
Yes, this is the expected behaviour. MTSEdit is a command line conversion tool primarily, so you should execute it from cmd.exe. That's why I've said to you to use the MTSEdit.lnk on your desktop, because if you right-click on it and check its properties, you'll see that it executes "mtsedit.exe C:\" (there's a directory argument), so it will start the interface.

I've tried to explain this in the usage manual
Without an argument, or with -h it prints an usage to stdout.
...
If you start MTSEdit with a single parameter, being an MTS file's path, it will open it in the GUI editor.
If that parameter is a directory, then MTSEdit will start with the "Load Schematic from File" screen.
Yeah, seems problematic at first, but I cannot help that because you must be able to call MTSEdit from .bat or .sh files too, so it cannot start the interface right away. This isn't a problem on Linux, but under Windows you must compile the program to either be a console application or a GUI application, and you cannot choose at run-time. Yet another epic design failure in Win, use Linux ;-)

Cheers,
bzt
Okay, finally I understood how to open the interface. Right click on the SDL2.ddl file, then click on "Open with". There, click on "choose an application", then on "show applications", scroll down to the bottom and click on "Find another application on this PC". In the file explorer, look for the file mtsedit.exe, click on it and then on open. The GUI should open.

bzt
Member
Posts: 217
Joined: Tue Sep 24, 2019 14:26

Re: Help

by bzt » Post

Lulgius wrote:
Tue Jun 22, 2021 12:24
Okay, finally I understood how to open the interface. Right click on the SDL2.ddl file, then click on "Open with". There, click on "choose an application", then on "show applications", scroll down to the bottom and click on "Find another application on this PC". In the file explorer, look for the file mtsedit.exe, click on it and then on open. The GUI should open.
That's absolutely amazing, you literally got everything WRONG. Sorry, no offense, but seeing such an incompetence makes me ask, are you just trolling?

First of all, unpack the zip to "C:\Program Files (x86)", then

Method 1: in the "C:\Program Files (x86)\MTSEdit" directory, click on MTSEdit.lnk (not on the .exe, but on the .lnk, that's the one with the MTSEdit icon and a little curly arrow with white background on its corner)

Method 2: optionally assign .mts extension with mtsedit.exe, and then you'll be able to open .mts files from File Explorer's right-click menu

If anything of the above isn't clear, then I'd suggest to take a beginner's course on Windows or ask for help from a local IT guy.

Cheers,
bzt
Attachments
mtsedit.png
mtsedit.png (8.94 KiB) Viewed 3181 times

Lulgius
New member
Posts: 7
Joined: Wed Feb 27, 2019 09:21

Re: Help

by Lulgius » Post

bzt wrote:
Wed Jun 23, 2021 08:02
Lulgius wrote:
Tue Jun 22, 2021 12:24
Okay, finally I understood how to open the interface. Right click on the SDL2.ddl file, then click on "Open with". There, click on "choose an application", then on "show applications", scroll down to the bottom and click on "Find another application on this PC". In the file explorer, look for the file mtsedit.exe, click on it and then on open. The GUI should open.
That's absolutely amazing, you literally got everything WRONG. Sorry, no offense, but seeing such an incompetence makes me ask, are you just trolling?

First of all, unpack the zip to "C:\Program Files (x86)", then

Method 1: in the "C:\Program Files (x86)\MTSEdit" directory, click on MTSEdit.lnk (not on the .exe, but on the .lnk, that's the one with the MTSEdit icon and a little curly arrow with white background on its corner)

Method 2: optionally assign .mts extension with mtsedit.exe, and then you'll be able to open .mts files from File Explorer's right-click menu

If anything of the above isn't clear, then I'd suggest to take a beginner's course on Windows or ask for help from a local IT guy.

Cheers,
bzt
Okay I just figured out why it wasn't working when I was doing this method. When you extract the files from the .zip, the file creates an extra folder for you called "mtsedit-master" (EDIT : I confused with the other folder file, I meant mtsedit-i686-win folder not mtsedit-master folder). I moved the .inkl file but when I clicked on it, an error message said "C:/program files (x86)/MTSEdit\mtsedit.exe The specified path does not exist". Indeed, if you move the "MTSEdit" folder to program filesx86, the .inkl file does its job and everything works. I would like to point out that my method also worked (but indeed it's not the better) and it is still valid if you want to open .mts files with MTSedit.
I'm really sorry to have annoyed you so much. Now, I just want to remind you that English is not my first language at all and I am not a computer expert. I'm just a guy who understands a couple of things and would just like to set up an animation to teach 3D modeling for kids. I don't mind that my problem was really stupid (and maybe I was too), but that doesn't justify calling me incompetent or a troll.
Anyway, apart from that your software is great and it's exactly what I was looking for. It will help me a lot. It's great that you did all this for free. I really thank you for the tool you made.
Last edited by Lulgius on Wed Jun 23, 2021 18:33, edited 1 time in total.

bzt
Member
Posts: 217
Joined: Tue Sep 24, 2019 14:26

Re: Help

by bzt » Post

Lulgius wrote:
Wed Jun 23, 2021 12:35
Okay I just figured out why it wasn't working when I was doing this method. When you extract the files from the .zip, the file creates an extra folder for you called "mtsedit-master".
No, you haven't followed the instructions at all, and that's why you have downloaded the source, not the distribution (full disclosure, you can install it from source too, but with your skills I would not recommend that).



Please try to follow the steps in the README under section "Installation":
Under Windows

1. download mtsedit-i686-win.zip
2. unpack it into "C:\Program Files (x86)"
3. copy "C:\Program Files (x86)\MTSEdit\MTSEdit.lnk" to your desktop or into your menu directory (whereever you like)
You see, there's a link at the first step on the file that you have to download, and it is called "mtsedit-i686-win.zip", and not "mtsedit-master.zip", that's a totally and completely different file. I have absolutely no clue how could you miss that and download the repository source tarball instead.


Lulgius wrote:
Wed Jun 23, 2021 12:35
I moved the .inkl file but when I clicked on it, an error message said "C:/program files (x86)/MTSEdit\mtsedit.exe The specified path does not exist". Indeed, if you move the "MTSEdit" folder to program filesx86, the .inkl file does its job and everything works.
It is not ".inkl" but ".lnk", and yes, it contains an absolute path to the default application's folder. If you put MTSEdit to a different location, then you have to modify the path in the .lnk file, that's how Windows shortcuts work.
Lulgius wrote:
Wed Jun 23, 2021 12:35
I would like to point out that my method also worked (but indeed it's not the better) and it is still valid if you want to open .mts files with MTSedit.
I highly doubt that. Even if your assignment was successful, you have assigned MTSEdit to SDL2.dll (and that's ".dll", not ".ddl") and not to an .mts file as you should.
Lulgius wrote:
Wed Jun 23, 2021 12:35
I'm really sorry to have annoyed you so much.
You did not annoyed me at all, if anything I feel sorry. If I were annoyed, you wouldn't get replies and I wouldn't keep trying to explain things to you.
Lulgius wrote:
Wed Jun 23, 2021 12:35
Now, I just want to remind you that English is not my first language at all and I am not a computer expert. I'm just a guy who understands a couple of things and would just like to set up an animation to teach 3D modeling for kids. I don't mind that my problem was really stupid (and maybe I was too), but that doesn't justify calling me incompetent or a troll.
This has nothing to do with your English or computer skills. You failed to follow the simplest instructions, constantly clicking on the wrong links and files (where did you read "SDL2.dll" in the first place? I did not mention that; not in the installation instruction, and neither in my posts, yet you were keep clicking on it for some unknown reason.)
Lulgius wrote:
Wed Jun 23, 2021 12:35
Anyway, apart from that your software is great and it's exactly what I was looking for. It will help me a lot. It's great that you did all this for free. I really thank you for the tool you made.
Thanks, and you're welcome, and I'm glad that finally you had sorted it out! Enjoy! Feel free to ask anything, just please keep in mind you're not a computer expert, so follow the instructions letter by letter instead of going rouge, and try to copy'n'paste filenames precisely, because that matters.

Cheers,
bzt

User avatar
Extex
Member
Posts: 244
Joined: Wed Mar 14, 2018 23:14
GitHub: Extex101
In-game: Extex

Re: MTS Editor

by Extex » Post

Getting this error with the mod when trying to use /mtsedit imgs

Code: Select all

AsyncErr: Lua: Runtime error from mod 'mtsedit' in callback on_chat_message(): ...inetest-5.6.0-d400a98-win64\bin\..\mods\mtsedit\init.lua:287: attempt to concatenate a nil value
stack traceback:
	...inetest-5.6.0-d400a98-win64\bin\..\mods\mtsedit\init.lua:287: in function 'func'
	...inetest-5.6.0-d400a98-win64\bin\..\builtin\game\chat.lua:79: in function <...inetest-5.6.0-d400a98-win64\bin\..\builtin\game\chat.lua:52>
	...est-5.6.0-d400a98-win64\bin\..\builtin\game\register.lua:429: in function <...est-5.6.0-d400a98-win64\bin\..\builtin\game\register.lua:415>
Creator of jelys_pizzaria and motorbike, and player of persistent kingdoms. RIP

bzt
Member
Posts: 217
Joined: Tue Sep 24, 2019 14:26

Re: MTS Editor

by bzt » Post

Hi,

Thank for your feedback! Sorry about the delay, you should have used gitlab issues and I'd have answered much sooner. I don't check this forum that often.

First, I'm unable to reproduce your error, using latest MTG, MCL2 nor MCL5. I have the latest 5.6.1-2 MTE that my distro ships (5.7.0 is not in my distro's repo yet).

Second, your error message says:

Code: Select all

mods\mtsedit\init.lua:287: attempt to concatenate a nil value
Now the code is like

Code: Select all

284            if (t["mod_origin"] == nil or t["mod_origin"] == "") then
285                file:write(",")
286            else
287                file:write(","..string.format("%q", minetest.get_modpath(t["mod_origin"])..""))
288            end
Because t["mod_origin"]) is checked against being a nil, so that can't be. The other concatenation is between a constant, not nil by definition, and a string returned by string.format. I can't see how that latter could be nil either. Which leads us to minetest.get_modpath isn't working?

Please change the code and copy'n'paste the error message again to get more info on the situation:

Code: Select all

            else
                print("mod", t["mod_origin"])
                print("modpath", minetest.get_modpath(t["mod_origin"]))
                print("quoted", string.format("%q", minetest.get_modpath(t["mod_origin"])..""))
                file:write(","..string.format("%q", minetest.get_modpath(t["mod_origin"])..""))
            end
I'll be able to tell more once you provided the output of this.

Cheers,
bzt

EDIT: I've added an extra check if get_modpath returns nil to avoid crash, however this isn't a solution really just a workaround because when this happens there'll be no image paths in the output which are required to get the texture files in MTSEdit.

User avatar
Extex
Member
Posts: 244
Joined: Wed Mar 14, 2018 23:14
GitHub: Extex101
In-game: Extex

Re: MTS Editor

by Extex » Post

bzt wrote:
Fri Apr 28, 2023 12:59
First, I'm unable to reproduce your error, using latest MTG, MCL2 nor MCL5. I have the latest 5.6.1-2 MTE that my distro ships (5.7.0 is not in my distro's repo yet).
Extex wrote:
Tue Apr 18, 2023 00:36

Code: Select all

minetest-5.6.0-d400a98-win64\bin\..\mods\mtsedit\init.lua:287[/quote]

Realized I was still using an old pre-release 5.6. I updated and I'm no longer getting the crash.
So it's working now. But the documentation is somewhat confusing as to how to import the textures so I can't figure it out.
Creator of jelys_pizzaria and motorbike, and player of persistent kingdoms. RIP

bzt
Member
Posts: 217
Joined: Tue Sep 24, 2019 14:26

Re: MTS Editor

by bzt » Post

Extex wrote:So it's working now.
Well done, glad to hear! I won't remove the extra check though, it won't hurt having that.
Extex wrote:But the documentation is somewhat confusing as to how to import the textures so I can't figure it out.
Probably that's because you can't import textures :-)

In short, MTSEdit works with pre-rendered block images (see here), and that's it. It does not need nor use textures at all. Such a pre-rendered block image for example:
Image

The advantage of this approach is that you can use this editor with whatever block types you want, with whatever Minetest mods you wish. The downside is, you'll have to create these block images for missing nodes (FYI, MTSEdit works even if the block images are missing, it loads / saves .mts files correctly etc, it's just on the GUI all nodes will look the same, with a "no image" image).

You can use GIMP for example to draw these block images (or grab from an inventory screenshot etc.), but MTSEdit is also capable of generating these provided it has the corresponding Minetest data. For that latter, you have to do two steps:
1. within the game (when all your desired mods are enabled), you issue /mtsedit imgs. This will save blockimgs.csv file with all the necessary data for all the available nodes.
2. then, outside of the game, you load this data using mtsedit -t blockimgs.csv.

The second step will read in all the node types from the saved data file, it will locate the textures and generate the block images. It also generates slabs and stair variants if applicable. Because this could possibly mean generating more thousand image files, might take a while.

If you know which node is missing, then you can add its name to the command line, like mtsedit -t blockimgs.csv node_name (peek into the csv file with Notepad to see what node names are saved there). In this case only the block images for that node will generated, which is much faster than generating all the block images all the time.

Cheers,
bzt

ps: if there's a way to save the block images directly from the game (looking the same as in the inventory for example), then I would gladly remove this entire feature. The only reason why I come up with the blockimgs.csv workaround because I couldn't figure out how to save nodes as pre-rendered PNG files using the Lua API.

ShadMOrdre
Member
Posts: 1118
Joined: Mon Dec 29, 2014 08:07
Location: USA

Re: MTS Editor

by ShadMOrdre » Post

@bzt,

Why not use the

Code: Select all

minetest.encode_png
function to grab the front, right, and top tiles, apply the correct skew to the images, merge them as a single image, and encode as a png?

I don't see why a function of this nature couldn't also easily be added to builtin, to provide to modders.

Using an inventory cube image has been wanted by many for quite a while now.... :)


Shad

User avatar
LMD
Member
Posts: 1386
Joined: Sat Apr 08, 2017 08:16
GitHub: appgurueu
IRC: appguru[eu]
In-game: LMD
Location: Germany
Contact:

Re: MTS Editor

by LMD » Post

minetest.encode_png sadly isn't this powerful. All it does is dump a bunch of ARGB8 values in a file in PNG format, that's it. It's trivial to implement in Lua yourself.
My stuff: Projects - Mods - Website

bzt
Member
Posts: 217
Joined: Tue Sep 24, 2019 14:26

Re: MTS Editor

by bzt » Post

ShadMOrdre wrote:
Mon May 01, 2023 21:49
@bzt,

Why not use the

Code: Select all

minetest.encode_png
function to grab the front, right, and top tiles, apply the correct skew to the images, merge them as a single image, and encode as a png?
Maybe I wasn't clear when I said "pre-rendered PNG". The emphasis is on "pre-rendered", and not on the PNG part, that latter is solved in Lua by the function you mentioned just fine. And as @LMD pointed out, that's all it does.

The problematic part is getting the pixelbuffer with the node (inventory cube view). It's not just applying a skew, think about slabs and stairs for example, not to mention the shading and different rotations if the node isn't symmetric.

The reason why the C++ code in MTE can get away with this complexity when displaying the inventory is because that has all the necessary data, the textures and the vertices in GPU memory already and just uses an orthogonal projection matrix and lets the GPU do the heavy lifting. Something that the engine is capable of, but you can't access from Lua ATM.
ShadMOrdre wrote:
Mon May 01, 2023 21:49
I don't see why a function of this nature couldn't also easily be added to builtin, to provide to modders.

Using an inventory cube image has been wanted by many for quite a while now.... :)


Shad
I agree, it would be really great to have such a Lua function! I wouldn't mind if it just renders to an off-screen buffer, because I could call encode_png on that easily. Just having a function that generates a "inventory view" of a single node with the given rotation would be huge!

Cheers,
bzt

User avatar
LMD
Member
Posts: 1386
Joined: Sat Apr 08, 2017 08:16
GitHub: appgurueu
IRC: appguru[eu]
In-game: LMD
Location: Germany
Contact:

Re: MTS Editor

by LMD » Post

For my online_craftguide mod, I solved this by writing a CSM to render these images to texture. This relied on a misc stuff PR, which I then split into store_texture, get_item_defs and a texture modifier / "speedup" PR. All of the PRs are now closed (and would probably have significant merge conflicts now).

modlib on the other hand has been continuously growing, to the point where it can read textures and models. It shouldn't be too difficult to use modlib to render these in plain software (pure Lua even), but it would require significant work (probably at least 1kloc I'd estimate), and I just don't want to sink my time into this now (or ever).
My stuff: Projects - Mods - Website

bzt
Member
Posts: 217
Joined: Tue Sep 24, 2019 14:26

Re: MTS Editor

by bzt » Post

LMD wrote:
Tue May 02, 2023 17:55
It shouldn't be too difficult to use modlib to render these in plain software
Yes, but one of the main goal is to be dependency-free (so it can only use the provided Lua API, nothing else).

On a different note, I've seen your own schem format in modlib, but wasn't able to find its specification. I believe that supposed to be here, just unfinished as of now?

I'd really like to add support for that format to MTSEdit, because it seems to have everything that .mts lacks (FYI, I've proposed to add support for metadata in .mts files, no luck unfortunately). My only question is, why does it have baked light data? That makes no sense, because you can place schematics in different parts of the world (with different lighting environments). Also by changing the node mapping (like MCL or MTG nodes) the light parameters could change too.

Anyway, are you planning to finish that spec?

Cheers,
bzt

User avatar
LMD
Member
Posts: 1386
Joined: Sat Apr 08, 2017 08:16
GitHub: appgurueu
IRC: appguru[eu]
In-game: LMD
Location: Germany
Contact:

Re: MTS Editor

by LMD » Post

My only question is, why does it have baked light data? That makes no sense, because you can place schematics in different parts of the world (with different lighting environments).
Baked light data is optional and off by default; I push the responsibility of deciding whether it's useful onto the user :)

The idea was to avoid having to call VoxelManip:calc_lighting, using precalculated "baked" light data and supplying it using VoxelManip:set_lighting instead. Consider it a premature optimization (I never benchmarked it). Note that for some special cases (say full light for all nodes), the baked light data will also compress very well through deflate's run-length encoding.

For the use cases I had in mind, the node mapping would have been static, so the light parameters of nodes changing wouldn't have been an issue; the environment wouldn't have been an issue either, since it would always be the same - this was intended for something like CTF, where you place schematics of maps.

As far as MTSEdit is concerned, you can probably ignore baked light data.

I've now added proper documentation of the schematic format (and cleaned it up, fixing an off by one error).
My stuff: Projects - Mods - Website

bzt
Member
Posts: 217
Joined: Tue Sep 24, 2019 14:26

Re: MTS Editor

by bzt » Post

LMD wrote:
Thu Jun 01, 2023 11:37
...this was intended for something like CTF, where you place schematics of maps.
Ah, I see, that makes perfect sense. I was thinking about structures that you place multiple times on the map at different positions. Since baked light is optional, this is great!
LMD wrote:
Thu Jun 01, 2023 11:37
I've now added proper documentation of the schematic format (and cleaned it up, fixing an off by one error).
Which is a great, but I was asking for a file format specification not an API documentation (totally useless to me as MTSEdit is implemented in C, not in Lua).

A specification does not have any function call reference in it, just a plain simple description of every single byte in the file. For example, b3d file format specification (uses C struct-like explanation of the byte layout), obj file format specification (makes it clear that this is a line based text format and then lists all possible line variants), or zlib format specification (using ASCII "graphics" and figures to explain the meaning of each byte and bits).

Ideally what I would like to see in case of a binary file spec is a list of "position + size + explanation" triplets that describe all bytes one after another in the file, like the vox file format specification or the mts file format specification or the m3d voxel format (extract from the full specification, focusing on storing voxels).

For now, all that your schematic.md says about the bytes in the file goes like this:
The binary format uses modlib's Bluon to write the table format.
Which tells me absolutely nothing. At least a link to what bluon supposed to be would be nice. I did some detective work and found this, but again, this isn't a file format specification either rather an API documentation.

How to explain this... when you write a file format specification, you must assume that your reader can't use your lib, and yet they must implement a fully functional reader/writer relying solely on what's written in the spec. Therefore the spec must explain all bytes in the file in great detail: at a specific offset which byte means what. Does this make sense to you?

Cheers,
bzt

User avatar
LMD
Member
Posts: 1386
Joined: Sat Apr 08, 2017 08:16
GitHub: appgurueu
IRC: appguru[eu]
In-game: LMD
Location: Germany
Contact:

Re: MTS Editor

by LMD » Post

bzt wrote:
Thu Jun 01, 2023 13:21
Which is a great, but I was asking for a file format specification not an API documentation (totally useless to me as MTSEdit is implemented in C, not in Lua).
Well, it is supposed to be both, although the "specification" part is rather brief; the schematic format is simply built on top of Bluon, which is a binary representation of Lua values; describing the table format then suffices to describe the binary format.

I should probably have linked the Bluon doc.
bzt wrote:
Thu Jun 01, 2023 13:21
For now, all that your schematic.md says about the bytes in the file goes like this:
The binary format uses modlib's Bluon to write the table format.
Which tells me absolutely nothing. At least a link to what bluon supposed to be would be nice. I did some detective work and found this, but again, this isn't a file format specification either rather an API documentation.
Yes, that's the Bluon documentation. Again there is a section on the format, which is perhaps again too brief and unclear; the format is essentially very simple: Every value is represented as a one byte tag (the "type") followed by zero or more bytes encoding the value (this is what I call a "tagged union"). "Constant" tags use zero bytes after the tag; the value is already encoded in the tag. The "tags" are listed in the order in which they are assigned tag numbers (bytes). Everything is little endian. Integers are simply little endian unsigned integers, varying only in how many bytes they use (powers of two only though). These are the U(nsigned)-types. Negative numbers are represented using negative-U(nsigned)-tags followed by the unsigned value of the number. Floats are either little-endian 32-bit or 64-bit; using 64-bit floats alone would suffice, but would often be a waste of space. Strings are simply an unsigned little-endian length encoded using 1, 2, 4 or 8 bytes (depending on the length of the string) followed by the bytes of the string.
Tables are more difficult; they use 25 tags, all combinations of M0, M1, M2, M4, M8 with L0, L1, L2, L4, L8.
The order of these tags is M0L0, M0L1, ..., M0L8, ..., M1L0, ..., M1L8, ..., ..., ..., M8L8.
The M-part indicates the number of bytes used to encode the length of the hash part and the L-part indicates the number of bytes used to encode the length of the list part. Both are encoded as little endian unsigned integers.
The count of the list part is written first, the count of the map part second. Then come the elements of the list part, all Bluon-encoded, followed by the k-v-pairs of the map part, again Bluon encoded. The key comes first, the value second.

References are essentially just like unsigned integers, except they are 1-based indices referring to strings or tables that have been written/read already, in the order they have been written / read.

Perhaps (more elaborate) prose would have been a better choice than a list format...

Not sure whether ASCII art would help here. I think C-struct-like wouldn't really work too well either due to all the variable lengths involved here.
My stuff: Projects - Mods - Website

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest