[MOD] villages

ironzorg
Member
Posts: 46
Joined: Tue Aug 23, 2011 06:34

[MOD] villages

by ironzorg » Post

Hello everyone.

Releasing that mod I made a couple days ago that will randomly place buildings on your map.

Default buildings
Image

Watchtower ruin (built on sand/dirt)

Image

Watchtower (built on sand/dirt)

Image

Wooden house (built on dirt)

How it works
  • You declare the building in the buildings.lua file (cf below)
  • You force the server to generate new chunks
  • Enjoy !
For each new chunk generated, the mod will try to place the building on the map: if it fits, it uses the value (the `odds`) you declared for that building to decide weither the building can be placed or not.

How to declare new buildings
The buildings file is basically a single table in which you have to declare your buildings. It uses the variables:
  • name: the name of the building
  • size: the dimensions of the building (in relation to the `structure` variable
  • odds: chances the building has to be placed on the map for each chunk it fits in
  • building_surfaces: a table of the nodes the building can be placed on
  • structure: the actual building
The mod
I called it "villages" but it's merely a mod that allows you to place random buildings on the map. It's up to you to make it generate complete towns !

Note that every building you generate has to be AT MOST 15x15x15 nodes, which is the size of the chunks generated by the server.

Download init.lua

Download buildings.lua
Last edited by ironzorg on Sun Dec 11, 2011 15:44, edited 1 time in total.

sfan5
Moderator
Posts: 4094
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5
Location: Germany

by sfan5 » Post

We need better a File Format for the Buildings
Mods: Mesecons | WorldEdit | Nuke & Minetest builds for Windows (32-bit & 64-bit)

ironzorg
Member
Posts: 46
Joined: Tue Aug 23, 2011 06:34

by ironzorg » Post

sfan5 wrote:We need better a File Format for the Buildings
Unless you are talking about the way the tables are organized, I think what I have here is pretty much the less time consuming way of going through all the available buildings at runtime.

What did you have in mind ?

sfan5
Moderator
Posts: 4094
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5
Location: Germany

by sfan5 » Post

ironzorg wrote:
sfan5 wrote:We need better a File Format for the Buildings
Unless you are talking about the way the tables are organized, I think what I have here is pretty much the less time consuming way of going through all the available buildings at runtime.

What did you have in mind ?
Something like:

Code: Select all

wood,wood,wood,wood <- this is from pos to pos+(4,0,0)
stone,stone,stone,stone <- this is from pos+(0,1,0) to pos+(4,1,0)
;
tree,tree,tree,tree <- this is from pos+(0,0,1) to pos+(4,0,1)
leaves,leaves,leaves,leaves <- this is from pos+(0,1,1) to pos+(4,1,1)
Anything after "<-" is a comment

By the Way, cool Mod!
Last edited by sfan5 on Sat Dec 10, 2011 14:41, edited 1 time in total.
Mods: Mesecons | WorldEdit | Nuke & Minetest builds for Windows (32-bit & 64-bit)

ironzorg
Member
Posts: 46
Joined: Tue Aug 23, 2011 06:34

by ironzorg » Post

sfan5 wrote:
ironzorg wrote:
sfan5 wrote:We need better a File Format for the Buildings
Unless you are talking about the way the tables are organized, I think what I have here is pretty much the less time consuming way of going through all the available buildings at runtime.

What did you have in mind ?
Something like:

Code: Select all

wood,wood,wood,wood <- this is from pos to pos+(4,0,0)
stone,stone,stone,stone <- this is from pos+(0,1,0) to pos+(4,1,0)
;
tree,tree,tree,tree <- this is from pos+(0,0,1) to pos+(4,0,1)
leaves,leaves,leaves,leaves <- this is from pos+(0,1,1) to pos+(4,1,1)
Anything after "<-" is a comment

By the Way, cool Mod!
Thanks.

However: I thought about that format too, the thing is that it adds a lot of code for parsing the file, detecting errors, etc…
I don't feel like doing it right now (although I might in a near future), I'll just focus on improving the main algorithm.

Patches welcome, of course.

sfan5
Moderator
Posts: 4094
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5
Location: Germany

by sfan5 » Post

ironzorg wrote:
sfan5 wrote:...
Thanks.

However: I thought about that format too, the thing is that it adds a lot of code for parsing the file, detecting errors, etc…
I don't feel like doing it right now (although I might in a near future), I'll just focus on improving the main algorithm.

Patches welcome, of course.
I'm working on WorldEdit for Minetest.
Maybe I'll write a parser for this file format
Mods: Mesecons | WorldEdit | Nuke & Minetest builds for Windows (32-bit & 64-bit)

User avatar
lmtea
Member
Posts: 35
Joined: Tue Oct 18, 2011 13:40

by lmtea » Post

Not working for me(

Debug.txt


-------------
Separator
-------------

Debug streams initialized, disable_stderr=0
22:16:40: ACTION[main]: minetest with SER_FMT_VER_HIGHEST=21, VER=0.4.dev-20111209-1 RUN_IN_PLACE=1 USE_GETTEXT=1 INSTALL_PREFIX=/usr/local BUILD_TYPE=Release
22:16:40: INFO[main]: Parsing configuration file: "/home/semen/minetest-dev/minetest/bin/../minetest.conf"
22:16:40: INFO[main]: Settings: Setting not found: "enable-unittests"
22:16:40: INFO[main]: Settings: Setting not found: "server"
22:16:41: INFO[main]: Settings: Setting not found: "speedtests"
22:16:41: INFO[main]: Settings: Setting not found: "random-input"
22:16:41: INFO[main]: text_height=18
22:16:41: INFO[main]: Created main menu
22:16:42: INFO[main]: Dropping main menu
22:16:42: INFO[main]: Updating configuration file: "/home/semen/minetest-dev/minetest/bin/../minetest.conf"
22:16:42: INFO[main]: Creating server
AuthManager: loading from /home/semen/minetest-dev/minetest/bin/../world/auth.txt
BanManager: loading from /home/semen/minetest-dev/minetest/bin/../world/ipban.txt
22:16:42: INFO[main]: Mod search paths:
22:16:42: INFO[main]: /home/semen/minetest-dev/minetest/bin/../usermods
22:16:42: INFO[main]: /home/semen/minetest-dev/minetest/bin/../world/worldmods
22:16:42: INFO[main]: /home/semen/minetest-dev/minetest/bin/../data/mods
22:16:42: INFO[main]: Server: Initializing scripting
22:16:42: INFO[main]: scriptapi_export
22:16:42: INFO[main]: Server: Loading builtin Lua stuff from "/home/semen/minetest-dev/minetest/bin/../data/builtin.lua"
22:16:42: INFO[main]: Loading and running script from /home/semen/minetest-dev/minetest/bin/../data/builtin.lua
22:16:42: INFO[main]: registerNode: registering content id "126": name="air"
22:16:42: INFO[main]: registerNode: registering content id "127": name="ignore"
22:16:42: INFO[main]: registerNode: WARNING: Ignoring CONTENT_IGNORE redefinition
22:16:42: INFO[main]: Server: Loading mod "villages"
22:16:42: INFO[main]: Loading and running script from /home/semen/minetest-dev/minetest/bin/../data/mods/villages/init.lua
22:16:42: ERROR[main]: Failed to load and run script from /home/semen/minetest-dev/minetest/bin/../data/mods/villages/init.lua:
22:16:42: ERROR[main]: [LUA]
22:16:42: ERROR[main]: [LUA] ...test-dev/minetest/bin/../data/mods/villages/init.lua:1: module 'data/mods/villages/buildings' not found:
22:16:42: ERROR[main]: no field package.preload['data/mods/villages/buildings']
22:16:42: ERROR[main]: no file './data/mods/villages/buildings.lua'
22:16:42: ERROR[main]: no file '/usr/local/share/lua/5.1/data/mods/villages/buildings.lua'
22:16:42: ERROR[main]: no file '/usr/local/share/lua/5.1/data/mods/villages/buildings/init.lua'
22:16:42: ERROR[main]: no file '/usr/local/lib/lua/5.1/data/mods/villages/buildings.lua'
22:16:42: ERROR[main]: no file '/usr/local/lib/lua/5.1/data/mods/villages/buildings/init.lua'
22:16:42: ERROR[main]: no file './data/mods/villages/buildings.so'
22:16:42: ERROR[main]: no file '/usr/local/lib/lua/5.1/data/mods/villages/buildings.so'
22:16:42: ERROR[main]: no file '/usr/local/lib/lua/5.1/loadall.so'
22:16:42: ERROR[main]: stack traceback:
22:16:42: ERROR[main]: [C]: in function 'require'
22:16:42: ERROR[main]: ...test-dev/minetest/bin/../data/mods/villages/init.lua:1: in main chunk
22:16:42: ERROR[main]: [LUA]
22:16:42: ERROR[main]: Server: Failed to load and run /home/semen/minetest-dev/minetest/bin/../data/mods/villages/init.lua
BanManager: saving to /home/semen/minetest-dev/minetest/bin/../world/ipban.txt
AuthManager: saving to /home/semen/minetest-dev/minetest/bin/../world/auth.txt
22:16:42: ERROR[main]: ModError: Failed to load and run /home/semen/minetest-dev/minetest/bin/../data/mods/villages/init.lua
22:16:42: ERROR[main]: error_message = ModError: Failed to load and run /home/semen/minetest-dev/minetest/bin/../data/mods/villages/init.lua
22:16:42: ERROR[main]: Check debug.txt for details.
22:16:42: INFO[main]: Created main menu

sfan5
Moderator
Posts: 4094
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5
Location: Germany

by sfan5 » Post

You forgot to download buildings.lua
Mods: Mesecons | WorldEdit | Nuke & Minetest builds for Windows (32-bit & 64-bit)

User avatar
lmtea
Member
Posts: 35
Joined: Tue Oct 18, 2011 13:40

by lmtea » Post

No, I have it.

sfan5
Moderator
Posts: 4094
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5
Location: Germany

by sfan5 » Post

Try to change

Code: Select all

require('data/mods/villages/buildings')
to

Code: Select all

require('buildings')
Mods: Mesecons | WorldEdit | Nuke & Minetest builds for Windows (32-bit & 64-bit)

bwog
Member
Posts: 283
Joined: Wed Nov 30, 2011 14:09
Location: United States
Contact:

by bwog » Post

Once the bugs get sorted out I'll try it.

User avatar
xyz
Member
Posts: 450
Joined: Thu Nov 10, 2011 14:25

by xyz » Post

Nice mod. Just some ideas:
1) use table.getn() to get table size (and dont make user to input x, y and z for every building)
2) maybe make chances depend on what buildings are near? to finally make villages (for example - farm near house, etc..)

ironzorg
Member
Posts: 46
Joined: Tue Aug 23, 2011 06:34

by ironzorg » Post

xyz wrote:Nice mod. Just some ideas:
1) use table.getn() to get table size (and dont make user to input x, y and z for every building)
2) maybe make chances depend on what buildings are near? to finally make villages (for example - farm near house, etc..)
No, I want to be able to draw parts of a building.

MrThebuilder3: your mod folders has to be called 'village'. Also paste your debug.txt file to codepad instead of flooding this thread.

User avatar
MrThebuilder3
Member
Posts: 104
Joined: Sat Nov 19, 2011 18:26

by MrThebuilder3 » Post

i'll try that and sorry

User avatar
MrThebuilder3
Member
Posts: 104
Joined: Sat Nov 19, 2011 18:26

by MrThebuilder3 » Post

nope:(

User avatar
xyz
Member
Posts: 450
Joined: Thu Nov 10, 2011 14:25

by xyz » Post

ironzorg wrote:
xyz wrote:Nice mod. Just some ideas:
1) use table.getn() to get table size (and dont make user to input x, y and z for every building)
2) maybe make chances depend on what buildings are near? to finally make villages (for example - farm near house, etc..)
No, I want to be able to draw parts of a building.

MrThebuilder3: your mod folders has to be called 'village'. Also paste your debug.txt file to codepad instead of flooding this thread.
ah, ok, got your idea
but what about number 1)?

Wolfgang
Member
Posts: 37
Joined: Thu Jun 23, 2011 11:21

by Wolfgang » Post

Is there a way to distinguish auto generated buildings from player made content? Otherwise this gives a new excuse for griefing: "Oh that was your building? I assumed it to be some auto-generated place."

User avatar
neko259
Member
Posts: 805
Joined: Sun Jun 19, 2011 06:51

by neko259 » Post

Wolfgang wrote:Is there a way to distinguish auto generated buildings from player made content? Otherwise this gives a new excuse for griefing: "Oh that was your building? I assumed it to be some auto-generated place."
Maybe add some sign near the building door. For example, "AUTO 0001" or something similar.
s3tuPDfUv2IyvXHzPmE31MQvnWULv1zj

User avatar
lmtea
Member
Posts: 35
Joined: Tue Oct 18, 2011 13:40

by lmtea » Post

Not working(

ironzorg
Member
Posts: 46
Joined: Tue Aug 23, 2011 06:34

by ironzorg » Post

To install the mod, just create a `villages` folder in your mods directory and paste init.lua and buildings.lua in it. Create a new file called depends.txt that contains `default`.

And the most important: lua uses your PWD to locate the mods, so launch the game from the main minetest directory (where the data folder is).

Nothing fancy, I didn't think I would have to explain all this. Ima try to fix this though, its annoying to have mod pwd reliant.
neko259 wrote:
Wolfgang wrote: Is there a way to distinguish auto generated buildings from player made content? Otherwise this gives a new excuse for griefing: "Oh that was your building? I assumed it to be some auto-generated place."
Maybe add some sign near the building door. For example, "AUTO 0001" or something similar.
I don't think a sign will do the trick. I don't think you can really check that your automatically generated buildings are not turned to a pile of dust by some griefers.
Well, there is one way: make a server mod that disallow harvesting of groups of blocks (= the buildings), but even you will probably need to destroy an annoying watchtower that spawned out of nowhere on the space you wanted to build a giant castle.

User avatar
Staffs
Member
Posts: 329
Joined: Thu Aug 04, 2011 13:16

by Staffs » Post

ironzorg wrote:Hello everyone.

Image

Wooden house (built on dirt)
Hey behind the tree there is something like jellyfish but grey... What is it ?
I love mods :D

User avatar
lmtea
Member
Posts: 35
Joined: Tue Oct 18, 2011 13:40

by lmtea » Post

It's rat)

Wolfgang
Member
Posts: 37
Joined: Thu Jun 23, 2011 11:21

by Wolfgang » Post

ironzorg wrote: I don't think a sign will do the trick. I don't think you can really check that your automatically generated buildings are not turned to a pile of dust by some griefers.
Well, there is one way: make a server mod that disallow harvesting of groups of blocks (= the buildings), but even you will probably need to destroy an annoying watchtower that spawned out of nowhere on the space you wanted to build a giant castle.
Exactly. If a player made the annoying watchtower I'd have to build somewhere else. But if it is a automatically generated building, not claimed by any player it is pickaxe time. At the moment it is usually easy to tell if the structure is a generated dungeon or something else. (Unless it is a already vandalized building). So some sign might help. Then again first griefer steals sign or changes sign on player's building to

ironzorg
Member
Posts: 46
Joined: Tue Aug 23, 2011 06:34

by ironzorg » Post

Staffs wrote:
ironzorg wrote:Hello everyone.

Image

Wooden house (built on dirt)
Hey behind the tree there is something like jellyfish but grey... What is it ?
It is indeed a rat, from g4cj's texture pack.

I will fix the require('buildings') bug whenever the repo gets updated, but for now you will have to launch the game from its main directory.

EDIT: Thanks to celeron55's patch, this bug is fixed in the current dev release. I updated the init.lua file.
Last edited by ironzorg on Sun Dec 11, 2011 15:46, edited 1 time in total.

User avatar
RabbiBob
Member
Posts: 335
Joined: Sat Jan 28, 2012 22:40
Location: /teleport 54,47,28
Contact:

by RabbiBob » Post


Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests