Minetest_game: Add saveschems mod to MTG but disabled (or just the tables in .txt form)

Created on 12 Jun 2018  路  26Comments  路  Source: minetest/minetest_game

Useful for core devs and modders as a record of MTG lua table schematics.
If included as a mod disabled by default it will be usefully placed for core devs wanting to create new schematics, just enable it (by editing code, not by a setting, it's not for player use) to create the new schematic.

Documentation Mapgen

Most helpful comment

I'd agree with them being added as a text file.

All 26 comments

Not sure that this is a good idea. What do you mean by:

as a record of MTG lua table schematics

I'm not sure if the actual mod should be added, but I do think the lua tables used to create MTG schematics should be kept as documentation within MTG, or in some way clearly linked to/referenced. Otherwise we're basically treating something like an official MTG resource, but it's just a weird thing floating about that nothing points toward.

In short, this should be documentation, not a mod.

At first i thought as documentation too, but:

  • It's easier to include the whole mod than to format and update a txt file.
  • The mod itself is very useful for modders, i'm always directing modders to the one in minetest-mods.
  • When creating schematics a core dev needs to edit and run the saveschems somewhere, if it's in the repo this becomes much faster and easier to do. The first line of the mod can be 'return', comment it out to run it.
  • It's the code that creates the MTG schematics, so belongs in MTG, it just doesn't need to be run.

Anyway Ezhh please could you copy the new log schems here to be included?

Some more good reasons, realised through my experience of being the person who works wirh saveschems a lot:

  • Currently the official saveschems repo is in the minetest-mods organisation, before that it was in my account. Both are random and inconvenient places, the only place that makes sense is in the MTG repo itself where it will be safest, most accessible and findable.

  • When i create a new schematic for MTG, afterwards i then have to do another job of updating the saveschems repo at minetest-mods. If saveschems is in MTG then the act of creating the new lua table automatically updates the official saveschems repo as part of the same commit.

  • When i update the official saveschems repo i first have to update my local copy to pull in any changes sofar may have made to the code. If saveschems is in MTG this will be done regularly and automatically during the normal process of updating my local copy of MTG.

So doing this will save core devs a lot of time and effort as well as moving the official saveshems repo to the optimum place.

I still don't think this is a good idea. I'd prefer making a minetest/saveschems repo

Yes that's a reasonable alternative, but as explained above being in MTG seems to have several time/effort-saving advantages.
Does anyone have practical reasons it should not be in MTG? Maybe you can convince me :)

What do you mean by [as a record of MTG lua table schematics]

The lua tables need to be stored somewhere for reference. Looking at them is extremely useful for modders and core devs, in fact, essential for dev work.

Anyway Ezhh please could you copy the new log schems here to be included?

I had assumed I would just make a PR to the mod instead (but once I have updated them).

Yeah that's fine too, even better :)

I can understand you paramat.

I really like moretrees mod, and because it not generate trees at mapgen, I start to convert moretrees trees to schematics. I never understand why the function to create schematics is hidden out of Minetest Game (thanks google).

In my opinion the original data and the function to convert it to schematics files must be in MTG (maybe as part of MTG APIs), or in MT as MT API.

In my fork of moretrees I include the schematics data and the function to create the schematics (from saveschems), and in my mod the first line define a boolean constant that define if the mod must regenerate the schematics or not. It was necessary for save time due to continuosly apply changes to schematics data and retest it. Even I create a function to convert schematics data from horizontal layers to the vertical layers format of saveschems because for me was easy define the data in horizontal layers.

I do agree there should be something outside of MTG, like a new documentation file in MTE. I could write such documentation. But i still prefer the official repo to be in MTG since it contains MTG schematics and for the convenience reasons given above.

Saveschems needs a new location for the repo. Having it as a new repo in the MT organisation means that every lua table schematic from every core-dev-related game would be added, that would be a lot. We would also lose the advantage of our local saveschems repos being automatically updated when we update MTG.

... but blocking with no reasons is frustrating =)

That's not what either one of us have done. We've simply stated our preferences.

I don't think you even considered this until I mentioned visibility of the schematic tables and the lack of documentation directing people to the mod. But I also mentioned at the same time that I feel the mod should be a more general resource than an MTG specific mod. This type of tool is invaluable to games beyond MTG, therefore in my opinion should ideally be game-neutral instead of made even more MTG-focused.

Each game can then have the schematic tables it uses stored as part of their documentation and the mod can be linked to as the resource by which the schematics, using these tables, can most easily be edited. This not only has the advantage of opening the mod up to be more easily used by other games, (we really need more of those remember, so providing tools to ease their creation is massively important), but it will also, in my opinion, make MTG schematics easier to work on as well. How? Mostly because it will mean I'd then just paste in the specific schematic I was working with and wouldn't be generating every schematic in the list every time. It's cleaner.

... every lua table schematic from every core-dev-related game would be added ...

Not so if my suggested approach is used. (And there's currently only one official game anyway...)

I don't feel having this mod in MTG will make anything easier. I'm saying this as someone who has also edited schematics for the game. I'd much prefer to see it as a more general modding tool under MT itself as rubenwardy suggested.

Thanks. I deleted that post, was just lightheartedly frustrated. I'm actually now not so sure what is best to do.
We could perhaps have a neutral saveschems repo plus game-specific versions in each game.
However i'm also feeling it might be ok to just have text files of the lua tables in each game.

I'd aim for something that is quick and easy to paste into the mod to be stored in MTG itself, then make the mod game neutral, with maybe one example schematic that only runs if default is present (so no hard depend and it will work fine with other games, while leaving people something to use as a guide).

(And as a tiny aside... it would be so nice if the right-way-up tables were the default... This could make it easier for a lot of people.)

Yes i'm ok with your suggestions (and rubenwardy's).
As a first step i have forked saveschems from minetest-mods, updated it with the missing schematics and hosted it here https://github.com/paramat/mtgschems this is temporarily the most official source of MTG schematics.
The reversal function causes issues, i need to work on it to not create mirror-image schematics.

I don't get what the point of the saveschems mod is. It's a tiny bit of code which should be in the engine anyway, and then a bunch of MTG sources. It's barely a tool.

1. raw_schematic folder

It would be better to include the raw resources as files in default, say a raw_schematic/ folder. You could then load the raw files and convert them pretty easily:

local dirs = minetest.get_dir_list(moddir .. "/raw_schematics", true)
table.insert(dirs, ".")
for _, dir in pairs(dirs) do
    local files = minetest.get_dir_list(mapdir .. dir, false)
    for i=1, #files do
        -- set env to expose _ and etc by default
        local schemtable = dofile(dir .. DIR_DELIM .. files[i])
        -- convert and save to .mts
    end
end

There would be a raw_schematics/aspen_tree.lua file like so:

return {
    size = {x = 5, y = 14, z = 5},
    data = {
        _, _, _, _, _,
        _, _, _, _, _,
        _, _, _, _, _,
        _, _, _, _, _,
        _, _, _, _, _,
        _, _, _, _, _,
        _, _, _, _, _,
        N, M, L, M, N,
        _, _, _, _, _,
        N, M, L, M, N,
        _, _, _, _, _,
        N, M, L, M, N,
        _, _, _, _, _,
        _, _, _, _, _,
        -- etc
    },
    yslice_prob = {
        {ypos = 2, prob = 127},
        {ypos = 3, prob = 127},
        {ypos = 8, prob = 127},
        {ypos = 10, prob = 127},
    },
}

This would be best done by the engine, for example it could convert the schems in raw_schematics to .mts for you when running a command like:

/compileschems default

Or it could be a part of default using builtin APIs.

2. just default/raw_schematics.lua

This would be much similar to saveschems, except instead of saveschm you'd use builtin APIs

Summary

This removes the need for a separate mod, and puts the resources where they belong. The raw source files should be part of the mod where they are used and not as a separate mod.

Then again, even better would be to have .lua files in schematics/, and have the engine do this automatically.

Worth considering and that may be a good idea. Obviously the mod is not pointless and has been extremely useful in the form it is in, it just hasn't been integrated into the engine.
The mod is still useful for modders and gamemakers in the form it is in instead of an engine-integrated form, so i'll continue to host it as a mod.

Couldn't saveschems be placed in minimal?
That seems a more optimal place for it.

Actually, Minimal would be a good place to keep other dev tools as well (possibly even NBE)

Either that or adding another MT project repo where all the various tools can be kept and maint.
simply labeled MT/MTG Tools

I agree to just storing the schematic tables in MTG then. However i disapprove of what rubenwardy suggests because it is unnecessary and over-engineered. Also, no-one has time to code that and it is low priority.

I suggest a .txt file that contains a direct copy-paste of the tables as they appears in a 'saveschems' or 'mtgschems' mod. It is most useful in a form that can be copy-pasted directly into that type of mod. Other forms just move it further away from a mod and modder-friendly form. Let's keep it simple.

The actual code that converts can then be added as a .txt document in the engine. The converting code is most useful to people in a lua form so that modders can understand it and learn from it, copy it, edit it for their own uses. In the engine it will be beyond most people's understanding and be uneditable, it won't help modders at all.

Then again, even better would be to have .lua files in schematics/, and have the engine do this automatically.

No, it's always best to have the .mts file stored for use. Reduces memory, time and processing. There's no need to do this.

No, it's always best to have the .mts file stored for use. Reduces memory, time and processing. There's no need to do this.

Not true. It would generate the .mts at server load time and place it in the schematics folder. Future loads won't use the Lua file

I suggest just adding the lua schems to a default/raw_schematics.lua file however, and calling it a day

It would generate the .mts at server load time and place it in the schematics folder. Future loads won't use the Lua file

Ok i misunderstood. As long as it doesn't convert every game session that's ok.

I suggest just adding the lua schems to a default/raw_schematics.lua file

Possibly, but then there is no information about whether the table is in reversed form. Manually reversing all these tables to upright form will not be fun, i don't want to do it and i doubt anyone else will. It also will not be in a form usable in mods. I can't see any advantages to your suggestions, only disadvantages.

I suggest a straight copy-paste of the mtgschems mod init.lua in .txt. form, with added comments, at least for the short term until anyone can be bothered to do anything else.

There would be a raw_schematics/aspen_tree.lua file like so:

return {
    size = {x = 5, y = 14, z = 5},
    data = {
        _, _, _, _, _,
        _, _, _, _, _,
        _, _, _, _, _,
        _, _, _, _, _,
        _, _, _, _, _,
        _, _, _, _, _,
        _, _, _, _, _,
        N, M, L, M, N,
        _, _, _, _, _,
        N, M, L, M, N,
        _, _, _, _, _,
        N, M, L, M, N,
        _, _, _, _, _,
        _, _, _, _, _,
        -- etc
    },
    yslice_prob = {
        {ypos = 2, prob = 127},
        {ypos = 3, prob = 127},
        {ypos = 8, prob = 127},
        {ypos = 10, prob = 127},
    },
}

That doesn't include the definitions for L, M, N, _.

With my suggestion, any new schematic added to MTG can be easily and directly copy-pasted into the .txt file without having to change the format. It needs to be simple and quick as it will be done as part of a commit.

Perhaps we will do something different or i perhaps i will change my mind later, but that could be a long way off so for the moment let's do something simple.

why not leave the defs, but just comment them out?

So let's do something.
Please can i have pre-approval to create a 'schematics.txt' file containing all tables (but no functions)?
This will be a mix of normal and upright tables, maybe later some can be converted to have all in one form (hopefully automatically, i'm not going to edit these manually).

I'd agree with them being added as a text file.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

juozaspo picture juozaspo  路  6Comments

sofar picture sofar  路  5Comments

TekhnaeRaav picture TekhnaeRaav  路  5Comments

HybridDog picture HybridDog  路  4Comments

paramat picture paramat  路  3Comments