[Mod] Structures [git] [minetest_mods_structures]

User avatar
MirceaKitsune
Member
 
Posts: 837
Joined: Sat May 21, 2011 22:31
Location: Romania, Bucharest
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

[Mod] Structures [git] [minetest_mods_structures]

by MirceaKitsune » Tue Apr 09, 2013 12:57

A few days ago I got started on one of the important projects I had in mine for MineTest, which I believe can be of big importance and will open the gates to doors possibilities in MineTest. Currently it's halfway done, but I'm very glad with what I did in such a short amount of time.

- Mod information:

The Structures mod allows marking an area in the world in which you can import and export structures to text files. You place an I/O node on the ground and 3 markers for each axis (one either to its left or right, one either to its back or front, one either above or below it). Once the markers are detected, the node activates and allows you to access the I/O menu. From here you can clone the area to a text file, import a text file to the area, or clear the area of nodes.

Basically, this allows you to copy your buildings from one place to another in the world, save what you build in MineTest on your drive, and even share what you create on the forum for others to load on their map. For example: If you want to load the test structure I used currently for this mod (made of 4 obsidian blocks), simply put the following in a text file and import it:

Code: Select all
default:obsidian 7 0 2
default:obsidian 7 0 1
default:obsidian 7 1 1
default:obsidian 6 0 1


The I/O component is the first part of the mod. The second part I'll be getting to is a mapgen function, which will allow buildings in text files to be automatically spawned in the world. Ideally you will be able to specify a folder of text files, and the mapgen will randomly spawn any building there in a given area. This will be perfect for implementing villages, cities, or places made of structures you build in your world.

Note that there are still bugs in the mod and things which aren't finished. The biggest lack is that facedir isn't saved / loaded yet, so stairs / torches / etc will not be rotated correctly. Other than that, feel free to test it and report any bugs and suggestions. You can also post the text files of buildings you create for others to load and play with.

- Screenshots and download:

You can get the mod from its Github repository. It will be updated frequently within the next days so don't forget to pull every now and then. Here are some screenshots of what's been done so far:

Image

Image

- License:

Code by MirceaKitsune, LGPL. Default town schematics by MirceaKitsune, WTFPL. Full license information included in the README.txt.
Last edited by MirceaKitsune on Sun Jun 28, 2015 11:48, edited 4 times in total.
 

ashenk69
Member
 
Posts: 230
Joined: Tue Jul 03, 2012 00:08

by ashenk69 » Tue Apr 09, 2013 13:55

This mod sounds very similar to worldedit's importing and exporting of of its .we files.
For the map generation take a look at the Random Buildings mod http://forum.minetest.net/viewtopic.php?id=4885.
Something you could add to make it unique is to make it craftable and make the structures only build if they have the required resources.
 

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

by Sokomine » Tue Apr 09, 2013 15:16

The idea is good. However, three nodes as markers are too much and overly complicated. I think we need one node out of which you can draw a second marker which will then mark the opposite end of the building. Height can be determined by either looking how large the structure extends upward (find one level where there's nothing but air) or by asking the player. Guessing how heigh someting is is usually easier than determining x and z correctly. The same apllies for depth. At least for small scale.

I'm working on something similar for my random_buildings mod. As good as my cottages may be, Minetest is about building, and players have to be able to extend the village with their own structures (saving them, adding copies of them, making enough buildings for entirely new villages). Another area where this functionality is desperately needed is node_ownership. It is annoying and difficult to get the corners of a to-be-protected-area right. Plus the ability to save the content to a file (and maybe send it to you as a mail) would be great. What I have to do once I find the time is to store the information of the starting node in the second marker, add the formspecs required etc.

Please use the de-facto-standard of the worldedit savefile format for your mod as well. Weather you take the newest or an older format is of limited importance. The older one - that does not save meta information - is very similar to your format except that saves param1 and param2 as well.

MirceaKitsune wrote:Ideally you will be able to specify a folder of text files, and the mapgen will randomly spawn any building there in a given area. This will be perfect for implementing villages, cities, or places made of structures you build in your world.

Spawning buildings at mapgen time is the real trouble. It works - to a degree. Even those tiny lumberjack- and clay trader houses have to wait more often than not for their spawn space to "exist" completely (they do some checks first to make sure nothing important is destroyed by their spawning and to determine how high the platform for the building has to be). This is also a protection against griefs by mapgen which occoured at least in earlier versions of mapgen: Imported buildings where griefed because caves where created in them. Small buildings work relatively well (say, up to 20x20), but the 80x80 area of Gambits NPC village proved to be too large. At least on my computer, making sure that the entire area was loaded failed. Even when I was standing at the start of it. Spawning worked nevertheless, but this way it is far less safe.

For importing really huge structures, talk to Mauvebic. He may tell you how much pain it sometimes is to get something really large imported. He has found some workarounds. Still, importing e.g. a Minecraft classic map is sometimes limited by those factors.

Apart from the general trouble with importing large areas, there's also the factor of the smoothness of terrain. Even tiny houses need platforms to stand on because there's not enough flat land around. And you usually don't want completely flat maps (which would eliminiate the problem) because they would be too boring for this (=randomly spawned buildings) scenario.

If you want to experiment a bit with my random_buildings mod (as linked in the thread above), best install moretrees in your world. After all, what gets spawned are lumberjacks. Without moretrees, you do get only the standard wood traders, which is a bit boring. Clay traders spawn as well. Buildings for villages exsit, but due to the problems mentioned above they do not spawn by themshelves. You can build them in a similar way to towntest by using /giveme random_buildings:build to obtain a building chest. Place that chest and insert the materials as requested. The chest will construct a scaffolding structure where the building will later be. As soon as there is as much material of one type as required, all those blocks of that type are placed in one go. There is no NPC moving around like in towntest (that one goes through solid matter, which looks odd, but what would require a lot of computation time to avoid).
A list of my mods can be found here.
 

User avatar
MirceaKitsune
Member
 
Posts: 837
Joined: Sat May 21, 2011 22:31
Location: Romania, Bucharest
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Tue Apr 09, 2013 17:41

Regarding worldedit: I haven't tried this mod yet and don't know how it works, although I assume it's a very useful tool too and worth checking out. It probably has a different purpose than what my mod does however. The primary purpose of this is to save or share individual structures, as well as integrate them with mapgen automatically and in realtime (when I get to that).

I can't promise I can change my file format to work with worldedit or any other mod. This is its own mod after all. When the basic things are ready I might take a look at that, but I cannot promise. Note that the only things each line (node) will contain are the node name, position, and param2 + paramtype 2 (for facedir). Air nodes are also excluded.

This hopefully makes it as effortless as possible for the import function to build the structure (and therefore the mapgen). No matter what, doing this in Lua will be slow. I think it's better than nothing though, so we'll see how fast it will be when generating.

The 3 markers approach felt easiest to me. I thought about using only one marker in opposite corner, but that can be harder to place and also harder for me to calculate. I remember a similar mod in MineCraft used this approach. Maybe it could be better, but it's the one I found easiest.

I might check your mod later, it sounds interesting too. Also worldedit. But at least until it's ready, this one goes in its own direction.
 

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

by Sokomine » Tue Apr 09, 2013 18:19

Worldedit can be used for the things you mentioned (apart from the spawning at mapgen - which it can't do). Most people use it to transfer structures between worlds. It is also a very powerful tool for constructing really large structures. Unfortionately, most servers do not give worldedit priv to players since that could cause a lot of damage. Uberi has created a limited version that will hopefully help there.

Regarding file format: I disagree with you. Just spend the 2 minutes it takes to understand the (old!) worldedit format and you can use it :-) Mostly it takes a re-ordering of your parameters plus adding param1 and param2. One line from the old worldedit savefile format (which can still be read by the newest version) might be:
Code: Select all
5 3 2 default:glass 204 0

..which is x, y, z, name, param1, param2, whereas your foramt is name, x, y, z. Can't tell me that won't be easy to integrate :-) Parsing it is done by applying a regular expression. Air nodes are excluded as well. Your format would end up beeing almost exactly the same - except for the order of the parameters. Sticking to the de-facto standard will allow users of your mod to import worldedit schems without having to re-order the parameters first.

The problem with importing the structures is not speed. Large worldedit actions may lag, yes. But those actions may involve thousands or millions of nodes (when e.g. making a 3d area flat for building or importing entire maps). Small buildings are usually no problem. And when they get larger, you run into the problems I mentioned. It's hard to do things in regions that the server believes are not yet loaded/generated but which will be needed for your building.

The marker ought to remember which save-box it belongs to. I don't know yet if that can be done efficiently. It may even be easier for players to use your 3-marker-version. Hard to tell.
A list of my mods can be found here.
 

User avatar
MirceaKitsune
Member
 
Posts: 837
Joined: Sat May 21, 2011 22:31
Location: Romania, Bucharest
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Tue Apr 09, 2013 21:27

Sokomine: Nice. That does look similar to what I'm doing from the screenshots, though a different approach still. And yes... I didn't know it's THAT similar to my format. In that case I can indeed make it Worldedit compatible and will, no point in not doing so.

For now, the latest version in GIT stores facedir from param2. Stairs and torches are copied at the correct rotations, though for some reason this fails sometimes. Already made a house to test it and it seems the import function spawns the 1000 nods in just half a second. Not too bad :)

[EDIT] Changed format to be Worldedit compatible as mentioned above. Structures should be possible to read / write between the mods now.
Last edited by MirceaKitsune on Tue Apr 09, 2013 21:39, edited 1 time in total.
 

Temperest
Member
 
Posts: 651
Joined: Tue Nov 15, 2011 23:13
GitHub: Uberi

by Temperest » Wed Apr 10, 2013 00:17

This is pretty neat. Have you considered using the WorldEdit API to do file loading? WorldEdit's current worldedit.deserialize supports every version of WorldEdit ever released having save/load capabilities. Just add "worldedit" to depends.txt, or even use the following to avoid a dependency:

Code: Select all
dofile(minetest.get_modpath("worldedit").."/serialization.lua")
x = io.open("something"):read("*a")
array_of_nodes = worldedit.deserialize(x)


Every module is independent and works without requiring any other files.

You might have the facedir issues because of the client not updating nodes. I don't think there's any good way of fixing this other than adding the node multiple times. Which is a horrible solution, obviously.

Sokomine: how's the limited version working by the way? I haven't had much of a chance to work on it recently.
Last edited by Temperest on Wed Apr 10, 2013 00:18, edited 1 time in total.
WorldEdit 1.0 released

The Mesecons Laboratory - the art of Mesecons circuitry
Latest article: Mesecons Basics.
 

User avatar
MirceaKitsune
Member
 
Posts: 837
Joined: Sat May 21, 2011 22:31
Location: Romania, Bucharest
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Wed Apr 10, 2013 09:39

Temperest wrote:This is pretty neat. Have you considered using the WorldEdit API to do file loading? WorldEdit's current worldedit.deserialize supports every version of WorldEdit ever released having save/load capabilities. Just add "worldedit" to depends.txt, or even use the following to avoid a dependency:

Code: Select all
dofile(minetest.get_modpath("worldedit").."/serialization.lua")
x = io.open("something"):read("*a")
array_of_nodes = worldedit.deserialize(x)


Every module is independent and works without requiring any other files.

You might have the facedir issues because of the client not updating nodes. I don't think there's any good way of fixing this other than adding the node multiple times. Which is a horrible solution, obviously.

Sokomine: how's the limited version working by the way? I haven't had much of a chance to work on it recently.


I added Worldedit compatibility but that's the most I'm doing. Not planning to copy code from it or re-base my mod off it, especially now that I have my own functions working. This isn't Worldedit, it's a mod that does something similar to it and uses its own approach :P

I think my issue with facedir is due to a bad formula currently, I'll try to work on that today. Furnaces and chests also aren't rotated well when importing at 180* and doors are broken (you can't either open or punch them to remove them). I'll think about the mapgen part after doing this and other optimizations... still need to think where and how to store the mapgen options.
 

User avatar
MirceaKitsune
Member
 
Posts: 837
Joined: Sat May 21, 2011 22:31
Location: Romania, Bucharest
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Wed Apr 10, 2013 19:34

Today I did several improvements, including fully fixing bad mirroring and facedir / wallmounted directions. I also implemented support for importing at 90* and 270* too, which makes the I/O system pretty much complete. Next should be the mapgen part, which I'll see when I get to and what approach I'll be using.
 

User avatar
MirceaKitsune
Member
 
Posts: 837
Joined: Sat May 21, 2011 22:31
Location: Romania, Bucharest
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Fri Apr 12, 2013 22:39

Today I got started on the mapgen implementation. After a full day of working on the script, I managed to get the basics functioning and the default house to spawn around the world. The code is in the latest GIT, but be warned that it's very buggy and basic so don't use this on a world you don't wish to ruin. Here are some images of the mapgen in action:

Image

Image

Image
 

Temperest
Member
 
Posts: 651
Joined: Tue Nov 15, 2011 23:13
GitHub: Uberi

by Temperest » Fri Apr 12, 2013 23:33

Impressive. Any plans of fitting it to the terrain in the future? That would need some sort of parametric system I guess.
WorldEdit 1.0 released

The Mesecons Laboratory - the art of Mesecons circuitry
Latest article: Mesecons Basics.
 

User avatar
MirceaKitsune
Member
 
Posts: 837
Joined: Sat May 21, 2011 22:31
Location: Romania, Bucharest
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Sat Apr 13, 2013 09:09

Temperest wrote:Impressive. Any plans of fitting it to the terrain in the future? That would need some sort of parametric system I guess.


Matching structures properly to the terrain is harder than I even thought... especially when you don't want the script to be very CPU intensive and use a lot of loops. I will improve on buildings cutting large areas around themselves when spawning, as well as spawning over each another... but sadly I doubt I can do more.
 

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

by Sokomine » Sat Apr 13, 2013 14:16

My random_buildings construct a platform for the building. That works at least to a degree and looks acceptable most of the time. It would look better if there where more flat areas for buildings to spawn on.
A list of my mods can be found here.
 

User avatar
MirceaKitsune
Member
 
Posts: 837
Joined: Sat May 21, 2011 22:31
Location: Romania, Bucharest
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Sun Apr 14, 2013 21:37

After two days of full work, I managed to get the mapgen to the point where it's stable and usable. Building bounds are now correct as well as probabilities in each structure group. A table is used to maintain all origins of previously spawned buildings in order to avoid them, heavily reducing cases where buildings spawn into each other. A floor is also build under each building using its spawn trigger node, to cover areas when parts are left floating. More importantly, there's now a delay for each building in a probability loop, making it visibly less stressful for the mapgen to spawn buildings. Additionally I added a tower and 3 different houses.

If anyone wants to test it and let me know what they think, get the latest code from GIT (see first post) and go exploring. Note that there will be rare cases of buildings either spawning into each other or not spawning completely. Here are some beautiful views with naturally generated towns:

Image

Image

Image

Image

Image
 

User avatar
Traxie21
Member
 
Posts: 753
Joined: Mon Dec 31, 2012 10:48
Location: McKinney, Texas U.S.A.

by Traxie21 » Mon Apr 15, 2013 02:32

Incredible! I think I will add this to SunriseTest!
 

User avatar
jojoa1997
Member
 
Posts: 2890
Joined: Thu Dec 13, 2012 05:11
Location: Earth

by jojoa1997 » Mon Apr 15, 2013 02:48

Maybe this could be added to Minitest for villages and peaceful_npc for villages also.
Coding;
1X coding
3X debugging
12X tweaking to be just right
 

User avatar
jojoa1997
Member
 
Posts: 2890
Joined: Thu Dec 13, 2012 05:11
Location: Earth

by jojoa1997 » Mon Apr 15, 2013 03:04

Does this mod use the world edit schemaTic
Coding;
1X coding
3X debugging
12X tweaking to be just right
 

User avatar
MirceaKitsune
Member
 
Posts: 837
Joined: Sat May 21, 2011 22:31
Location: Romania, Bucharest
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Mon Apr 15, 2013 08:48

Traxie21 wrote:Incredible! I think I will add this to SunriseTest!


Thanks. It should be safe and stable to add now, but again expect naturally spawned structures to act up a little bit. It will also make the mapgen slower, although I optimized the code as well as I could (eg: adding breaks to all loops after they've finished their purpose).

Also keep in mind that there's no privilege to using the I/O system. So if someone obtains / finds a manager node and 3 markers, they can import or export any structure on your server. However they're not craftable, so the only way they can get them is from an admin or the Creative inventory.

jojoa1997 wrote:Maybe this could be added to Minitest for villages and peaceful_npc for villages also.


I doubt this mod can get added to Minetest by default. Spawning large structures in Lua is rather slow no matter what you do, and the approach for the I/O system might not be most preferred. It does allow for complex natural villages however. Maybe for one of the other games it could be added still (not minetest_game).

jojoa1997 wrote:Does this mod use the world edit schemaTic


The code is completely original. But I made it support the worldedit format as well, as explained some posts above. Haven't tested if worldedit structures import fine however.
 

User avatar
Traxie21
Member
 
Posts: 753
Joined: Mon Dec 31, 2012 10:48
Location: McKinney, Texas U.S.A.

by Traxie21 » Mon Apr 15, 2013 12:50

Taoki, I know it's hard to notice, but jojoa said MINItest, not MINEtest.
Minitest is a game that tries to emulate Minecraft as much s possible.
 

User avatar
MirceaKitsune
Member
 
Posts: 837
Joined: Sat May 21, 2011 22:31
Location: Romania, Bucharest
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Mon Apr 15, 2013 14:37

Traxie21 wrote:Taoki, I know it's hard to notice, but jojoa said MINItest, not MINEtest.
Minitest is a game that tries to emulate Minecraft as much s possible.


Ohh, sorry about that. Sure, it could be used for that if the mod's admin wants to :)
 

User avatar
jojoa1997
Member
 
Posts: 2890
Joined: Thu Dec 13, 2012 05:11
Location: Earth

by jojoa1997 » Mon Apr 15, 2013 15:26

MirceaKitsune wrote:
Traxie21 wrote:Taoki, I know it's hard to notice, but jojoa said MINItest, not MINEtest.
Minitest is a game that tries to emulate Minecraft as much s possible.


Ohh, sorry about that. Sure, it could be used for that if the mod's admin wants to :)
Yeah sorry but i didnt make the name.
Coding;
1X coding
3X debugging
12X tweaking to be just right
 

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

by Sokomine » Wed Apr 17, 2013 17:03

How does it work with larger buildings? The 80x80 of Gambits NPC village for Jojoas peaceful_npc proved problematic with my mod - at least with the checks for "area loaded and free to use" active.

I'll use a similar approach as far as remembering where buildings where spawned in the future - for a slightly diffrent purpose. There's no chance to manage villages if most of the village is not even loaded when the player runs around at one end of it. Roads are another matter. The world is just too hilly :-(
A list of my mods can be found here.
 

User avatar
MirceaKitsune
Member
 
Posts: 837
Joined: Sat May 21, 2011 22:31
Location: Romania, Bucharest
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Thu Apr 18, 2013 20:29

More fun changes for today. I added a group avoidance system which finally fixes all cases of buildings spawning in one another and cutting each other. I also introduced a shuffling system to the mapgen (triggered at each group spawn) which fixes structures at the top of the file always being favored due to taking up space first. Also added two fountains and a lighting pole to default structures. Try the latest GIT and let me know what you think... would like to play online on a server that has this :)

@ Sokomine: I haven't tested with buildings larger than 25 nodes, but as far as I'm aware it should work fine. Just make sure they use the proper distance in mapgen settings so no other building can clash with it (measured from each one's center). You'll also need to edit a script setting to create such a building, since by default markers only link with manager nodes on a distance of 50 nodes.

Image

Image

Image

Image
Last edited by MirceaKitsune on Thu Apr 18, 2013 20:32, edited 1 time in total.
 

User avatar
MirceaKitsune
Member
 
Posts: 837
Joined: Sat May 21, 2011 22:31
Location: Romania, Bucharest
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Sun Jun 09, 2013 18:22

Fixed the mod not working due to missing depends.txt, and added a "structures" privilege which is now required to use the manager node (given for singleplayer) to prevent any possibility of griefing. Get the latest GIT for the changes.

Anyway, it's been a while. Any news on this? Was hoping more people would put it on their server and could offer more input. Maybe see how it works with their own buildings and ideas. Any server use it yet?
Last edited by MirceaKitsune on Sun Jun 09, 2013 18:23, edited 1 time in total.
 

JBR
Member
 
Posts: 76
Joined: Sun May 26, 2013 22:04
Location: United Kingdom, Wales

by JBR » Sun Jun 09, 2013 18:30

MirceaKitsune wrote:Fixed the mod not working due to missing depends.txt, and added a "structures" privilege which is now required to use the manager node (given for singleplayer) to prevent any possibility of griefing. Get the latest GIT for the changes.

Anyway, it's been a while. Any news on this? Was hoping more people would put it on their server and could offer more input. Maybe see how it works with their own buildings and ideas. Any server use it yet?


Gonna try it out now
 

Next

Return to Mod Releases



Who is online

Users browsing this forum: No registered users and 5 guests