forked from VoxeLibre/VoxeLibre
Merge branch 'master' into simplified_palette_index
This commit is contained in:
commit
09db6017c3
|
@ -79,19 +79,27 @@ function settlements.create_site_plan(maxp, minp, pr)
|
||||||
local settlement_info = {}
|
local settlement_info = {}
|
||||||
local building_all_info
|
local building_all_info
|
||||||
local possible_rotations = {"0", "90", "180", "270"}
|
local possible_rotations = {"0", "90", "180", "270"}
|
||||||
|
|
||||||
-- find center of chunk
|
-- find center of chunk
|
||||||
local center = {
|
local center = {
|
||||||
x=math.floor((minp.x+maxp.x)/2),
|
x=math.floor((minp.x+maxp.x)/2),
|
||||||
y=maxp.y,
|
y=maxp.y,
|
||||||
z=math.floor((minp.z+maxp.z)/2)
|
z=math.floor((minp.z+maxp.z)/2)
|
||||||
}
|
}
|
||||||
|
|
||||||
-- find center_surface of chunk
|
-- find center_surface of chunk
|
||||||
local center_surface , surface_material = settlements.find_surface(center, true)
|
local center_surface , surface_material = settlements.find_surface(center, true)
|
||||||
local chunks = {}
|
local chunks = {}
|
||||||
chunks[mcl_vars.get_chunk_number(center)] = true
|
chunks[mcl_vars.get_chunk_number(center)] = true
|
||||||
|
|
||||||
-- go build settlement around center
|
-- go build settlement around center
|
||||||
if not center_surface then return false end
|
if not center_surface then
|
||||||
|
minetest.log("action", "Cannot build village at: " .. minetest.pos_to_string(center))
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
minetest.log("action", "Village built.")
|
||||||
|
--minetest.log("action", "Build village at: " .. minetest.pos_to_string(center) .. " with surface material: " .. surface_material)
|
||||||
|
end
|
||||||
|
|
||||||
-- initialize all settlement_info table
|
-- initialize all settlement_info table
|
||||||
local count_buildings, number_of_buildings, number_built = settlements.initialize_settlement_info(pr)
|
local count_buildings, number_of_buildings, number_built = settlements.initialize_settlement_info(pr)
|
||||||
|
@ -190,6 +198,7 @@ local function construct_node(p1, p2, name)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function spawn_iron_golem(pos)
|
local function spawn_iron_golem(pos)
|
||||||
|
--minetest.log("action", "Attempt to spawn iron golem.")
|
||||||
local p = minetest.find_node_near(pos,50,"mcl_core:grass_path")
|
local p = minetest.find_node_near(pos,50,"mcl_core:grass_path")
|
||||||
if p then
|
if p then
|
||||||
local l=minetest.add_entity(p,"mobs_mc:iron_golem"):get_luaentity()
|
local l=minetest.add_entity(p,"mobs_mc:iron_golem"):get_luaentity()
|
||||||
|
@ -200,6 +209,7 @@ local function spawn_iron_golem(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function spawn_villagers(minp,maxp)
|
local function spawn_villagers(minp,maxp)
|
||||||
|
--minetest.log("action", "Attempt to spawn villagers.")
|
||||||
local beds=minetest.find_nodes_in_area(vector.offset(minp,-20,-20,-20),vector.offset(maxp,20,20,20),{"mcl_beds:bed_red_bottom"})
|
local beds=minetest.find_nodes_in_area(vector.offset(minp,-20,-20,-20),vector.offset(maxp,20,20,20),{"mcl_beds:bed_red_bottom"})
|
||||||
for _,bed in pairs(beds) do
|
for _,bed in pairs(beds) do
|
||||||
local m = minetest.get_meta(bed)
|
local m = minetest.get_meta(bed)
|
||||||
|
@ -235,23 +245,6 @@ end
|
||||||
function settlements.place_schematics(settlement_info, pr)
|
function settlements.place_schematics(settlement_info, pr)
|
||||||
local building_all_info
|
local building_all_info
|
||||||
|
|
||||||
--attempt to place one belltower in the center of the village - this doesn't always work out great but it's a lot better than doing it first or last.
|
|
||||||
local belltower = table.remove(settlement_info,math.floor(#settlement_info/2))
|
|
||||||
if belltower then
|
|
||||||
mcl_structures.place_schematic(
|
|
||||||
vector.offset(belltower["pos"],0,0,0),
|
|
||||||
settlements.modpath.."/schematics/belltower.mts",
|
|
||||||
belltower["rotation"],
|
|
||||||
nil,
|
|
||||||
true,
|
|
||||||
nil,
|
|
||||||
function(p1, p2, size, rotation, pr)
|
|
||||||
spawn_iron_golem(p1)
|
|
||||||
end,
|
|
||||||
pr
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
for i, built_house in ipairs(settlement_info) do
|
for i, built_house in ipairs(settlement_info) do
|
||||||
local is_last = i == #settlement_info
|
local is_last = i == #settlement_info
|
||||||
|
|
||||||
|
@ -262,6 +255,9 @@ function settlements.place_schematics(settlement_info, pr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local pos = settlement_info[i]["pos"]
|
local pos = settlement_info[i]["pos"]
|
||||||
local rotation = settlement_info[i]["rotat"]
|
local rotation = settlement_info[i]["rotat"]
|
||||||
-- get building node material for better integration to surrounding
|
-- get building node material for better integration to surrounding
|
||||||
|
@ -313,8 +309,11 @@ function settlements.place_schematics(settlement_info, pr)
|
||||||
|
|
||||||
-- format schematic string
|
-- format schematic string
|
||||||
local schematic = loadstring(schem_lua)()
|
local schematic = loadstring(schem_lua)()
|
||||||
|
|
||||||
|
local is_belltower = building_all_info["name"] == "belltower"
|
||||||
|
|
||||||
-- build foundation for the building an make room above
|
-- build foundation for the building an make room above
|
||||||
-- place schematic
|
|
||||||
mcl_structures.place_schematic(
|
mcl_structures.place_schematic(
|
||||||
pos,
|
pos,
|
||||||
schematic,
|
schematic,
|
||||||
|
@ -323,8 +322,12 @@ function settlements.place_schematics(settlement_info, pr)
|
||||||
true,
|
true,
|
||||||
nil,
|
nil,
|
||||||
function(p1, p2, size, rotation, pr)
|
function(p1, p2, size, rotation, pr)
|
||||||
|
if is_belltower then
|
||||||
|
spawn_iron_golem(p1)
|
||||||
|
else
|
||||||
init_nodes(p1, p2, size, rotation, pr)
|
init_nodes(p1, p2, size, rotation, pr)
|
||||||
spawn_villagers(p1,p2)
|
spawn_villagers(p1,p2)
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
pr
|
pr
|
||||||
)
|
)
|
||||||
|
|
|
@ -52,6 +52,7 @@ schem_path = settlements.modpath.."/schematics/"
|
||||||
local basic_pseudobiome_villages = minetest.settings:get_bool("basic_pseudobiome_villages", true)
|
local basic_pseudobiome_villages = minetest.settings:get_bool("basic_pseudobiome_villages", true)
|
||||||
|
|
||||||
settlements.schematic_table = {
|
settlements.schematic_table = {
|
||||||
|
{name = "belltower", mts = schem_path.."belltower.mts", hwidth = 5, hdepth = 5, hheight = 9, hsize = 14, max_num = 0 , rplc = basic_pseudobiome_villages },
|
||||||
{name = "large_house", mts = schem_path.."large_house.mts", hwidth = 12, hdepth = 12, hheight = 9, hsize = 14, max_num = 0.08 , rplc = basic_pseudobiome_villages },
|
{name = "large_house", mts = schem_path.."large_house.mts", hwidth = 12, hdepth = 12, hheight = 9, hsize = 14, max_num = 0.08 , rplc = basic_pseudobiome_villages },
|
||||||
{name = "blacksmith", mts = schem_path.."blacksmith.mts", hwidth = 8, hdepth = 11, hheight = 13, hsize = 13, max_num = 0.055, rplc = basic_pseudobiome_villages },
|
{name = "blacksmith", mts = schem_path.."blacksmith.mts", hwidth = 8, hdepth = 11, hheight = 13, hsize = 13, max_num = 0.055, rplc = basic_pseudobiome_villages },
|
||||||
{name = "butcher", mts = schem_path.."butcher.mts", hwidth = 12, hdepth = 8, hheight = 10, hsize = 14, max_num = 0.03 , rplc = basic_pseudobiome_villages },
|
{name = "butcher", mts = schem_path.."butcher.mts", hwidth = 12, hdepth = 8, hheight = 10, hsize = 14, max_num = 0.03 , rplc = basic_pseudobiome_villages },
|
||||||
|
|
|
@ -40,23 +40,33 @@ function settlements.find_surface(pos, wait)
|
||||||
-- go through nodes an find surface
|
-- go through nodes an find surface
|
||||||
while cnt < cnt_max do
|
while cnt < cnt_max do
|
||||||
-- Check Surface_node and Node above
|
-- Check Surface_node and Node above
|
||||||
--
|
if surface_node and settlements.surface_mat[surface_node.name] then
|
||||||
if settlements.surface_mat[surface_node.name] then
|
|
||||||
local surface_node_plus_1 = get_node({ x=p6.x, y=p6.y+1, z=p6.z})
|
local surface_node_plus_1 = get_node({ x=p6.x, y=p6.y+1, z=p6.z})
|
||||||
if surface_node_plus_1 and surface_node and
|
|
||||||
(string.find(surface_node_plus_1.name,"air") or
|
if surface_node_plus_1 then
|
||||||
string.find(surface_node_plus_1.name,"snow") or
|
|
||||||
|
local surface_node_minus_1 = get_node({ x=p6.x, y=p6.y-1, z=p6.z})
|
||||||
|
local is_leaf_below = minetest.get_item_group(surface_node_minus_1, "leaves") ~= 0 or
|
||||||
|
string.find(surface_node_minus_1.name,"leaves")
|
||||||
|
|
||||||
|
if not is_leaf_below and ((string.find(surface_node_plus_1.name,"air") or
|
||||||
string.find(surface_node_plus_1.name,"fern") or
|
string.find(surface_node_plus_1.name,"fern") or
|
||||||
string.find(surface_node_plus_1.name,"flower") or
|
string.find(surface_node_plus_1.name,"flower") or
|
||||||
string.find(surface_node_plus_1.name,"bush") or
|
string.find(surface_node_plus_1.name,"bush") or
|
||||||
string.find(surface_node_plus_1.name,"tree") or
|
string.find(surface_node_plus_1.name,"tree") or
|
||||||
string.find(surface_node_plus_1.name,"grass"))
|
string.find(surface_node_plus_1.name,"grass")) or
|
||||||
|
string.find(surface_node_plus_1.name,"snow"))
|
||||||
then
|
then
|
||||||
settlements.debug("find_surface7: " ..surface_node.name.. " " .. surface_node_plus_1.name)
|
settlements.debug("find_surface success: " ..surface_node.name.. " " .. surface_node_plus_1.name)
|
||||||
|
settlements.debug("node below: " .. tostring(surface_node_minus_1.name))
|
||||||
|
settlements.debug("node below leaves group: " .. tostring(minetest.get_item_group(surface_node_minus_1, "leaves")))
|
||||||
return p6, surface_node.name
|
return p6, surface_node.name
|
||||||
else
|
else
|
||||||
settlements.debug("find_surface2: wrong surface+1")
|
settlements.debug("find_surface2: wrong surface+1")
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
settlements.debug("find_surface8: missing node or plus_1")
|
||||||
|
end
|
||||||
else
|
else
|
||||||
settlements.debug("find_surface3: wrong surface "..surface_node.name.." at pos "..minetest.pos_to_string(p6))
|
settlements.debug("find_surface3: wrong surface "..surface_node.name.." at pos "..minetest.pos_to_string(p6))
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue