forked from VoxeLibre/VoxeLibre
add MCLA schematics
This commit is contained in:
parent
d89eec9d98
commit
79d96e9ea0
|
@ -1,59 +1,3 @@
|
|||
--[[
|
||||
-------------------------------------------------------------------------------
|
||||
-- build schematic, replace material, rotation
|
||||
-------------------------------------------------------------------------------
|
||||
function mcl_villages.build_schematic(vm, data, va, pos, building, replace_wall, name)
|
||||
-- get building node material for better integration to surrounding
|
||||
local platform_material = mcl_vars.get_node(pos)
|
||||
if not platform_material or (platform_material.name == "air" or platform_material.name == "ignore") then
|
||||
return
|
||||
end
|
||||
platform_material = platform_material.name
|
||||
-- pick random material
|
||||
local material = wallmaterial[math.random(1,#wallmaterial)]
|
||||
-- schematic conversion to lua
|
||||
local schem_lua = minetest.serialize_schematic(building,
|
||||
"lua",
|
||||
{lua_use_comments = false, lua_num_indent_spaces = 0}).." return schematic"
|
||||
-- replace material
|
||||
if replace_wall == "y" then
|
||||
schem_lua = schem_lua:gsub("mcl_core:cobble", material)
|
||||
end
|
||||
schem_lua = schem_lua:gsub("mcl_core:dirt_with_grass",
|
||||
platform_material)
|
||||
|
||||
-- Disable special junglewood for now.
|
||||
-- special material for spawning npcs
|
||||
-- schem_lua = schem_lua:gsub("mcl_core:junglewood",
|
||||
-- "settlements:junglewood")
|
||||
--
|
||||
|
||||
-- format schematic string
|
||||
local schematic = loadstring(schem_lua)()
|
||||
-- build foundation for the building an make room above
|
||||
local width = schematic["size"]["x"]
|
||||
local depth = schematic["size"]["z"]
|
||||
local height = schematic["size"]["y"]
|
||||
local possible_rotations = {"0", "90", "180", "270"}
|
||||
local rotation = possible_rotations[ math.random( #possible_rotations ) ]
|
||||
mcl_villages.foundation(
|
||||
pos,
|
||||
width,
|
||||
depth,
|
||||
height,
|
||||
rotation)
|
||||
vm:set_data(data)
|
||||
-- place schematic
|
||||
|
||||
minetest.place_schematic_on_vmanip(
|
||||
vm,
|
||||
pos,
|
||||
schematic,
|
||||
rotation,
|
||||
nil,
|
||||
true)
|
||||
vm:write_to_map(true)
|
||||
end]]
|
||||
-------------------------------------------------------------------------------
|
||||
-- initialize settlement_info
|
||||
-------------------------------------------------------------------------------
|
||||
|
@ -76,33 +20,33 @@ end
|
|||
-------------------------------------------------------------------------------
|
||||
-- check ground for a single building
|
||||
-------------------------------------------------------------------------------
|
||||
local function try_place_building(pos_surface, building_all_info, rotation, settlement_info, pr)
|
||||
local fwidth, fdepth = building_all_info["hwidth"], building_all_info["hdepth"]
|
||||
local function try_place_building(minp, maxp, pos_surface, building_all_info, rotation, settlement_info, pr)
|
||||
local fwidth, fdepth = building_all_info["hwidth"] or 5, building_all_info["hdepth"] or 5
|
||||
if rotation == "90" or rotation == "270" then fwidth, fdepth = fdepth, fwidth end
|
||||
local fheight = building_all_info["hheight"]
|
||||
local fheight = building_all_info["hheight"] or 5
|
||||
-- use building centers for better placement
|
||||
pos_surface.x = pos_surface.x - math.ceil(fwidth / 2)
|
||||
pos_surface.z = pos_surface.z - math.ceil(fdepth / 2)
|
||||
-- ensure we have 3 space for terraforming
|
||||
if pos_surface.x - 3 < minp.x or pos_surface.z + 3 < minp.z or pos_surface.x + fwidth + 3 > maxp.x or pos_surface.z + fheight + 3 > maxp.z then return nil end
|
||||
-- to find the y position, also check the corners
|
||||
local ys = {pos_surface.y}
|
||||
local pos_c
|
||||
pos_c = mcl_villages.find_surface_down(vector.new(pos_surface.x-1, pos_surface.y+fheight, pos_surface.z-1))
|
||||
pos_c = mcl_villages.find_surface_down(vector.new(pos_surface.x, pos_surface.y+fheight, pos_surface.z))
|
||||
if pos_c then table.insert(ys, pos_c.y) end
|
||||
pos_c = mcl_villages.find_surface_down(vector.new(pos_surface.x+fwidth+2, pos_surface.y+fheight, pos_surface.z-1))
|
||||
pos_c = mcl_villages.find_surface_down(vector.new(pos_surface.x+fwidth-1, pos_surface.y+fheight, pos_surface.z))
|
||||
if pos_c then table.insert(ys, pos_c.y) end
|
||||
pos_c = mcl_villages.find_surface_down(vector.new(pos_surface.x-1, pos_surface.y+fheight, pos_surface.z+fdepth+2))
|
||||
pos_c = mcl_villages.find_surface_down(vector.new(pos_surface.x, pos_surface.y+fheight, pos_surface.z+fdepth-1))
|
||||
if pos_c then table.insert(ys, pos_c.y) end
|
||||
pos_c = mcl_villages.find_surface_down(vector.new(pos_surface.x+fwidth+2, pos_surface.y+fheight, pos_surface.z+fdepth+2))
|
||||
pos_c = mcl_villages.find_surface_down(vector.new(pos_surface.x+fwidth-1, pos_surface.y+fheight, pos_surface.z+fdepth-1))
|
||||
if pos_c then table.insert(ys, pos_c.y) end
|
||||
table.sort(ys)
|
||||
-- well supported base, not too uneven?
|
||||
if #ys < 5 or ys[#ys]-ys[1] > fheight + 3 then return nil end
|
||||
pos_surface.y = ys[math.ceil(#ys/2)]
|
||||
-- check distance to other buildings
|
||||
if mcl_villages.check_distance(settlement_info, pos_surface, building_all_info["hsize"]) then
|
||||
return pos_surface
|
||||
end
|
||||
return nil
|
||||
if not mcl_villages.check_distance(settlement_info, pos_surface, math.max(fheight, fdepth)) then return nil end
|
||||
return pos_surface
|
||||
end
|
||||
-------------------------------------------------------------------------------
|
||||
-- fill settlement_info
|
||||
|
@ -132,7 +76,7 @@ function mcl_villages.create_site_plan(minp, maxp, pr)
|
|||
-- already enough buildings of that type?
|
||||
if count_buildings[building_all_info["name"]] < building_all_info["max_num"]*number_of_buildings then
|
||||
local rotation = possible_rotations[pr:next(1, #possible_rotations)]
|
||||
local pos = try_place_building(pos_surface, building_all_info, rotation, settlement_info, pr)
|
||||
local pos = try_place_building(minp, maxp, pos_surface, building_all_info, rotation, settlement_info, pr)
|
||||
if pos then
|
||||
if #settlement_info == 0 then -- town bell
|
||||
center_surface, y = pos, pos.y + max_height_difference
|
||||
|
@ -148,7 +92,7 @@ function mcl_villages.create_site_plan(minp, maxp, pr)
|
|||
table.insert(settlement_info, {
|
||||
pos = pos,
|
||||
name = building_all_info["name"],
|
||||
hsize = building_all_info["hsize"],
|
||||
hsize = math.max(building_all_info["hwidth"], building_all_info["hdepth"]), -- ,building_all_info["hsize"],
|
||||
rotat = rotation,
|
||||
surface_mat = surface_material
|
||||
})
|
||||
|
@ -170,12 +114,12 @@ function mcl_villages.create_site_plan(minp, maxp, pr)
|
|||
if r > 35 then break end -- avoid touching neighboring blocks
|
||||
end
|
||||
mcl_villages.debug("really ".. number_built)
|
||||
if number_built <= 8 then
|
||||
if number_built < 8 then
|
||||
minetest.log("action", "Bad village location, could only place "..number_built.." buildings.")
|
||||
return
|
||||
end
|
||||
minetest.log("action", "Village completed at " .. minetest.pos_to_string(center))
|
||||
minetest.log("Village completed at " .. minetest.pos_to_string(center)) -- for debugging only
|
||||
--minetest.log("Village completed at " .. minetest.pos_to_string(center)) -- for debugging only
|
||||
return settlement_info
|
||||
end
|
||||
-------------------------------------------------------------------------------
|
||||
|
@ -275,18 +219,28 @@ function mcl_villages.place_schematics(settlement_info, pr)
|
|||
local schem_lua = building_all_info["schem_lua"]
|
||||
if not schem_lua then
|
||||
schem_lua = minetest.serialize_schematic(building_all_info["mts"], "lua", { lua_use_comments = false, lua_num_indent_spaces = 0 }) .. " return schematic"
|
||||
-- MCLA node names to VL for import
|
||||
for _, sub in pairs(mcl_villages.mcla_to_vl) do
|
||||
schem_lua = schem_lua:gsub(sub[1], sub[2])
|
||||
end
|
||||
local schematic = loadstring(schem_lua)()
|
||||
if schematic.size["x"] ~= building_all_info["hwidth"] or schematic.size["y"] ~= building_all_info["hheight"] or schematic.size["z"] ~= building_all_info["hdepth"] then
|
||||
minetest.log(building_all_info["name"].." width "..schematic.size["x"].." height "..schematic.size["y"].." depth "..schematic.size["z"])
|
||||
end
|
||||
building_all_info["schem_lua"] = schem_lua
|
||||
end
|
||||
schem_lua = schem_lua:gsub('"mcl_core:dirt"', '"'..platform_material..'"')
|
||||
schem_lua = schem_lua:gsub('"mcl_core:dirt_with_grass"', '"'..surface_material..'"')
|
||||
local schematic = loadstring(mcl_villages.substitute_materials(pos, schem_lua, pr))()
|
||||
|
||||
local is_belltower = building_all_info["name"] == "belltower"
|
||||
|
||||
-- already built the foundation for the building and made room above
|
||||
local sx, sy, sz = schematic.size.x, schematic.size.y, schematic.size.z
|
||||
if rotation == "90" or rotation == "270" then sx, sz = sz, sx end
|
||||
local p2 = vector.new(pos.x+sx-1,pos.y+sy-1,pos.z+sz-1)
|
||||
lvm:read_from_map(pos, p2)
|
||||
lvm:read_from_map(vector.new(pos.x-3, pos.y-40, pos.z-3), vector.new(pos.x+sx+3, pos.y+sy+40, pos.z+sz+3)) -- safety margins for foundation
|
||||
lvm:get_data()
|
||||
-- TODO: make configurable as in MCLA
|
||||
mcl_villages.foundation(lvm, pos, sx, sy, sz, surface_material, pr)
|
||||
minetest.place_schematic_on_vmanip(
|
||||
lvm,
|
||||
pos,
|
||||
|
@ -297,14 +251,12 @@ function mcl_villages.place_schematics(settlement_info, pr)
|
|||
{ place_center_x = false, place_center_y = false, place_center_z = false }
|
||||
)
|
||||
lvm:write_to_map(true) -- FIXME: postpone
|
||||
if rotation == "90" or rotation == "270" then sx, sz = sz, sx end
|
||||
init_nodes(pos, p2, schematic.size, rotation, pr)
|
||||
|
||||
if is_belltower then
|
||||
if building_all_info["name"] == "belltower" then
|
||||
spawn_iron_golem(pos)
|
||||
else
|
||||
spawn_villagers(pos,p2)
|
||||
fix_village_water(pos,p2)
|
||||
end
|
||||
spawn_villagers(pos,p2)
|
||||
fix_village_water(pos,p2)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -59,18 +59,47 @@ schem_path = mcl_villages.modpath.."/schematics/"
|
|||
local basic_pseudobiome_villages = minetest.settings:get_bool("basic_pseudobiome_villages", true)
|
||||
|
||||
mcl_villages.schematic_table = {
|
||||
{name = "belltower", mts = schem_path.."belltower.mts", hwidth = 5, hdepth = 5, hheight = 9, hsize = 14, max_num = 0.0001 , rplc = basic_pseudobiome_villages, yadjust = 1 },
|
||||
{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 = "butcher", mts = schem_path.."butcher.mts", hwidth = 12, hdepth = 8, hheight = 10, hsize = 14, max_num = 0.03 , rplc = basic_pseudobiome_villages },
|
||||
{name = "church", mts = schem_path.."church.mts", hwidth = 13, hdepth = 13, hheight = 14, hsize = 15, max_num = 0.04 , rplc = basic_pseudobiome_villages },
|
||||
{name = "farm", mts = schem_path.."farm.mts", hwidth = 9, hdepth = 7, hheight = 13, hsize = 13, max_num = 0.1 , rplc = basic_pseudobiome_villages, yadjust = 1 },
|
||||
{name = "lamp", mts = schem_path.."lamp.mts", hwidth = 3, hdepth = 4, hheight = 13, hsize = 10, max_num = 0.1 , rplc = false },
|
||||
{name = "library", mts = schem_path.."library.mts", hwidth = 12, hdepth = 12, hheight = 8, hsize = 13, max_num = 0.04 , rplc = basic_pseudobiome_villages },
|
||||
{name = "medium_house", mts = schem_path.."medium_house.mts", hwidth = 9, hdepth = 12, hheight = 8, hsize = 14, max_num = 0.08 , rplc = basic_pseudobiome_villages },
|
||||
{name = "small_house", mts = schem_path.."small_house.mts", hwidth = 9, hdepth = 8, hheight = 8, hsize = 13, max_num = 0.7 , rplc = basic_pseudobiome_villages },
|
||||
{name = "tavern", mts = schem_path.."tavern.mts", hwidth = 12, hdepth = 10, hheight = 10, hsize = 13, max_num = 0.050, rplc = basic_pseudobiome_villages },
|
||||
{name = "well", mts = schem_path.."well.mts", hwidth = 6, hdepth = 8, hheight = 6, hsize = 10, max_num = 0.045, rplc = basic_pseudobiome_villages },
|
||||
{name = "belltower", mts = schem_path.."new_villages/belltower.mts", hwidth = 9, hdepth = 9, hheight = 7, hsize = 12, max_num = 0.01 , rplc = basic_pseudobiome_villages, yadjust = 1, yadjust = 1 },
|
||||
{name = "old_belltower", mts = schem_path.."belltower.mts", hwidth = 5, hdepth = 5, hheight = 6, hsize = 8, max_num = 0, rplc = basic_pseudobiome_villages, yadjust = 1 },
|
||||
{name = "large_house", mts = schem_path.."large_house.mts", hwidth = 12, hdepth = 12, hheight = 10, hsize = 18, max_num = 0.08 , rplc = basic_pseudobiome_villages },
|
||||
{name = "blacksmith", mts = schem_path.."blacksmith.mts", hwidth = 8, hdepth = 11, hheight = 8, hsize = 15, max_num = 0.01 , rplc = basic_pseudobiome_villages },
|
||||
{name = "new_blacksmith", mts = schem_path.."new_villages/blacksmith.mts", hwidth = 9, hdepth = 11, hheight = 8, hsize = 15, max_num = 0.01 , rplc = basic_pseudobiome_villages, yadjust = 1 },
|
||||
{name = "weaponsmith", mts = schem_path.."new_villages/weaponsmith.mts", hwidth = 11, hdepth = 9, hheight = 6, hsize = 15, max_num = 0.01 , rplc = basic_pseudobiome_villages, yadjust = 1 },
|
||||
{name = "toolsmith", mts = schem_path.."new_villages/toolsmith.mts", hwidth = 9, hdepth = 11, hheight = 6, hsize = 15, max_num = 0.01 , rplc = basic_pseudobiome_villages, yadjust = 1 },
|
||||
{name = "tannery", mts = schem_path.."new_villages/leather_worker.mts", hwidth = 8, hdepth = 8, hheight = 7, hsize = 12, max_num = 0.01 , rplc = basic_pseudobiome_villages, yadjust = 1 },
|
||||
{name = "butcher", mts = schem_path.."butcher.mts", hwidth = 12, hdepth = 8, hheight = 10, hsize = 15, max_num = 0.01 , rplc = basic_pseudobiome_villages },
|
||||
{name = "church", mts = schem_path.."church.mts", hwidth = 13, hdepth = 14, hheight = 15, hsize = 20, max_num = 0.01 , rplc = basic_pseudobiome_villages },
|
||||
{name = "newchurch", mts = schem_path.."new_villages/church.mts", hwidth = 14, hdepth = 16, hheight = 13, hsize = 22, max_num = 0.01 , rplc = basic_pseudobiome_villages, yadjust = 1 },
|
||||
{name = "chapel", mts = schem_path.."new_villages/chapel.mts", hwidth = 9, hdepth = 10, hheight = 6, hsize = 14, max_num = 0.01 , rplc = basic_pseudobiome_villages, yadjust = 1 },
|
||||
{name = "farm", mts = schem_path.."farm.mts", hwidth = 9, hdepth = 7, hheight = 8, hsize = 12, max_num = 0.1 , rplc = basic_pseudobiome_villages, yadjust = 0 },
|
||||
{name = "lamp", mts = schem_path.."lamp.mts", hwidth = 3, hdepth = 4, hheight = 6, hsize = 6, max_num = 0.001 , rplc = false },
|
||||
{name = "lamp_1", mts = schem_path.."new_villages/lamp_1.mts", hwidth = 1, hdepth = 1, hheight = 4, hsize = 2, max_num = 0.001 , rplc = false, yadjust = 1 },
|
||||
{name = "lamp_2", mts = schem_path.."new_villages/lamp_2.mts", hwidth = 1, hdepth = 2, hheight = 6, hsize = 3, max_num = 0.001 , rplc = false, yadjust = 1 },
|
||||
{name = "lamp_3", mts = schem_path.."new_villages/lamp_3.mts", hwidth = 3, hdepth = 3, hheight = 4, hsize = 5, max_num = 0.001 , rplc = false, yadjust = 1 },
|
||||
{name = "lamp_4", mts = schem_path.."new_villages/lamp_4.mts", hwidth = 1, hdepth = 2, hheight = 5, hsize = 3, max_num = 0.001 , rplc = false, yadjust = 1 },
|
||||
{name = "lamp_5", mts = schem_path.."new_villages/lamp_5.mts", hwidth = 1, hdepth = 1, hheight = 2, hsize = 2, max_num = 0.001 , rplc = false, yadjust = 1 },
|
||||
{name = "lamp_6", mts = schem_path.."new_villages/lamp_6.mts", hwidth = 1, hdepth = 1, hheight = 3, hsize = 2, max_num = 0.001 , rplc = false, yadjust = 1 },
|
||||
{name = "library", mts = schem_path.."library.mts", hwidth = 12, hdepth = 12, hheight = 9, hsize = 18, max_num = 0.01 , rplc = basic_pseudobiome_villages },
|
||||
{name = "newlibrary", mts = schem_path.."new_villages/library.mts", hwidth = 14, hdepth = 14, hheight = 7, hsize = 21, max_num = 0.01 , rplc = basic_pseudobiome_villages, yadjust = 1 },
|
||||
{name = "medium_house", mts = schem_path.."medium_house.mts", hwidth = 9, hdepth = 12, hheight = 9, hsize = 16, max_num = 0.08 , rplc = basic_pseudobiome_villages },
|
||||
{name = "small_house", mts = schem_path.."small_house.mts", hwidth = 9, hdepth = 8, hheight = 9, hsize = 13, max_num = 0.3 , rplc = basic_pseudobiome_villages },
|
||||
{name = "house_1_bed", mts = schem_path.."new_villages/house_1_bed.mts", hwidth = 9, hdepth = 8, hheight = 7, hsize = 13, max_num = 0.3 , rplc = basic_pseudobiome_villages, yadjust = 1 },
|
||||
{name = "house_2_bed", mts = schem_path.."new_villages/house_2_bed.mts", hwidth = 11, hdepth = 8, hheight = 7, hsize = 15, max_num = 0.2 , rplc = basic_pseudobiome_villages, yadjust = 1 },
|
||||
{name = "house_3_bed", mts = schem_path.."new_villages/house_3_bed.mts", hwidth = 11, hdepth = 13, hheight = 9, hsize = 18, max_num = 0.1 , rplc = basic_pseudobiome_villages, yadjust = 1 },
|
||||
{name = "house_4_bed", mts = schem_path.."new_villages/house_4_bed.mts", hwidth = 11, hdepth = 13, hheight = 10, hsize = 18, max_num = 0.1 , rplc = basic_pseudobiome_villages, yadjust = 1 },
|
||||
{name = "mason", mts = schem_path.."new_villages/mason.mts", hwidth = 8, hdepth = 8, hheight = 7, hsize = 12, max_num = 0.01 , rplc = basic_pseudobiome_villages, yadjust = 1 },
|
||||
{name = "mill", mts = schem_path.."new_villages/mill.mts", hwidth = 8, hdepth = 8, hheight = 7, hsize = 12, max_num = 0.01 , rplc = basic_pseudobiome_villages, yadjust = 1 },
|
||||
{name = "cartographer", mts = schem_path.."new_villages/cartographer.mts", hwidth = 9, hdepth = 12, hheight = 6, hsize = 16, max_num = 0.01 , rplc = basic_pseudobiome_villages, yadjust = 2 },
|
||||
{name = "fletcher", mts = schem_path.."new_villages/fletcher.mts", hwidth = 8, hdepth = 8, hheight = 7, hsize = 12, max_num = 0.01 , rplc = basic_pseudobiome_villages, yadjust = 1 },
|
||||
{name = "new_butcher", mts = schem_path.."new_villages/butcher.mts", hwidth = 8, hdepth = 14, hheight = 9, hsize = 17, max_num = 0.01 , rplc = basic_pseudobiome_villages, yadjust = 2 },
|
||||
{name = "fish_farm", mts = schem_path.."new_villages/fishery.mts", hwidth = 10, hdepth = 7, hheight = 9, hsize = 13, max_num = 0.01 , rplc = basic_pseudobiome_villages, yadjust=-2 },
|
||||
{name = "tavern", mts = schem_path.."tavern.mts", hwidth = 12, hdepth = 10, hheight = 13, hsize = 17, max_num = 0.050, rplc = basic_pseudobiome_villages },
|
||||
{name = "well", mts = schem_path.."well.mts", hwidth = 6, hdepth = 8, hheight = 7, hsize = 11, max_num = 0.01, rplc = basic_pseudobiome_villages },
|
||||
{name = "new_well", mts = schem_path.."new_villages/well.mts", hwidth = 6, hdepth = 6, hheight = 8, hsize = 9, max_num = 0.01, rplc = basic_pseudobiome_villages, yadjust=-1 },
|
||||
{name = "new_farm", mts = schem_path.."new_villages/farm.mts", hwidth=10, hdepth=9, hheight=6, hsize=14, max_num = 0.1, rplc = basic_pseudobiome_villages, yadjust = 1 },
|
||||
{name = "farm_small", mts = schem_path.."new_villages/farm_small_1.mts", hwidth=10, hdepth=9, hheight=6, hsize=14, max_num = 0.1, rplc = basic_pseudobiome_villages, yadjust = 1 },
|
||||
{name = "farm_small2", mts = schem_path.."new_villages/farm_small_2.mts", hwidth=9, hdepth=9, hheight=3, hsize=14, max_num = 0.1, rplc = basic_pseudobiome_villages, yadjust = 1 },
|
||||
{name = "farm_large", mts = schem_path.."new_villages/farm_large_1.mts", hwidth=13, hdepth=13, hheight=4, hsize=19, max_num = 0.1, rplc = basic_pseudobiome_villages, yadjust = 1 },
|
||||
}
|
||||
|
||||
--
|
||||
|
@ -127,16 +156,68 @@ mcl_villages.biome_map = {
|
|||
|
||||
CherryGrove = "cherry",
|
||||
|
||||
-- no change
|
||||
--FlowerForest = "oak",
|
||||
--Forest = "oak",
|
||||
--MushroomIsland = "",
|
||||
--Plains = "oak",
|
||||
--StoneBeach = "",
|
||||
--SunflowerPlains = "oak",
|
||||
--Swampland = "oak",
|
||||
-- no change, but try to convert MCLA material
|
||||
FlowerForest = "oak",
|
||||
Forest = "oak",
|
||||
MushroomIsland = "oak",
|
||||
Plains = "oak",
|
||||
StoneBeach = "oak",
|
||||
SunflowerPlains = "oak",
|
||||
Swampland = "oak",
|
||||
}
|
||||
|
||||
mcl_villages.vl_to_mcla = {
|
||||
{ '"mcl_core:tree"', '"mcl_trees:tree_oak"'},
|
||||
{ '"mcl_core:wood"', '"mcl_trees:wood_oak"'},
|
||||
{ '"mcl_fences:fence', '"mcl_fences:oak_fence'},
|
||||
{ '"mcl_stairs:stair_wood"', '"mcl_stairs:stair_oak"'},
|
||||
{ '"mcl_stairs:stair_wood_', '"mcl_stairs:stair_oak_'},
|
||||
{ '"mcl_stairs:slab_wood"', '"mcl_stairs:slab_oak"'},
|
||||
{ '"mcl_stairs:slab_wood_', '"mcl_stairs:slab_oak_'},
|
||||
{ '"mcl_doors:wooden_door_', '"mcl_doors:door_oak_'},
|
||||
{ '"mcl_doors:trapdoor_', '"mcl_doors:trapdoor_oak_'},
|
||||
{ '"xpanes:bar', '"mcl_panes:bar' },
|
||||
{ '"xpanes:pane', '"mcl_panes:pane' },
|
||||
{ '"mcl_itemframes:item_frame"', '"mcl_itemframes:frame"' },
|
||||
{ '"mesecons_pressureplates:pressure_plate_wood_', '"mesecons_pressureplates:pressure_plate_oak_'},
|
||||
-- tree types
|
||||
{ '"mcl_core:([a-z]*)tree"', '"mcl_trees:tree_%1"' },
|
||||
{ '"mcl_core:([a-z]*)wood"', '"mcl_trees:wood_%1"' },
|
||||
{ '"mcl_stairs:stair_([a-z]*)tree"', '"mcl_stairs:stair_%1"' },
|
||||
}
|
||||
mcl_villages.mcla_to_vl = {
|
||||
-- oneway
|
||||
{ '"mcl_villages:no_paths"', '"air"'}, -- TODO: support these
|
||||
{ '"mcl_villages:path_endpoint"', '"air"'}, -- TODO: support these
|
||||
{ '"mcl_villages:crop_root', '"mcl_farming:potato'}, -- TODO: support biome specific farming
|
||||
{ '"mcl_villages:crop_grain', '"mcl_farming:wheat'}, -- TODO: support biome specific farming
|
||||
{ '"mcl_villages:crop_gourd', '"mcl_farming:pumpkin'}, -- TODO: support biome specific farming
|
||||
{ '"mcl_villages:crop_flower', '"mcl_farming:sweet_berry_bush'}, -- TODO: support biome specific farming
|
||||
-- bidirectional
|
||||
{ '"mcl_trees:tree_oak"', '"mcl_core:tree"'},
|
||||
{ '"mcl_trees:wood_oak"', '"mcl_core:wood"'},
|
||||
{ '"mcl_fences:oak_fence', '"mcl_fences:fence'},
|
||||
{ '"mcl_stairs:stair_oak"', '"mcl_stairs:stair_wood"'},
|
||||
{ '"mcl_stairs:stair_oak_bark', '"mcl_stairs:stair_tree_bark'},
|
||||
{ '"mcl_stairs:stair_oak_', '"mcl_stairs:stair_wood_'},
|
||||
{ '"mcl_stairs:slab_oak"', '"mcl_stairs:slab_wood"'},
|
||||
{ '"mcl_stairs:slab_oak_', '"mcl_stairs:slab_wood_'},
|
||||
{ '"mcl_doors:door_oak_', '"mcl_doors:wooden_door_'},
|
||||
{ '"mcl_doors:trapdoor_oak_', '"mcl_doors:trapdoor_'},
|
||||
{ '"mcl_panes:bar', '"xpanes:bar' },
|
||||
{ '"mcl_panes:pane', '"xpanes:pane' },
|
||||
{ '"mcl_itemframes:frame"', '"mcl_itemframes:item_frame"' },
|
||||
{ '"mesecons_pressureplates:pressure_plate_oak_', '"mesecons_pressureplates:pressure_plate_wood_'},
|
||||
-- tree types
|
||||
{ '"mcl_trees:tree_([a-z]*)"', '"mcl_core:%1tree"' },
|
||||
{ '"mcl_trees:wood_([a-z]*)"', '"mcl_core:%1wood"' },
|
||||
{ '"mcl_stairs:stair_birch(["_])', '"mcl_stairs:stair_birchwood%1' },
|
||||
{ '"mcl_stairs:stair_spruce(["_])', '"mcl_stairs:stair_sprucewood%1' },
|
||||
{ '"mcl_stairs:stair_dark(["_])', '"mcl_stairs:stair_darkwood%1' },
|
||||
{ '"mcl_stairs:stair_jungle(["_])', '"mcl_stairs:stair_junglewood%1' },
|
||||
{ '"mcl_stairs:stair_acacia(["_])', '"mcl_stairs:stair_acaciawood%1' },
|
||||
{ '"mcl_stairs:stair_bamboo(["_])', '"mcl_stairs:stair_bamboowood%1' },
|
||||
}
|
||||
mcl_villages.material_substitions = {
|
||||
desert = {
|
||||
{ '"mcl_stairs:slab_oak([^"]*)"', '"mcl_stairs:slab_sandstonesmooth%1"' },
|
||||
|
@ -168,6 +249,7 @@ mcl_villages.material_substitions = {
|
|||
{ '"mcl_stairs:stair_oak([^"]*)"', '"mcl_stairs:stair_sandstonesmooth%1"' },
|
||||
},
|
||||
spruce = {
|
||||
{ '"(mcl_core:wood|mcl_core:tree|mcl_stairs:stair_wood|mcl_fences:fence)"', '"%1_oak"'}, -- VL to MCLA
|
||||
{ '"mcl_stairs:slab_oak([^"]*)"', '"mcl_stairs:slab_sprucewood%1"' },
|
||||
{
|
||||
'"mesecons_pressureplates:pressure_plate_oak_([^"]+)"',
|
||||
|
@ -179,8 +261,10 @@ mcl_villages.material_substitions = {
|
|||
{ "mcl_trees:wood_oak", "mcl_trees:wood_spruce" },
|
||||
{ '"mcl_fences:oak_fence([^"]*)"', '"mcl_fences:spruce_fence%1"' },
|
||||
{ '"mcl_stairs:stair_oak([^"]*)"', '"mcl_stairs:stair_spruce%1"' },
|
||||
{ '"(mcl_core:wood|mcl_core:tree|mcl_stairs:stair_wood|mcl_fences:fence)_oak"', '"%1"'}, -- MCLA to VL
|
||||
},
|
||||
birch = {
|
||||
{ '"(mcl_core:wood|mcl_core:tree|mcl_stairs:stair_wood|mcl_fences:fence)"', '"%1_oak"'}, -- VL to MCLA
|
||||
{ '"mcl_stairs:slab_oak([^"]*)"', '"mcl_stairs:slab_birchwood%1"' },
|
||||
{
|
||||
'"mesecons_pressureplates:pressure_plate_oak_([^"]+)"',
|
||||
|
@ -192,8 +276,10 @@ mcl_villages.material_substitions = {
|
|||
{ "mcl_trees:wood_oak", "mcl_trees:wood_birch" },
|
||||
{ '"mcl_fences:oak_fence([^"]*)"', '"mcl_fences:birch_fence%1"' },
|
||||
{ '"mcl_stairs:stair_oak([^"]*)"', '"mcl_stairs:stair_birch%1"' },
|
||||
{ '"(mcl_core:wood|mcl_core:tree|mcl_stairs:stair_wood|mcl_fences:fence)_oak"', '"%1"'}, -- MCLA to VL
|
||||
},
|
||||
acacia = {
|
||||
{ '"(mcl_core:wood|mcl_core:tree|mcl_stairs:stair_wood|mcl_fences:fence)"', '"%1_oak"'}, -- VL to MCLA
|
||||
{ '"mcl_stairs:slab_oak([^"]*)"', '"mcl_stairs:slab_acaciawood%1"' },
|
||||
{
|
||||
'"mesecons_pressureplates:pressure_plate_oak_([^"]+)"',
|
||||
|
@ -205,8 +291,10 @@ mcl_villages.material_substitions = {
|
|||
{ "mcl_trees:wood_oak", "mcl_trees:wood_acacia" },
|
||||
{ '"mcl_fences:oak_fence([^"]*)"', '"mcl_fences:acacia_fence%1"' },
|
||||
{ '"mcl_stairs:stair_oak([^"]*)"', '"mcl_stairs:stair_acacia%1"' },
|
||||
{ '"(mcl_core:wood|mcl_core:tree|mcl_stairs:stair_wood|mcl_fences:fence)_oak"', '"%1"'}, -- MCLA to VL
|
||||
},
|
||||
dark_oak = {
|
||||
{ '"(mcl_core:wood|mcl_core:tree|mcl_stairs:stair_wood|mcl_fences:fence)"', '"%1_oak"'}, -- VL to MCLA
|
||||
{ '"mcl_stairs:slab_oak([^"]*)"', '"mcl_stairs:slab_darkwood%1"' },
|
||||
{
|
||||
'"mesecons_pressureplates:pressure_plate_oak_([^"]+)"',
|
||||
|
@ -218,8 +306,10 @@ mcl_villages.material_substitions = {
|
|||
{ "mcl_trees:wood_oak", "mcl_trees:wood_dark_oak" },
|
||||
{ '"mcl_fences:oak_fence([^"]*)"', '"mcl_fences:dark_oak_fence%1"' },
|
||||
{ '"mcl_stairs:stair_oak([^"]*)"', '"mcl_stairs:stair_dark_oak%1"' },
|
||||
{ '"(mcl_core:wood|mcl_core:tree|mcl_stairs:stair_wood|mcl_fences:fence)_oak"', '"%1"'}, -- MCLA to VL
|
||||
},
|
||||
jungle = {
|
||||
{ '"(mcl_core:wood|mcl_core:tree|mcl_stairs:stair_wood|mcl_fences:fence)"', '"%1_oak"'}, -- VL to MCLA
|
||||
{ '"mcl_stairs:slab_oak([^"]*)"', '"mcl_stairs:slab_junglewood%1"' },
|
||||
{
|
||||
'"mesecons_pressureplates:pressure_plate_oak_([^"]+)"',
|
||||
|
@ -231,8 +321,10 @@ mcl_villages.material_substitions = {
|
|||
{ "mcl_trees:wood_oak", "mcl_trees:wood_jungle" },
|
||||
{ '"mcl_fences:oak_fence([^"]*)"', '"mcl_fences:jungle_fence%1"' },
|
||||
{ '"mcl_stairs:stair_oak([^"]*)"', '"mcl_stairs:stair_jungle%1"' },
|
||||
{ '"(mcl_core:wood|mcl_core:tree|mcl_stairs:stair_wood|mcl_fences:fence)_oak"', '"%1"'}, -- MCLA to VL
|
||||
},
|
||||
bamboo = {
|
||||
{ '"(mcl_core:wood|mcl_core:tree|mcl_stairs:stair_wood|mcl_fences:fence)"', '"%1_oak"'}, -- VL to MCLA
|
||||
{ '"mcl_stairs:slab_oak([^"]*)"', '"mcl_stairs:slab_bamboo_block%1"' },
|
||||
{
|
||||
'"mesecons_pressureplates:pressure_plate_oak_([^"]+)"',
|
||||
|
@ -249,8 +341,10 @@ mcl_villages.material_substitions = {
|
|||
{ "mcl_trees:wood_oak", "mcl_trees:wood_bamboo" },
|
||||
{ '"mcl_fences:oak_fence([^"]*)"', '"mcl_fences:bamboo_fence%1"' },
|
||||
{ '"mcl_stairs:stair_oak([^"]*)"', '"mcl_stairs:stair_bamboo%1"' },
|
||||
{ '"(mcl_core:wood|mcl_core:tree|mcl_stairs:stair_wood|mcl_fences:fence)_oak"', '"%1"'}, -- MCLA to VL
|
||||
},
|
||||
cherry = {
|
||||
{ '"(mcl_core:wood|mcl_core:tree|mcl_stairs:stair_wood|mcl_fences:fence)"', '"%1_oak"'}, -- VL to MCLA
|
||||
{ '"mcl_stairs:slab_oak([^"]*)"', '"mcl_stairs:slab_cherry_blossom%1"' },
|
||||
{
|
||||
'"mesecons_pressureplates:pressure_plate_oak_([^"]+)"',
|
||||
|
@ -262,5 +356,9 @@ mcl_villages.material_substitions = {
|
|||
{ "mcl_trees:wood_oak", "mcl_trees:wood_cherry_blossom" },
|
||||
{ '"mcl_fences:oak_fence([^"]*)"', '"mcl_fences:cherry_blossom_fence%1"' },
|
||||
{ '"mcl_stairs:stair_oak([^"]*)"', '"mcl_stairs:stair_cherry_blossom%1"' },
|
||||
{ '"(mcl_core:wood|mcl_core:tree|mcl_stairs:stair_wood|mcl_fences:fence)_oak"', '"%1"'}, -- MCLA to VL
|
||||
},
|
||||
oak = {
|
||||
{ '"(mcl_core:wood|mcl_core:tree|mcl_stairs:stair_wood|mcl_fences:fence)_oak"', '"%1"'}, -- MCLA to VL
|
||||
},
|
||||
}
|
||||
|
|
|
@ -12,6 +12,12 @@ local function is_solid(node)
|
|||
local ndef = minetest.registered_nodes[node.name]
|
||||
return ndef and ndef.walkable
|
||||
end
|
||||
local function make_solid(lvm, cp, with, except)
|
||||
local cur = lvm:get_node_at(cp)
|
||||
if not is_solid(cur) or (except and cur.name == except) then
|
||||
lvm:set_node_at(cp, {name=with})
|
||||
end
|
||||
end
|
||||
local function excavate(lvm,xi,yi,zi,pr)
|
||||
local pos, n, c = vector.new(xi,yi,zi), nil, 0
|
||||
local node = lvm:get_node_at(pos)
|
||||
|
@ -28,7 +34,7 @@ local function excavate(lvm,xi,yi,zi,pr)
|
|||
-- try to completely remove trees overhead
|
||||
if not string.find(node.name, "leaf") and not string.find(node.name, "tree") then
|
||||
-- stop randomly depending on fill, to narrow down the caves
|
||||
if pr:next(0,905) > c * 100 then return false end
|
||||
if pr:next(0,31)^2 > c * 100 then return false end
|
||||
end
|
||||
lvm:set_node_at(vector.new(xi, yi, zi),{name="air"})
|
||||
return true -- modified
|
||||
|
@ -51,7 +57,7 @@ local function grow_foundation(lvm,xi,yi,zi,pr,surface_mat,platform_mat)
|
|||
end
|
||||
end
|
||||
-- stop randomly depending on fill, to narrow down the foundation
|
||||
if pr:next(0,905) > c * 100 then return false end
|
||||
if pr:next(0,31)^2 > c * 100 then return false end
|
||||
lvm:set_node_at(vector.new(xi, yi, zi),{name=platform_mat})
|
||||
return true -- modified
|
||||
end
|
||||
|
@ -59,7 +65,6 @@ end
|
|||
-- function clear space above baseplate
|
||||
-------------------------------------------------------------------------------
|
||||
function mcl_villages.terraform(settlement_info, pr)
|
||||
local fheight, fwidth, fdepth, schematic_data
|
||||
--local lvm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
||||
local lvm = VoxelManip()
|
||||
|
||||
|
@ -72,188 +77,117 @@ function mcl_villages.terraform(settlement_info, pr)
|
|||
end
|
||||
end
|
||||
local pos = settlement_info[i]["pos"]
|
||||
if settlement_info[i]["rotat"] == "0" or settlement_info[i]["rotat"] == "180" then
|
||||
fwidth, fdepth = schematic_data["hwidth"], schematic_data["hdepth"]
|
||||
else
|
||||
fwidth, fdepth = schematic_data["hdepth"], schematic_data["hwidth"]
|
||||
end
|
||||
fheight = schematic_data["hheight"] -- remove trees and leaves above
|
||||
|
||||
-- use biome-specific materials
|
||||
local fwidth, fheight, fdepth = schematic_data["hwidth"], schematic_data["hheight"], schematic_data["hdepth"]
|
||||
local surface_mat = settlement_info[i]["surface_mat"]
|
||||
mcl_villages.debug("Surface material: " .. tostring(surface_mat))
|
||||
local platform_mat = foundation_materials[surface_mat] or "mcl_core:dirt"
|
||||
mcl_villages.debug("Foundation material: " .. tostring(platform_mat))
|
||||
|
||||
if settlement_info[i]["rotat"] == "90" or settlement_info[i]["rotat"] == "270" then
|
||||
fwidth, fdepth = fdepth, fwidth
|
||||
end
|
||||
lvm:read_from_map(vector.new(pos.x-2, pos.y-20, pos.z-2), vector.new(pos.x+fwidth+2, pos.y+fheight+20, pos.z+fdepth+2))
|
||||
-- TODO: further optimize by using raw data arrays instead of set_node_at. But OK for a first draft.
|
||||
lvm:get_data()
|
||||
-- excavate the needed volume, some headroom, and add a baseplate
|
||||
local p2 = vector.new(pos)
|
||||
for xi = pos.x,pos.x+fwidth-1 do
|
||||
for zi = pos.z,pos.z+fdepth-1 do
|
||||
lvm:set_node_at(vector.new(xi, pos.y+1, zi),{name="air"})
|
||||
-- pos.y+2 to pos.y+5 are filled larger below!
|
||||
for yi = pos.y+6,pos.y+fheight do
|
||||
lvm:set_node_at(vector.new(xi, yi, zi),{name="air"})
|
||||
end
|
||||
local cp = vector.new(xi, pos.y, zi)
|
||||
local cur = lvm:get_node_at(cp)
|
||||
if not is_solid(cur) or cur.name == platform_mat then
|
||||
lvm:set_node_at(cp, {name=surface_mat})
|
||||
end
|
||||
local cp = vector.new(xi, pos.y - 1, zi)
|
||||
local cur = lvm:get_node_at(cp)
|
||||
if not is_solid(cur) then
|
||||
lvm:set_node_at(cp, {name=platform_mat})
|
||||
end
|
||||
end
|
||||
end
|
||||
-- slightly widen the cave, to make easier to enter for mobs
|
||||
for xi = pos.x-1,pos.x+fwidth do
|
||||
for zi = pos.z-1,pos.z+fdepth do
|
||||
for yi = pos.y+2,pos.y+5 do
|
||||
lvm:set_node_at(vector.new(xi, yi, zi),{name="air"})
|
||||
end
|
||||
end
|
||||
end
|
||||
-- some extra gaps
|
||||
for xi = pos.x-2,pos.x+fwidth+1 do
|
||||
for zi = pos.z-2,pos.z+fdepth+1 do
|
||||
if pr:next(1,4) == 1 then
|
||||
for yi = pos.y+3,pos.y+5 do
|
||||
lvm:set_node_at(vector.new(xi, yi, zi),{name="air"})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- slightly widen the baseplate, to make easier to enter for mobs
|
||||
for xi = pos.x,pos.x+fwidth-1 do
|
||||
local cp = vector.new(xi, pos.y-1, pos.z)
|
||||
local cur = lvm:get_node_at(cp)
|
||||
if not is_solid(cur) then
|
||||
lvm:set_node_at(cp, {name=platform_mat})
|
||||
end
|
||||
local cp = vector.new(xi, pos.y-1, pos.z-1)
|
||||
local cur = lvm:get_node_at(cp)
|
||||
if not is_solid(cur) or cur.name == platform_mat then
|
||||
lvm:set_node_at(cp, {name=surface_mat})
|
||||
end
|
||||
local cp = vector.new(xi, pos.y-1, pos.z+fdepth-1)
|
||||
local cur = lvm:get_node_at(cp)
|
||||
if not is_solid(cur) then
|
||||
lvm:set_node_at(cp, {name=platform_mat})
|
||||
end
|
||||
local cp = vector.new(xi, pos.y-1, pos.z+fdepth)
|
||||
local cur = lvm:get_node_at(cp)
|
||||
if not is_solid(cur) or cur.name == platform_mat then
|
||||
lvm:set_node_at(cp, {name=surface_mat})
|
||||
end
|
||||
end
|
||||
for zi = pos.z,pos.z+fdepth-1 do
|
||||
local cp = vector.new(pos.x, pos.y-1, zi)
|
||||
local cur = lvm:get_node_at(cp)
|
||||
if not is_solid(cur) then
|
||||
lvm:set_node_at(cp, {name=platform_mat})
|
||||
end
|
||||
local cp = vector.new(pos.x-1, pos.y-1, zi)
|
||||
local cur = lvm:get_node_at(cp)
|
||||
if not is_solid(cur) or cur.name == platform_mat then
|
||||
lvm:set_node_at(cp, {name=surface_mat})
|
||||
end
|
||||
local cp = vector.new(pos.x+fwidth-1, pos.y-1, zi)
|
||||
local cur = lvm:get_node_at(cp)
|
||||
if not is_solid(cur) then
|
||||
lvm:set_node_at(cp, {name=platform_mat})
|
||||
end
|
||||
local cp = vector.new(pos.x+fwidth, pos.y-1, zi)
|
||||
local cur = lvm:get_node_at(cp)
|
||||
if not is_solid(cur) or cur.name == platform_mat then
|
||||
lvm:set_node_at(cp, {name=surface_mat})
|
||||
end
|
||||
end
|
||||
-- make some additional steps, along both x sides
|
||||
for xi = pos.x,pos.x+fwidth-1 do
|
||||
local cp = vector.new(xi, pos.y-3, pos.z-1)
|
||||
if is_solid(lvm:get_node_at(cp)) then
|
||||
cp = vector.new(xi, pos.y-2, pos.z-1)
|
||||
local cur = lvm:get_node_at(cp)
|
||||
if not is_solid(cur) or cur.name == platform_mat then
|
||||
lvm:set_node_at(cp, {name=surface_mat})
|
||||
end
|
||||
cp.z = pos.z-2
|
||||
cur = lvm:get_node_at(cp)
|
||||
if not is_solid(cur) or cur.name == platform_mat then
|
||||
lvm:set_node_at(cp, {name=surface_mat})
|
||||
end
|
||||
end
|
||||
local cp = vector.new(xi, pos.y-3, pos.z+fdepth)
|
||||
if is_solid(lvm:get_node_at(cp)) then
|
||||
cp = vector.new(xi, pos.y-2, pos.z+fdepth)
|
||||
local cur = lvm:get_node_at(cp)
|
||||
if not is_solid(cur) or cur.name == platform_mat then
|
||||
lvm:set_node_at(cp, {name=surface_mat})
|
||||
end
|
||||
cp.z = pos.z + fdepth + 1
|
||||
cur = lvm:get_node_at(cp)
|
||||
if not is_solid(cur) or cur.name == platform_mat then
|
||||
lvm:set_node_at(cp, {name=surface_mat})
|
||||
end
|
||||
end
|
||||
end
|
||||
-- make some additional steps, along both z sides
|
||||
for zi = pos.z,pos.z+fdepth-1 do
|
||||
local cp = vector.new(pos.x-1, pos.y-3, zi)
|
||||
if is_solid(lvm:get_node_at(cp)) then
|
||||
cp = vector.new(pos.x-1, pos.y-2, zi)
|
||||
local cur = lvm:get_node_at(cp)
|
||||
if not is_solid(cur) or cur.name == platform_mat then
|
||||
lvm:set_node_at(cp, {name=surface_mat})
|
||||
end
|
||||
cp.x = pos.x-2
|
||||
cur = lvm:get_node_at(cp)
|
||||
if not is_solid(cur) or cur.name == platform_mat then
|
||||
lvm:set_node_at(cp, {name=surface_mat})
|
||||
end
|
||||
end
|
||||
local cp = vector.new(pos.x+fwidth, pos.y-3, zi)
|
||||
if is_solid(lvm:get_node_at(cp)) then
|
||||
cp = vector.new(pos.x+fwidth, pos.y-2, zi)
|
||||
local cur = lvm:get_node_at(cp)
|
||||
if not is_solid(cur) or cur.name == platform_mat then
|
||||
lvm:set_node_at(cp, {name=surface_mat})
|
||||
end
|
||||
cp.x = pos.x+fwidth+1
|
||||
cur = lvm:get_node_at(cp)
|
||||
if not is_solid(cur) or cur.name == platform_mat then
|
||||
lvm:set_node_at(cp, {name=surface_mat})
|
||||
end
|
||||
end
|
||||
end
|
||||
-- cave some additional area overhead, try to make it interesting though
|
||||
for yi = pos.y+3,pos.y+fheight*3 do
|
||||
local active = false
|
||||
for xi = pos.x-2,pos.x+fwidth+1 do
|
||||
for zi = pos.z-2,pos.z+fdepth+1 do
|
||||
if excavate(lvm,xi,yi,zi,pr) then
|
||||
active = true
|
||||
end
|
||||
end
|
||||
end
|
||||
if not active and yi > pos.y+fheight+5 then break end
|
||||
end
|
||||
-- construct additional baseplate below, also try to make it interesting
|
||||
for yi = pos.y-2,pos.y-20,-1 do
|
||||
local active = false
|
||||
for xi = pos.x-1,pos.x+fwidth do
|
||||
for zi = pos.z-1,pos.z+fdepth do
|
||||
if grow_foundation(lvm,xi,yi,zi,pr,surface_mat,platform_mat) then
|
||||
active = true
|
||||
end
|
||||
end
|
||||
end
|
||||
if not active and yi < pos.y-5 then break end
|
||||
end
|
||||
mcl_villages.foundation(lvm, pos, fwidth, fheight, fdepth, surface_mat, pr)
|
||||
lvm:write_to_map(false)
|
||||
end
|
||||
end
|
||||
function mcl_villages.foundation(lvm, pos, fwidth, fheight, fdepth, surface_mat, pr)
|
||||
-- TODO: further optimize by using raw data arrays instead of set_node_at. But OK for a first draft.
|
||||
local platform_mat = foundation_materials[surface_mat] or "mcl_core:dirt"
|
||||
|
||||
-- excavate the needed volume, some headroom, and add a baseplate
|
||||
local p2 = vector.new(pos)
|
||||
for xi = pos.x,pos.x+fwidth-1 do
|
||||
for zi = pos.z,pos.z+fdepth-1 do
|
||||
lvm:set_node_at(vector.new(xi, pos.y+1, zi),{name="air"})
|
||||
-- pos.y+2 to pos.y+5 are filled larger below!
|
||||
for yi = pos.y+6,pos.y+fheight do
|
||||
lvm:set_node_at(vector.new(xi, yi, zi),{name="air"})
|
||||
end
|
||||
make_solid(lvm, vector.new(xi, pos.y, zi), surface_mat, platform_mat)
|
||||
make_solid(lvm, vector.new(xi, pos.y - 1, zi), platform_mat)
|
||||
end
|
||||
end
|
||||
-- slightly widen the cave, to make easier to enter for mobs
|
||||
for xi = pos.x-1,pos.x+fwidth do
|
||||
for zi = pos.z-1,pos.z+fdepth do
|
||||
for yi = pos.y+2,pos.y+5 do
|
||||
lvm:set_node_at(vector.new(xi, yi, zi),{name="air"})
|
||||
end
|
||||
end
|
||||
end
|
||||
-- some extra gaps
|
||||
for xi = pos.x-2,pos.x+fwidth+1 do
|
||||
for zi = pos.z-2,pos.z+fdepth+1 do
|
||||
if pr:next(1,4) == 1 then
|
||||
for yi = pos.y+3,pos.y+5 do
|
||||
lvm:set_node_at(vector.new(xi, yi, zi),{name="air"})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- slightly widen the baseplate, to make easier to enter for mobs
|
||||
for xi = pos.x,pos.x+fwidth-1 do
|
||||
make_solid(lvm, vector.new(xi, pos.y-1, pos.z-1), surface_mat, platform_mat)
|
||||
make_solid(lvm, vector.new(xi, pos.y-1, pos.z), platform_mat)
|
||||
make_solid(lvm, vector.new(xi, pos.y-1, pos.z+fdepth-1), platform_mat)
|
||||
make_solid(lvm, vector.new(xi, pos.y-1, pos.z+fdepth), surface_mat, platform_mat)
|
||||
end
|
||||
for zi = pos.z,pos.z+fdepth-1 do
|
||||
make_solid(lvm, vector.new(pos.x-1, pos.y-1, zi), surface_mat, platform_mat)
|
||||
make_solid(lvm, vector.new(pos.x, pos.y-1, zi), platform_mat)
|
||||
make_solid(lvm, vector.new(pos.x+fwidth-1, pos.y-1, zi), platform_mat)
|
||||
make_solid(lvm, vector.new(pos.x+fwidth, pos.y-1, zi), surface_mat, platform_mat)
|
||||
end
|
||||
-- make some additional steps, along both x sides
|
||||
for xi = pos.x,pos.x+fwidth-1 do
|
||||
local cp = vector.new(xi, pos.y-3, pos.z-1)
|
||||
if is_solid(lvm:get_node_at(cp)) then
|
||||
cp = vector.new(xi, pos.y-2, pos.z-1)
|
||||
make_solid(lvm, cp, surface_mat, platform_mat)
|
||||
cp.z = pos.z-2
|
||||
make_solid(lvm, cp, surface_mat, platform_mat)
|
||||
end
|
||||
local cp = vector.new(xi, pos.y-3, pos.z+fdepth)
|
||||
if is_solid(lvm:get_node_at(cp)) then
|
||||
cp = vector.new(xi, pos.y-2, pos.z+fdepth)
|
||||
make_solid(lvm, cp, surface_mat, platform_mat)
|
||||
cp.z = pos.z + fdepth + 1
|
||||
make_solid(lvm, cp, surface_mat, platform_mat)
|
||||
end
|
||||
end
|
||||
-- make some additional steps, along both z sides
|
||||
for zi = pos.z,pos.z+fdepth-1 do
|
||||
local cp = vector.new(pos.x-1, pos.y-3, zi)
|
||||
if is_solid(lvm:get_node_at(cp)) then
|
||||
cp = vector.new(pos.x-1, pos.y-2, zi)
|
||||
make_solid(lvm, cp, surface_mat, platform_mat)
|
||||
cp.x = pos.x-2
|
||||
make_solid(lvm, cp, surface_mat, platform_mat)
|
||||
end
|
||||
local cp = vector.new(pos.x+fwidth, pos.y-3, zi)
|
||||
if is_solid(lvm:get_node_at(cp)) then
|
||||
cp = vector.new(pos.x+fwidth, pos.y-2, zi)
|
||||
make_solid(lvm, cp, surface_mat, platform_mat)
|
||||
cp.x = pos.x+fwidth+1
|
||||
make_solid(lvm, cp, surface_mat, platform_mat)
|
||||
end
|
||||
end
|
||||
-- cave some additional area overhead, try to make it interesting though
|
||||
for yi = pos.y+3,pos.y+fheight*3 do
|
||||
local active = false
|
||||
for xi = pos.x-2,pos.x+fwidth+1 do
|
||||
for zi = pos.z-2,pos.z+fdepth+1 do
|
||||
if excavate(lvm,xi,yi,zi,pr) then active = true end
|
||||
end
|
||||
end
|
||||
if not active and yi > pos.y+fheight+5 then break end
|
||||
end
|
||||
-- construct additional baseplate below, also try to make it interesting
|
||||
for yi = pos.y-2,pos.y-20,-1 do
|
||||
local active = false
|
||||
for xi = pos.x-1,pos.x+fwidth do
|
||||
for zi = pos.z-1,pos.z+fdepth do
|
||||
if grow_foundation(lvm,xi,yi,zi,pr,surface_mat,platform_mat) then active = true end
|
||||
end
|
||||
end
|
||||
if not active and yi < pos.y-5 then break end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
mcl_villages = {}
|
||||
mcl_villages.modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||
|
||||
local village_chance = tonumber(minetest.settings:get("mcl_villages_village_chance")) or 5
|
||||
local village_chance = tonumber(minetest.settings:get("mcl_villages_village_chance")) or 10
|
||||
|
||||
dofile(mcl_villages.modpath.."/const.lua")
|
||||
dofile(mcl_villages.modpath.."/utils.lua")
|
||||
|
@ -38,7 +38,7 @@ local function build_a_settlement(minp, maxp, blockseed)
|
|||
local settlement_info = mcl_villages.create_site_plan(minp, maxp, pr)
|
||||
if not settlement_info then return end
|
||||
|
||||
mcl_villages.terraform(settlement_info, pr)
|
||||
--mcl_villages.terraform(settlement_info, pr)
|
||||
mcl_villages.place_schematics(settlement_info, pr)
|
||||
mcl_villages.paths(settlement_info)
|
||||
mcl_villages.add_village(blockseed, settlement_info)
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -86,13 +86,14 @@ function mcl_villages.find_surface(pos, wait)
|
|||
end
|
||||
end
|
||||
-------------------------------------------------------------------------------
|
||||
-- check distance for new building
|
||||
-- check distance for new building, use maximum norm
|
||||
-------------------------------------------------------------------------------
|
||||
function mcl_villages.check_distance(settlement_info, building_pos, building_size)
|
||||
for i, built_house in ipairs(settlement_info) do
|
||||
local dx, dz = building_pos.x - built_house["pos"].x, building_pos.z - built_house["pos"].z
|
||||
local dsq = dx*dx+dz*dz
|
||||
if dsq < building_size^2 or dsq < built_house["hsize"]^2 then return false end
|
||||
--local d = math.sqrt(dx*dx+dz*dz)
|
||||
--if 2 * d < building_size + built_house["hsize"] then return false end
|
||||
if math.max(math.abs(dx), math.abs(dz)) * 2 - 6 <= building_size + built_house["hsize"] then return false end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
@ -193,12 +194,21 @@ function mcl_villages.substitute_materials(pos, schem_lua, pr)
|
|||
local biome_data = minetest.get_biome_data(pos)
|
||||
local biome_name = minetest.get_biome_name(biome_data.biome)
|
||||
|
||||
-- for now, map to MCLA, later back, so we can keep their rules unchanged
|
||||
for _, sub in pairs(mcl_villages.vl_to_mcla) do
|
||||
modified_schem_lua = modified_schem_lua:gsub(sub[1], sub[2])
|
||||
end
|
||||
|
||||
if mcl_villages.biome_map[biome_name] and mcl_villages.material_substitions[mcl_villages.biome_map[biome_name]] then
|
||||
for _, sub in pairs(mcl_villages.material_substitions[mcl_villages.biome_map[biome_name]]) do
|
||||
modified_schem_lua = modified_schem_lua:gsub(sub[1], sub[2])
|
||||
end
|
||||
end
|
||||
|
||||
-- MCLA node names back to VL
|
||||
for _, sub in pairs(mcl_villages.mcla_to_vl) do
|
||||
modified_schem_lua = modified_schem_lua:gsub(sub[1], sub[2])
|
||||
end
|
||||
return modified_schem_lua
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue