Page 1 of 4

[Mod] Settlements [settlements]

Posted: Sat Jul 07, 2018 12:18
by Rochambeau
Settlements

Image

Image

Description
This mod adds small settlements (7 - 20 buildings) during world generation. The small huts contain chests with random stuff.
If mobs_redos NPCs are available, there will be some life inside the buildings (they spawn on default:junglewood, maybe I'll register a special node for themthey spawn on a special node with junglewood looks). Still testing.

Buildings by now:
  • townhall (as center of settlement)
    well
    hut
    tower
    church
    garden
    blacksmith
    lamp
Notes
Settlements can be played with Minetest 0.4.16 or above.

Depends on default
Optional:
- mobs_npc (as inhabitants)
- farming (some vegetables as chest content)

List of features
Buildings are rather smalls to fit in almost every terrain.

Bug reports and suggestions
You can report bugs or suggest ideas on GitLab.

Links
Source
Download
How to install

License
WTFPL

Re: [Mod] Settlements [settlements]

Posted: Sat Jul 07, 2018 12:46
by Stix
Nice! Ive been waiting for a good villages mod that places schematics according to the terrain instead of flattening the ground. The only thing this is missing is gravel roads and more natural/realistic farms :3.

Re: [Mod] Settlements [settlements]

Posted: Sat Jul 07, 2018 13:39
by TenPlus1
Nice mod, was surprised to see 8 npc's sharing a tiny house though :)

Note: you could speed up generation using swap_nodes for foundations, also furnace has no formspec attached to it.

Re: [Mod] Settlements [settlements]

Posted: Sat Jul 07, 2018 13:57
by hajo
Rochambeau wrote:adds small settlements (7 - 20 buildings) during world generation.
Would it be possible to also have 'village-spawn-eggs',
ie. to make it easy to place such settlements manually ?

Re: [Mod] Settlements [settlements]

Posted: Sat Jul 07, 2018 14:01
by Stix
hajo wrote:
Rochambeau wrote:adds small settlements (7 - 20 buildings) during world generation.
Would it be possible to also have 'village-spawn-eggs',
ie. to make it easy to place such settlements manually ?
Yeah that would be nice.

Re: [Mod] Settlements [settlements]

Posted: Sat Jul 07, 2018 14:28
by texmex
Very good-looking!

Re: [Mod] Settlements [settlements]

Posted: Sat Jul 07, 2018 16:23
by R-One
hello, an oversight in init.lua on gitlab ?
package.cpath = package.cpath .. "; /usr/share/lua/5.2 / ?. so"
package.path = package.path .. "; / usr / share / zbstudio / lualibs / mobdebug / ?. lua"
require ( 'mobdebug'). start ()

Re: [Mod] Settlements [settlements]

Posted: Sat Jul 07, 2018 18:05
by Rochambeau
hello, an oversight in init.lua on gitlab ?
It's necessary when debugging with Zerobrane Studio. I forgot to remove it.
Would it be possible to also have 'village-spawn-eggs',
ie. to make it easy to place such settlements manually ?

Code: Select all

/giveme settlements:tool
leftclick: one building is generated, hardcoded
rightclick: attempting to build a settlement. Currently only works when in the "right area". Buildings can only be built when finding these surface materials:

Code: Select all

  "default:dirt_with_grass",
  "default:dirt_with_snow",
  "default:dirt_with_dry_grass",
  "default:dirt_with_coniferous_litter",
  "default:sand",

Note: you could speed up generation using swap_nodes for foundations, also furnace has no formspec attached to it.
Repaired the furnace. Furnaces don't have meta data, so won't work as expected. Same as chests. Meta is added by on_construct.
The only thing this is missing is gravel roads and more natural/realistic farms :3.
Gravel roads would be nice indeed. I tried to avoid them by claiming "it's only a settlement, not a village or town". ;-) Maybe in the distant future. As for the realistic farms: I designed the gardens after those in Minecraft. Yeah, that's bad. But I'm not that creative. If you point to a better looking farm, I see what I can do.

Re: [Mod] Settlements [settlements]

Posted: Sun Jul 08, 2018 00:03
by Sokomine
Stix wrote: Nice! Ive been waiting for a good villages mod that places schematics according to the terrain instead of flattening the ground.
The vast majority of human players on a server isn't capable of adjusting their building style to the sourrounding terrain.
Stix wrote: The only thing this is missing is gravel roads and more natural/realistic farms :3.
:-/ Such demands is what you get if you promise "placed without adjusting the land" :-)
TenPlus1 wrote: Nice mod, was surprised to see 8 npc's sharing a tiny house though :)
There was heavy overpopulation in my test worlds as well. It's possible that they breed so much in order to get at least some people through the next night when aggressive monsters (sometimes called players) will appear.
Rochambeau wrote: "default:dirt_with_coniferous_litter",
That's something I'll have to teach mg_villages/handle_schematics as well.
Rochambeau wrote: Gravel roads would be nice indeed. I tried to avoid them by claiming "it's only a settlement, not a village or town". ;-) Maybe in the distant future.
Very understandable :-) MT's terrain is very tricky in that regard.
Rochambeau wrote: As for the realistic farms: I designed the gardens after those in Minecraft. Yeah, that's bad. But I'm not that creative. If you point to a better looking farm, I see what I can do.
Hm, yes, I don't overly like standard MC houses/villages. They seem so...tiny and stretched too much in height. At least the forge is pretty nice, and the huts as such aren't too bad either. The church looks much too cramped.

Overall, the settlements generated look quite good. In detail, there are points where much imporvement is needed. For example it feels wrong to have the tower at almost the lowest place of the village, where you can hop on top of it from the mountain it's partly embedded in. Many huts end up mostly embedded in a hill as well. It's partly acommodated for by the house having overhanging roofs. Thus the paths to the front door are usually free. Other houses end up on visible platforms. That's hard to avoid. I had that in my random_buildings mod as well (though with some randomness added to the platforms/pillars).

In one test world, the houses where cut off at an absolute height of 30.

A settlement inside a dense rainforrest isn't optimal either. The trees ought to be cut down in such a case.

Holes inside the village area are problematic. If all those poor mobs spawning inside the houses ever manage to get out of the door, they'll surely fall into all these deep holes and stay there forever. That can't be!

My handle_schematics mod has a cheap function for analyzing the hightmap and for finding places with equal height:

Code: Select all

local heightmap = minetest.get_mapgen_object('heightmap');
local res = handle_schematics.find_flat_land_get_candidates_fast( heightmap, minp, maxp, sizex, sizez, minheight, maxheight );
sizex and sizez are the dimensions of the flat area you're looking for. minheight and maxheight can limit where it can be placed (i.e. most houses don't want to be placed below water level; ships on mountains are uncommon). Returns res.places_x and res.places_z (for houses rotated by either 90 or 180 degrees; sizex and sizez are swapped). Those tables are arrays that contain all the indices relative to heightmap that are flat enough for a house of said dimensions. Places choosen for a house can be marked as occupied so that they won't get offered in subsequent runs of handle_schematics.find_flat_land_get_candidates_fast.

The circular way the mod places its houses looks very convincing. That'd be a very suitable arrangement of houses for the village type grasshut in my villages modpack as well.

Nice to see replacements used so that the houses look diffrent. Seems to work very well.

I hope that the mod will be developped further.

Re: [Mod] Settlements [settlements]

Posted: Thu Jul 12, 2018 19:20
by Cartmic
Hello,

I have a question about your licence file, I note that you have a copyright in there but below you provide a public domain licence and a link to it, so tell me is your code (c) Copyright Rochambeau (2018) or licenced under the the licence you refer to?

Re: [Mod] Settlements [settlements]

Posted: Thu Jul 12, 2018 20:10
by rubenwardy
Both.

Copyright doesn't mean that you can't use it, it just means that that person owns the copyright. All works will have a copyright, open or not. Copyright is automatic

You're mixing up copyright with "all rights reserved"

Re: [Mod] Settlements [settlements]

Posted: Thu Jul 12, 2018 20:33
by Cartmic
rubenwardy wrote:Both.

Copyright doesn't mean that you can't use it, it just means that that person owns the copyright. All works will have a copyright, open or not. Copyright is automatic

You're mixing up copyright with "all rights reserved"
Sorry I came across as quite abrasive there.
Thanks for that clarification.

Re: [Mod] Settlements [settlements]

Posted: Fri Jul 13, 2018 07:32
by Rochambeau
@ those who looked a the sources and know what the mod is doing at the current state:

would the use of voxelmanip bring any advantages in performance?


The next thing I'm trying to do is find better places for building a settlement. Thanks @Sokomine for bringing 'heightmap' to my attention.
To minimize the use of visible platforms the mod could determine the highest and lowest y in the area and if the difference is not too big -> settlement. That will dramatically decrease the number of suitable spots, but the remaining settlements might look more natural.

Re: [Mod] Settlements [settlements]

Posted: Fri Jul 13, 2018 19:13
by Rochambeau
Added simple height detection. Settlements are only created, when the height difference is 10 or less. So no hardcore mountain settlements anymore.
Still heavy WIP.

Re: [Mod] Settlements [settlements]

Posted: Sat Jul 14, 2018 21:34
by Sokomine
Rochambeau wrote: To minimize the use of visible platforms the mod could determine the highest and lowest y in the area and if the difference is not too big -> settlement. That will dramatically decrease the number of suitable spots, but the remaining settlements might look more natural.
My handle_schematics/basic_houses mod is already capable of detecting sufficiently large flat areas for building individual houses. Combined with your intresting circular arrangement that could produce good results. You'd still have to search through the list of possible places in order to find the one closest to the location on the circle you aim for with that particular building.

I've also made some progress with the detection of hills (= local to the mapchunk; can be removed for more flat surface area without affecting the overall landscape) and holes (= suitable for highlandpools or for filling up and thus creating more flat space).

Re: [Mod] Settlements [settlements]

Posted: Tue Jul 17, 2018 08:28
by Rochambeau
Found a way to create some gravel paths:
Image

Still in early stage and much space for improvement. But it works.

Re: [Mod] Settlements [settlements]

Posted: Tue Jul 17, 2018 09:27
by Hume2
Nice mod. I'm now testing it. It works but it might also throw this error:

Code: Select all

2018-07-17 11:14:21: ERROR[Main]: ServerError: AsyncErr: Lua: finishGenRuntime error from mod 'settlements' in callback environment_OnGenerated(): ...k1asw/blb/minetest/bin/../mods/settlements/utils.lua:35: attempt to index a nil value
2018-07-17 11:14:21: ERROR[Main]: stack traceback:
2018-07-17 11:14:21: ERROR[Main]: 	...k1asw/blb/minetest/bin/../mods/settlements/utils.lua:35: in function 'find_surface'
2018-07-17 11:14:21: ERROR[Main]: 	...k1asw/blb/minetest/bin/../mods/settlements/utils.lua:220: in function 'determine_heightmap'
2018-07-17 11:14:21: ERROR[Main]: 	...ok1asw/blb/minetest/bin/../mods/settlements/init.lua:77: in function '?'
2018-07-17 11:14:21: ERROR[Main]: 	...ok1asw/blb/minetest/bin/../builtin/game/register.lua:419: in function <...ok1asw/blb/minetest/bin/../builtin/game/register.lua:399>
Edit: I found another bug. When the farming redo mod is disabled but the MTG's farming is on, it might still generate stuff from farming redo like melon slices or corn in chests.

Re: [Mod] Settlements [settlements]

Posted: Tue Jul 17, 2018 10:45
by texmex
Rochambeau wrote:Found a way to create some gravel paths:
Image

Still in early stage and much space for improvement. But it works.
I's already beautiful!

Re: [Mod] Settlements [settlements]

Posted: Tue Jul 17, 2018 11:00
by Rochambeau
Hume2 wrote:Nice mod. I'm now testing it. It works but it might also throw this error:

Code: Select all

2018-07-17 11:14:21: ERROR[Main]: ServerError: AsyncErr: Lua: finishGenRuntime error from mod 'settlements' in callback environment_OnGenerated(): ...k1asw/blb/minetest/bin/../mods/settlements/utils.lua:35: attempt to index a nil value
2018-07-17 11:14:21: ERROR[Main]: stack traceback:
2018-07-17 11:14:21: ERROR[Main]: 	...k1asw/blb/minetest/bin/../mods/settlements/utils.lua:35: in function 'find_surface'
2018-07-17 11:14:21: ERROR[Main]: 	...k1asw/blb/minetest/bin/../mods/settlements/utils.lua:220: in function 'determine_heightmap'
2018-07-17 11:14:21: ERROR[Main]: 	...ok1asw/blb/minetest/bin/../mods/settlements/init.lua:77: in function '?'
2018-07-17 11:14:21: ERROR[Main]: 	...ok1asw/blb/minetest/bin/../builtin/game/register.lua:419: in function <...ok1asw/blb/minetest/bin/../builtin/game/register.lua:399>
Edit: I found another bug. When the farming redo mod is disabled but the MTG's farming is on, it might still generate stuff from farming redo like melon slices or corn in chests.
Thank you for testing. I fixed both bugs with the latest commits.

Re: [Mod] Settlements [settlements]

Posted: Tue Jul 17, 2018 15:13
by Hume2
Now it works fine. I have another screenshot for your collection :)
Image

Re: [Mod] Settlements [settlements]

Posted: Thu Jul 19, 2018 07:22
by Rochambeau
Replaced my own routine of height detection, because it was too slow. The mod uses the official heightmap now, though it seems a little buggy.
I often get heightmaps consisting of purely -31000 or other values that are impossible. I'm trying to filter those buggy heightmaps.

Re: [Mod] Settlements [settlements]

Posted: Fri Jul 20, 2018 17:01
by cdu13a
Nice work. It's been enjoyable wandering around looking for villages.
Image
Image

One little problem however. Using settlements with some other mods like say a mod like lower crossroads viewtopic.php?f=9&t=19036. Settlements will place buildings in the middle of the roads. While I do like that the villages often appear near/straddling roads, it would be nice if when placing a building that settlements could check if the nodes it was being placed on is_ground_content or not, and then move the building over a bit if it's not. that way we can play a bit nicer with other mods structures.

Re: [Mod] Settlements [settlements]

Posted: Fri Jul 20, 2018 21:11
by Sokomine
This settlement was cut off at a height of about 31 (most likely mapchunk border):
Image
Rochambeau wrote: Found a way to create some gravel paths:
The gravel paths are a very nice addition and look good from above. Trouble is that it's not easy (sometimes close to impossible) to actually navigate them. I wonder if the same algorithm used for pathfinding for mobs might help here. In combination with the mob claiming to be able to jump no higher than 1 block and be afraid of jumps of more than 1 block, it might almost work. Still, for a good paths network, stairs and slabs are necessary.
Rochambeau wrote: Replaced my own routine of height detection, because it was too slow. The mod uses the official heightmap now, though it seems a little buggy.
I often get heightmaps consisting of purely -31000 or other values that are impossible. I'm trying to filter those buggy heightmaps.
That usually indicates that height at that point cannot be determined. You may be looking at a mountain peak whose base is in the mapchunk below. Or there might be no ground in this mapchunk at all.
cdu13a wrote: Settlements will place buildings in the middle of the roads. While I do like that the villages often appear near/straddling roads, it would be nice if when placing a building that settlements could check if the nodes it was being placed on is_ground_content or not, and then move the building over a bit if it's not. that way we can play a bit nicer with other mods structures.
That'd certainly be nice - but might also be a lot of work and may not even work out in the end. Such things are very critical regarding order of modifications and which functions are used.

I've made some progress with my analysis of the heightmap regarding detection of hills and holes. Individual ones can now be distinguished from each other. I've still got to find a way to deal with holes in a hill and vice versa.

Re: [Mod] Settlements [settlements]

Posted: Sat Jul 21, 2018 10:40
by Rochambeau
Sokomine wrote:This settlement was cut off at a height of about 31 (most likely mapchunk border)
Hm, I guess I need to find a way to force load neighboring chunks.

Some other problem I stumbled upon migrating to LuaVoxelManip:
My subroutine to calculate pos on circles around the settlement center (cos, sin) sometimes gave me coordinates with decimal places (p6.x = 132.9956, p6.y = 8, p6.z = 1085.6584). When I fed tose coordinates to LVM, I got some strange results.
While

Code: Select all

s = minetest.get_node_or_nil(p6).name
gave me "air"

Code: Select all

local vi = va:index(p6.x, p6.y, p6.z)
local tmp = minetest.get_name_from_content_id(data[vi])
told me it found default:stone.

As a solution, I rounded the coordinates to to full int and the results where consistent. So I guess LVM and minetest.get_node_or_nil handle coordinates with digital places in different ways.

Re: [Mod] Settlements [settlements]

Posted: Sat Jul 21, 2018 12:08
by Krock
Donating my 4000th post to this cute new mod.
I also did some testing and found this town right next to the spawn in my custom Lua mapgen world:
Image