LevelDirector

LevelDirector script is performed after landscape generation but before placing of animals, trees and other resources on the map. It is the best moment to create workers and buildings.

By default, LevelDirector generates base buildings and 10 people in the landing place. Landing place is small area that automatically flattens out to simplify building placing. But you can extend this area by modify heights of landscape if it needed through gameMap:setTerrainHeight function.

To change default behaviour of LevelDirector you need to override perform function in your mod:

function fv.core.LevelDirector: perform(transferData) self :initStartPlace -- default behaviour. Change it as you like. end

initStartPlace implemented like this:

function fv.core.LevelDirector: initStartPlace local startPosition = gameMap:getStartPoint self :createDefaultBuildings(startPosition) self :createDefaultCitizens(startPosition) end

Another option is override only the function that you want to modify. For instance, createDefaultBuildings or createDefaultCitizens. Default versions of this function shown below:

function fv.core.LevelDirector: createDefaultCitizens(startPosition) self :createPeasant(startPosition, 10, 1 ,   false , false ) self :createPeasant(startPosition, 10, 2 ,   false , false ) self :createPeasant(startPosition, 10, 3 ,   true ,   false ) self :createPeasant(startPosition, 10, 4 ,   false , false ) self :createPeasant(startPosition, 10, 16 , true ,   true ) self :createPeasant(startPosition, 10, 19 , false , true ) self :createPeasant(startPosition, 10, 22 , false , true ) self :createPeasant(startPosition, 10, 25 , true ,   true ) self :createPeasant(startPosition, 10, 28 , false , true ) self :createPeasant(startPosition, 10, 31 , true ,   true ) end

function fv.core.LevelDirector: createDefaultBuildings(startPosition) local barn = self :createBuilding( 'Barn', startPosition + Vec2( 0 , - 5 ), 2 ) self :addResources(barn, {      fruits = 100,       fish = 700 ,       firewood = 340 ,       skin = 10 ,       bread = 900 ,       oat = 300 ,       dress = 3 ,       improve_dress = 3 ,       improve_tool = 30    }) local warehouse = self :createBuilding( 'Warehouse', startPosition + Vec2( 12 , - 5 ), 2 ) self :addResources(warehouse, {      hay = 100,       clay = 100 ,       ore = 100 ,       logs = 200 ,       stone = 120    }) self :createBuilding( 'Well', startPosition + Vec2( - 7.5 , - 1.5 ), 0 ) local shackOffsets = { Vec2( - 11, 6 ), Vec2( - 1, 6 ), Vec2( 9, 6 ) }  for offset in iter(shackOffsets) do        local shack = self :createBuilding( 'Shack', startPosition + offset, 1 ) self :addResources(shack, {          fruits = 60,           fish = 60 ,           firewood = 20        }) end end