Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ creates two workers, a stockpile, and some harvestable entities.

For more information about Stonehearth, please visit http://stonehearth.net



Installing
----------
Expand Down Expand Up @@ -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



136 changes: 136 additions & 0 deletions data/data_driven_world/building_editor_world.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
1 change: 1 addition & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
30 changes: 22 additions & 8 deletions micro_world.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
49 changes: 49 additions & 0 deletions worlds/building_editor_world.lua
Original file line number Diff line number Diff line change
@@ -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