2017-05-16 21:05:17 +02:00
|
|
|
|
|
|
|
--
|
|
|
|
-- Mapgen
|
|
|
|
--
|
2019-08-28 17:31:41 +02:00
|
|
|
local S = minetest.get_translator("village")
|
2017-05-16 21:05:17 +02:00
|
|
|
|
|
|
|
local spawn_pos = minetest.setting_get_pos("static_spawnpoint") or {x = 0, y = 0, z = 0}
|
2017-06-27 21:13:30 +02:00
|
|
|
local spawn_radius = minetest.settings:get("static_spawn_radius") or 256
|
2019-03-20 15:01:03 +01:00
|
|
|
local mapseed = minetest.get_mapgen_setting("seed")
|
2017-05-16 21:05:17 +02:00
|
|
|
|
|
|
|
-- Nodes
|
|
|
|
|
2017-05-12 04:29:55 +02:00
|
|
|
minetest.register_node(
|
2015-09-01 17:15:24 +02:00
|
|
|
"village:entity_spawner",
|
|
|
|
{
|
2019-08-28 17:31:41 +02:00
|
|
|
description = S("Village Entity Spawner"),
|
2015-09-01 17:15:24 +02:00
|
|
|
tiles = {"default_brick.png^default_book.png"},
|
|
|
|
is_ground_content = false,
|
|
|
|
groups = {dig_immediate = 2},
|
2015-09-02 00:13:34 +02:00
|
|
|
sounds = default.node_sound_wood_defaults()
|
2017-05-11 23:10:00 +02:00
|
|
|
})
|
2015-09-01 17:15:24 +02:00
|
|
|
|
2017-05-12 04:29:55 +02:00
|
|
|
minetest.register_node(
|
2015-09-01 17:15:24 +02:00
|
|
|
"village:grassland_village",
|
|
|
|
{
|
2019-08-28 17:31:41 +02:00
|
|
|
description = S("Village Spawner"),
|
2015-09-07 00:10:27 +02:00
|
|
|
tiles = {"default_grass.png^default_book.png"},
|
|
|
|
is_ground_content = false,
|
|
|
|
groups = {dig_immediate = 2},
|
2017-05-16 21:05:17 +02:00
|
|
|
sounds = default.node_sound_wood_defaults(),
|
|
|
|
|
|
|
|
on_construct = function(pos)
|
|
|
|
minetest.remove_node(pos)
|
|
|
|
|
2019-03-20 15:01:03 +01:00
|
|
|
local pr = PseudoRandom(mapseed
|
2017-05-16 21:05:17 +02:00
|
|
|
+ pos.x + pos.y + pos.z)
|
|
|
|
|
|
|
|
village.spawn_village(pos, pr)
|
|
|
|
end,
|
2017-05-11 23:10:00 +02:00
|
|
|
})
|
2015-09-01 17:15:24 +02:00
|
|
|
|
2017-05-12 04:29:55 +02:00
|
|
|
minetest.register_node(
|
2015-09-02 00:13:34 +02:00
|
|
|
"village:grassland_village_mg",
|
2015-09-01 17:15:24 +02:00
|
|
|
{
|
2019-08-28 17:31:41 +02:00
|
|
|
description = S("Mapgen Village Spawner").."\n"..S("(Has chance of not spawning village)"),
|
2019-06-23 22:15:44 +02:00
|
|
|
inventory_image = "default_wood.png^default_book.png",
|
|
|
|
wield_image = "default_wood.png^default_book.png",
|
2015-09-07 00:09:12 +02:00
|
|
|
drawtype = "airlike",
|
|
|
|
paramtype = "light",
|
|
|
|
sunlight_propagates = true,
|
|
|
|
walkable = false,
|
|
|
|
pointable = false,
|
|
|
|
diggable = false,
|
|
|
|
buildable_to = false,
|
|
|
|
is_ground_content = true,
|
|
|
|
air_equivalent = true,
|
|
|
|
drop = "",
|
2019-06-23 23:04:20 +02:00
|
|
|
groups = {not_in_craft_guide = 1},
|
2017-05-11 23:10:00 +02:00
|
|
|
})
|
2015-09-01 17:15:24 +02:00
|
|
|
|
2017-05-16 21:05:17 +02:00
|
|
|
-- Spawning LBM
|
|
|
|
|
|
|
|
minetest.register_lbm(
|
2015-09-01 17:15:24 +02:00
|
|
|
{
|
2017-05-16 21:05:17 +02:00
|
|
|
name = "village:spawn_village",
|
|
|
|
label = "Village spawning",
|
|
|
|
nodenames = {
|
|
|
|
"village:grassland_village_mg",
|
|
|
|
},
|
|
|
|
|
|
|
|
run_at_every_load = true,
|
|
|
|
|
2015-09-01 17:15:24 +02:00
|
|
|
action = function(pos, node)
|
2017-05-12 04:29:55 +02:00
|
|
|
minetest.remove_node(pos)
|
2017-05-11 23:10:00 +02:00
|
|
|
|
2017-06-27 21:13:30 +02:00
|
|
|
if minetest.settings:get_bool("mapgen_disable_villages") == true then
|
2017-05-11 23:12:40 +02:00
|
|
|
return
|
|
|
|
end
|
2017-05-11 23:10:00 +02:00
|
|
|
|
2019-03-20 15:01:03 +01:00
|
|
|
local pr = PseudoRandom(mapseed
|
2017-05-16 21:05:17 +02:00
|
|
|
+ pos.x + pos.y + pos.z)
|
2017-05-11 23:10:00 +02:00
|
|
|
|
2019-03-20 15:01:03 +01:00
|
|
|
if ((mapseed + pos.x + pos.y + pos.z) % 30) == 1 then
|
2017-05-16 21:05:17 +02:00
|
|
|
local nearest = village.get_nearest_village(pos)
|
2017-05-11 23:10:00 +02:00
|
|
|
|
2017-05-16 21:05:17 +02:00
|
|
|
if nearest.dist > village.min_spawn_dist then
|
|
|
|
if vector.distance(spawn_pos, pos) > spawn_radius then
|
|
|
|
minetest.log("Spawning a Grassland village at " .. "(" .. pos.x
|
|
|
|
.. ", " .. pos.y .. ", " .. pos.z .. ")")
|
2017-05-11 23:10:00 +02:00
|
|
|
|
2017-05-16 21:05:17 +02:00
|
|
|
minetest.after(
|
|
|
|
2.0,
|
|
|
|
function()
|
|
|
|
village.spawn_village(pos, pr)
|
|
|
|
end)
|
2017-05-11 23:10:00 +02:00
|
|
|
else
|
2017-05-16 21:05:17 +02:00
|
|
|
minetest.log("Cannot spawn village, too near the static spawnpoint")
|
2017-05-11 23:10:00 +02:00
|
|
|
end
|
2017-05-16 21:05:17 +02:00
|
|
|
else
|
|
|
|
minetest.log("Cannot spawn village, too near another village")
|
2017-05-11 23:10:00 +02:00
|
|
|
end
|
|
|
|
end
|
2017-05-16 21:05:17 +02:00
|
|
|
end,
|
2017-05-11 23:10:00 +02:00
|
|
|
})
|
2015-09-01 17:15:24 +02:00
|
|
|
|
2017-05-16 21:05:17 +02:00
|
|
|
-- Spawn decoration
|
|
|
|
|
2017-06-27 21:13:30 +02:00
|
|
|
if not minetest.settings:get_bool("mapgen_disable_villages") then
|
2017-05-16 21:05:17 +02:00
|
|
|
minetest.register_decoration(
|
|
|
|
{
|
|
|
|
deco_type = "simple",
|
|
|
|
place_on = "default:dirt_with_grass",
|
|
|
|
sidelen = 16,
|
|
|
|
fill_ratio = 0.005,
|
|
|
|
biomes = {
|
|
|
|
"Grassland",
|
|
|
|
"Forest"
|
|
|
|
},
|
|
|
|
decoration = {
|
|
|
|
"village:grassland_village_mg"
|
|
|
|
},
|
|
|
|
y_min = 1,
|
|
|
|
y_max = 1000,
|
|
|
|
})
|
|
|
|
end
|