Skip to content

Commit

Permalink
added blacksmith
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeb187 committed Jul 5, 2018
1 parent 863d79d commit 8f73f23
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
17 changes: 10 additions & 7 deletions buildings.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
-- list of schematics
local schematic_table = {
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"},
church = {name = "church", mts = schem_path.."church.mts", hsize = 14, max_num = 0.1, rplc = "n"}
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 = 8, max_num = 0.1, rplc = "n"},
tower = {name = "tower", mts = schem_path.."tower.mts", hsize = 11, max_num = 0.15, rplc = "n"},
well = {name = "well", mts = schem_path.."well.mts", hsize = 11, max_num = 0, rplc = "n"},
church = {name = "church", mts = schem_path.."church.mts", hsize = 15, max_num = 0.075, rplc = "n"},
blacksmith = {name = "blacksmith", mts = schem_path.."blacksmith.mts", hsize = 11, max_num = 0.1, rplc = "n"},
}
local count_buildings ={}
-- iterate over whole table to get all keys
Expand Down Expand Up @@ -40,7 +41,7 @@ function settlements.build_schematic(pos, building, replace_wall, name)
local rotation = possible_rotations[ math.random( #possible_rotations ) ]
settlements.foundation(pos, width, depth, height, rotation)
-- place schematic
minetest.after(2, function()
minetest.after(3, function()
minetest.place_schematic(pos, schematic, rotation, nil, true)
-- fill chest
if name == "hut" then
Expand Down Expand Up @@ -135,6 +136,8 @@ function settlements.pick_next_building(pos_surface)
building_all_info = schematic_table["lamp"]
elseif random_number > 55 and count_buildings["church"] < schematic_table["church"]["max_num"]*number_of_buildings then
building_all_info = schematic_table["church"]
elseif random_number > 45 and count_buildings["blacksmith"] < schematic_table["blacksmith"]["max_num"]*number_of_buildings then
building_all_info = schematic_table["blacksmith"]
else
building_all_info = schematic_table["hut"]
end
Expand Down
1 change: 1 addition & 0 deletions depends.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
default
farming?
mobs_npc?
6 changes: 5 additions & 1 deletion init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ dofile(settlements.modpath.."/foundation.lua")
dofile(settlements.modpath.."/buildings.lua")
-- load settlements on server
settlements_in_world = settlements.load()

if minetest.get_modpath("mobs_npc") ~= nil then
--mobs:register_spawn(name, nodes, max_light, min_light, chance, active_object_count, max_height, day_toggle)
mobs:register_spawn("mobs_npc:npc", {"default:junglewood"}, 20, 0, 1, 7, 31000, nil)
mobs:register_spawn("mobs_npc:trader", {"default:junglewood"}, 20, 0, 1, 7, 31000, nil)
end
--
-- on map generation, try to build a settlement
--
Expand Down
Binary file added schematics/blacksmith.mts
Binary file not shown.
Binary file modified schematics/lamp.mts
Binary file not shown.
3 changes: 2 additions & 1 deletion utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ function settlements.fill_chest(pos)
end
-- fill chest
local inv = minetest.get_inventory( {type="node", pos=chestpos} )
-- always
inv:add_item("main", "default:apple "..math.random(1,3))
-- low value items
if math.random(0,1) < 1 then
inv:add_item("main", "default:apple "..math.random(0,3))
inv:add_item("main", "farming:bread "..math.random(0,3))
inv:add_item("main", "default:steel_ingot "..math.random(0,3))
-- additional fillings when farmin mod enabled
Expand Down

0 comments on commit 8f73f23

Please sign in to comment.