This script contains function that ease setting up an initial infrastructure for maps. This includes placing buildings and roads.

connected_road(plr, sflag, descr[, create_carriers = true])

This is a convenience function to create roads. It is basically a frontend to The road is forced, that is other stuff in the way is removed. A sample usage:

local game = wl.Game()
connected_road(game.players[1],,20).immovable, "r,r|br,r|r,r")

This would create a road starting from the Flag standing at field(20,20) which must exist and goes from there 2 steps right (east), places a new flag. Then it goes one step bottom-right and one step right, places the next flag and then goes two steps right again and places the last flag.

  • plr ( – The player for which the road is created

  • sflag ( – The starting flag for this road.

  • descr – The description of this road. This are comma separated directions as those accepted by A | defines a flag.

  • create_carriers (boolean) – If this is true carriers are created for the roads. Otherwise no carriers will be created.

prefilled_buildings(plr, b1_descr[, b2_descr, ...])

Create pre-filled buildings. Each description is a arrays which contain building type, build field and pre-fill information. A sample usage:

   {"sentry", 57, 9}, -- Sentry completely full with soldiers
   {"sentry", 57, 9, soldier={[{0,0,0,0}]=1}}, -- Sentry with one soldier
   {"bakery", 55, 20, inputs = {wheat=6, water=6}}, -- bakery with wares and workers
   {"well", 52, 30}, -- a well with workers
  • plr ( – The player for which the road is created

  • b1_descr (array) –

    An array of tables. Each table must contain at least the name of the building, and the x and y positions of the field where the building should be created. Optional entries are:


    A table of (name,count) as expected by This is valid for and must not be used otherwise.


    A table of (name,count) as expected by Inputs are wares or workers which are consumed by the building. This is valid for and must not be used otherwise.


    A table of (soldier_descr,count) as expected by If this is nil, the site will be filled with {0,0,0,0} soldiers.


    A table of (workers_name,count) as expected by Note that ProductionSites are filled with workers by default.


A table of created buildings

place_building_in_region(plr, building, region[, opts])

Tries to place a building randomly in the given region. It places houses using prefilled_buildings(), therefore uses the same options. If it fails, an error is thrown. This is a most useful function when defining starting conditions (initializations) in normal games.

  • plr ( – The player for which the building is created

  • building (string) – The name of the building to create.

  • region (array) – The fields which are tested for suitability.

  • opts (table) – A table with prefill information (wares, soldiers, workers, see prefilled_buildings())


The building created


Checks whether an immovable is a finished building, i.e. not a construction site.


immovable – The immovable to test


true if the immovable is a building