Skip to content

Commit

Permalink
finetuning
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeb187 committed Jun 30, 2018
1 parent 7ff6f60 commit e688f35
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 56 deletions.
17 changes: 9 additions & 8 deletions buildings.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
-- list of schematics
local schematic_table = {
hut = {name = "hut", mts = schem_path.."hut.mts", hsize = 11, max_num = 0.9, rplc = "y"},
garden = {name = "garden", mts = schem_path.."garden.mts", hsize = 11, max_num = 0.2, rplc = "n"},
lamp = {name = "lamp", mts = schem_path.."lamp.mts", hsize = 10, max_num = 0.2, rplc = "n"},
tower = {name = "tower", mts = schem_path.."tower.mts", hsize = 11, max_num = 0.2, rplc = "n"},
well = {name = "well", mts = schem_path.."well.mts", hsize = 11, max_num = 0, rplc = "n"}
hut = {name = "hut", mts = schem_path.."hut.mts", hsize = 10, max_num = 0.9, rplc = "y"},
garden = {name = "garden", mts = schem_path.."garden.mts", hsize = 10, max_num = 0.2, rplc = "n"},
lamp = {name = "lamp", mts = schem_path.."lamp.mts", hsize = 7, max_num = 0.2, rplc = "n"},
tower = {name = "tower", mts = schem_path.."tower.mts", hsize = 10, max_num = 0.2, rplc = "n"},
well = {name = "well", mts = schem_path.."well.mts", hsize = 10, max_num = 0, rplc = "n"}
}
local count_buildings ={}
-- iterate over whole table to get all keys
Expand Down Expand Up @@ -37,7 +37,8 @@ function settlements.build_schematic(pos, building, replace_wall)
local height = schematic["size"]["y"]
settlements.foundation(pos, width, depth, height)
-- place schematic
minetest.place_schematic(pos, schematic, "random", nil, true)
minetest.after(2,minetest.place_schematic,pos, schematic, "random", nil, true)
-- minetest.place_schematic(pos, schematic, "random", nil, true)
end
--
-- placing buildings in circles around center
Expand All @@ -58,7 +59,7 @@ function settlements.place_settlement_circle(minp, maxp)
settlements.initialize_settlement()
-- build well in the center
building_all_info = schematic_table["well"]
settlements.build_schematic(center_surface, building_all_info["mts"])
settlements.build_schematic(center_surface, building_all_info["mts"],building_all_info["rplc"])
-- add to settlement info table
local index = 1
settlement_info[index] = {pos = center_surface, name = building_all_info["name"], hsize = building_all_info["hsize"]}
Expand Down Expand Up @@ -107,7 +108,7 @@ function settlements.initialize_settlement()
end

-- randomize number of buildings
number_of_buildings = 15--math.random(7,20)
number_of_buildings = math.random(7,20)
number_built = 1
minetest.chat_send_all("Dorf".. number_of_buildings)
end
Expand Down
3 changes: 2 additions & 1 deletion const.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ surface_mat = {
"default:dirt_with_snow",
"default:dirt_with_dry_grass",
"default:dirt_with_coniferous_litter",
"default:sand"
"default:sand",
"default:snow"
}
above_surface_mat = {"default:air","default:dirt_with_snow"}
under_surface_mat = {"default:stone","default:dirt"}
Expand Down
39 changes: 0 additions & 39 deletions doors.lua

This file was deleted.

5 changes: 3 additions & 2 deletions foundation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function settlements.ground(pos) -- Wendelsteinkircherl, Brannenburg
p2.y = p2.y-1
while true do
cnt = cnt+1
if cnt > 100 then break end
if cnt > 50 then break end
if cnt>math.random(2,4) then mat = "stone"end
minetest.set_node(p2, {name="default:"..mat})
p2.y = p2.y-1
Expand All @@ -27,7 +27,8 @@ function settlements.foundation(pos, width, depth, height)
local p = {x=p5.x+xi, y=p5.y, z=p5.z+zi}
minetest.after(1,settlements.ground,p)--(p)
else
minetest.remove_node({x=p5.x+xi, y=p5.y+yi, z=p5.z+zi})
-- minetest.remove_node({x=p5.x+xi, y=p5.y+yi, z=p5.z+zi})
minetest.set_node({x=p5.x+xi, y=p5.y+yi, z=p5.z+zi}, {name="air"})
end
end
end
Expand Down
9 changes: 5 additions & 4 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ minetest.register_on_generated(function(minp, maxp)
if dist_ok == false then
return
end
-- place_settlement(minp, maxp)
settlements.place_settlement_circle(minp, maxp)
end
end)
Expand All @@ -38,9 +37,11 @@ minetest.register_craftitem("settlements:tool", {
description = "settlements build tool",
inventory_image = "default_tool_woodshovel.png",
on_use = function(itemstack, placer, pointed_thing)
local p = pointed_thing.under
if p then
settlements.build_schematic(p)
local center_surface = pointed_thing.under
if center_surface then
building_all_info = {name = "hut", mts = schem_path.."hut.mts", hsize = 10, max_num = 0.9, rplc = "y"}
settlements.build_schematic(center_surface, building_all_info["mts"],building_all_info["rplc"])

-- settlements.convert_mts_to_lua()
-- settlements.mts_save()
end
Expand Down
4 changes: 2 additions & 2 deletions utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ end
--
function settlements.check_distance(building_pos, building_size)
for i, built_house in ipairs(settlement_info) do
local distance = vector.distance(building_pos, built_house["pos"])
local distance = math.sqrt(((building_pos.x - built_house["pos"].x)*(building_pos.x - built_house["pos"].x))+((building_pos.z - built_house["pos"].z)*(building_pos.z - built_house["pos"].z)))
if distance < building_size and distance < built_house["hsize"] then
return false
end
Expand Down Expand Up @@ -72,7 +72,7 @@ function settlements.load()
end

function settlements.check_distance_other_settlements(center_new_chunk)
local min_dist_settlements = 1000
local min_dist_settlements = 300
for i, pos in ipairs(settlements_in_world) do
local distance = vector.distance(center_new_chunk, pos)
if distance < min_dist_settlements then
Expand Down

0 comments on commit e688f35

Please sign in to comment.