diff --git a/README.md b/README.md index 0069ff4..d69f8be 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,6 @@ creates two workers, a stockpile, and some harvestable entities. For more information about Stonehearth, please visit http://stonehearth.net -  Installing ---------- @@ -74,6 +73,9 @@ run the harvest\_test game world every time you run Stonehearth: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -  +Running Building Editor Mod +=========================== +Stonehearth.exe --game.main_mod=microworld --mods.microworld.world=building_editor +   diff --git a/data/data_driven_world/building_editor_world.json b/data/data_driven_world/building_editor_world.json new file mode 100644 index 0000000..e1e92ce --- /dev/null +++ b/data/data_driven_world/building_editor_world.json @@ -0,0 +1,136 @@ +{ + "world" : { + "size" : 128, + "town_position" : { "x": 100, "z": 10 } + }, + + "entities" : [ + { + "alias" : "stonehearth:decoration:firepit", + + "position" : { + "x" : 0, + "z" : 11 + }, + + "requires_owner": true, + "full_size" : true + }, + + { + "alias" : "stonehearth:plants:berry_bush", + + "position" : { + "x" : 4, + "z" : 2 + }, + + "repeat" : { + "x" : 4, + "z" : 2 + }, + + "offset" : { + "x" : 4, + "z" : 4 + } + }, + + { + "alias" : "stonehearth:trees:oak:large", + + "position" : { + "x": -12, + "z" : -12 + } + }, + + { + "alias" : "stonehearth:trees:oak:medium", + + "position" : { + "x" : 14, + "z" : -1 + } + }, + + { + "alias" : "stonehearth:trees:oak:medium", + + "position" : { + "x" : 11, + "z" : 16 + } + }, + + { + "alias" : "stonehearth:trees:oak:small", + + "position" : { + "x" : -10, + "z" : 15 + } + }, + + { + "alias" : "stonehearth:red_fox", + + "position" : { + "x" : 2, + "z" : 2 + } + } + ], + + "citizens": [ + { + "position" : { + "x" : -2, + "z" : -2 + } + }, + + { + "position" : { + "x" : -2, + "z" : 1 + }, + + "carrying" : "stonehearth:resources:fiber:silkweed_bundle" + }, + + { + "position" : { + "x" : 1, + "z" : -2 + }, + + "carrying" : "stonehearth:trapper:talisman" + }, + + { + "position" : { + "x" : 1, + "z" : 1 + }, + + "carrying" : "stonehearth:carpenter:talisman" + }, + + { + "position" : { + "x" : 4, + "z" : -2 + } + }, + + { + "position" : { + "x" : 4, + "z" : 1 + }, + + "carrying" : "stonehearth:resources:wood:oak_log" + } + ] +} \ No newline at end of file diff --git a/manifest.json b/manifest.json index aaa3385..c65d777 100644 --- a/manifest.json +++ b/manifest.json @@ -8,6 +8,7 @@ "aliases" : { "data_driven:world:mini_game" : "file(data/data_driven_world/mini_game_world.json)", + "data_driven:world:building_editor" : "file(data/data_driven_world/building_editor_world.json)", "data_driven:world:harvest_test" : "file(data/data_driven_world/harvest_test_world.json)", "data_driven:world:profession_test" : "file(data/data_driven_world/profession_test_world.json)", "data_driven:world:equipment_test" : "file(data/data_driven_world/equipment_test_world.json)", diff --git a/micro_world.lua b/micro_world.lua index ab4ee33..02b9437 100644 --- a/micro_world.lua +++ b/micro_world.lua @@ -467,14 +467,12 @@ function MicroWorld:place_all_entities_passing_filter(player_id, x, z, filter_fn for uri in pairs(all_entities) do if filter_fn(uri) then - for i = 1, 4 do - -- place the entity into the world - self:place_item(uri, x, z, player_id) - x = (x + 1) % 8 - if x == 0 then - z = z + 1 - end - end + -- place the entity into the world + self:place_item(uri, x, z, player_id) + x = (x + 1) % 12 + if x == 0 then + z = z + 1 + end end end end @@ -491,6 +489,22 @@ local alias_is_equipment = function(uri) return false end +local alias_is_furniture = function(uri) + local json = radiant.resources.load_json(uri) + + if json['components'] ~= nil and + json['components']['stonehearth:entity_forms'] ~= nil then + return true + end + + return false +end + +--Place all furnitures in all the relevant mods in the test world +function MicroWorld:place_all_furnitures(player_id, x, z) + self:place_all_entities_passing_filter(player_id, x, z, alias_is_furniture) +end + --Place all the equipment in all the relevant mods in the test world function MicroWorld:place_all_combat_equipment(player_id, x, z) self:place_all_entities_passing_filter(player_id, x, z, alias_is_equipment) diff --git a/worlds/building_editor_world.lua b/worlds/building_editor_world.lua new file mode 100644 index 0000000..44f6233 --- /dev/null +++ b/worlds/building_editor_world.lua @@ -0,0 +1,49 @@ +local MicroWorld = require 'micro_world' +local Point3 = _radiant.csg.Point3 + +local BuildingEditor = class(MicroWorld) + +function BuildingEditor:__init() + -- create a tiny world + self[MicroWorld]:__init(128) + self:create_world() + + local player_id = self:get_session().player_id + local pop = stonehearth.population:get_population(player_id) + + -- create a settlement with a banner and firepit + -- and 6 workers around the point(0,0) + local workers = self:create_settlement({ + carpenter = { + num = 1, + level = 6 + }, + potter = { + num = 1, + level = 6 + }, + mason = { + num = 1, + level = 6 + }, + blacksmith = { + num = 1, + level = 6 + }, + weaver = { + num = 1, + level = 6 + }, + engineer = { + num = 1, + level = 6 + } + }, 0, 0) + + + self:place_all_furnitures(player_id, -30, 10) + +end + +return BuildingEditor +