Module Builder

Functions to create and destroy buildings, roads, trees and more.

For convenience you can provide the id of a draft as a string instead of the draft itself whenever a draft is needed. There are different types of drafts. Ensure that you use the correct functions to build them. For example you cannot build $park00 by using Builder.buildRoad. Since it's a build you would have to use Builder.buildBuilding instead.

For each type of object that can be built there's typically a function to check in advance whether the actual building process will be successful. It's good style to use these checks, even though the builder functions check validity on their own.

Usage:

    if Builder.isBuildingBuildable('$tree00', 2, 4) then
      Builder.buildBuilding('$tree00', 2, 4)
    end
    

Functions

buildBuilding (draft, x, y[, frame]) Tries to build the given building draft at the specified position and sets it's frame if a frame was specified.
buildFence (fence, x, y, edge) Builds fence on the specified edge of a tile.
buildFenceAround (fence, x, y, width, height) Builds fence around the specified rectangle area.
buildGround (draft, x, y) Builds the specified ground draft and returns true iff building was successful.
buildPipe (draft, x0, y0[, x1=x0[, y1=y0]]) Tries to build the given pipe draft along the given line.
buildRoad (draft, x0, y0, x1, y1[, level0=0[, level1=0[, bridge=false]]]) Tries to build the given road draft along the given line.
buildRoadDeco (draft, x, y, level[, index=nil]) Tries to build the given road decoration draft on the road on the specified location.
buildTree (draft, x, y[, frame]) Tries to build the given tree draft at the specified position x, y and return true iff this was successful.
buildWire (draft, x0, y0[, x1[, y1]]) Tries to build the given wire draft along the given line.
buildZone (draft, x, y) Builds the specified zone draft or removes it if draft is nil.
getBuildingPrice (draft, x, y) Returns the price of the building.
getGroundPrice (draft, x, y) Returns the price of the ground.
getPipePrice (draft, x0, y0[, x1=x0[, y1=y0]]) Returns the price to build a pipe.
getRoadDecoPrice (draft, x, y, level) Returns the price of the road deco.
getRoadPrice (draft, x0, y0, x1, y1[, level0=0[, level1=0[, bridge=false]]]) Returns the price of the road.
getTreePrice (draft, x, y) Returns the price of the tree.
getWirePrice (draft, x0, y0[, x1=x0[, y1=y0]]) Returns the price to build a wire.
getZonePrice (draft, x, y) Returns the price to build the given zone.
isBuildingBuildable (draft, x, y[, checkZone=true[, checkRoad=true]]) Checks whether the specified building draft can be built at the given position x, y.
isFenceBuildable (fence, x, y, edge) Checks whether the fence can be built on the specified edge of a tile.
isGroundBuildable (draft, x, y) Returns true iff the ground draft can be built at the given location.
isPipeBuildable (draft, x0, y0[, x1=x0[, y1=y0]]) Checks whether the specified pipe draft can be build along the given line x0,y0 - x1,y1.
isRoadBuildable (draft, x0, y0, x1, y1[, level0=0[, level1=0[, bridge=false]]]) Checks whether the specified road draft can be build along the given line x0,y0 - x1,y1.
isRoadDecoBuildable (draft, x, y, level) Returns true iff the given road decoration can be applied to the road at the specified location.
isTreeBuildable (draft, x, y) Checks whether the specified tree draft can be built at the specified position.
isWireBuildable (draft, x0, y0[, x1=x0[, y1=y0]]) Checks whether the specified wire draft can be build along the given line x0,y0 - x1,y1.
remove (x, y) Removes anything from the specified location.
removeFence (x, y, edge) Removes the fence on the specified edge of a tile.
removeFenceWithin (x, y, width, height) Removes any fence within the specified rectangle area.
removePipe (x, y) Dedicated remove function to remove pipes only.
removeRoadDeco (x, y[, level=0[, index=nil]]) Removes all or a specific road decoration from a specified road.
removeWire (x, y, level) Dedicated remove function to remove wires only.


Functions

buildBuilding (draft, x, y[, frame])
Tries to build the given building draft at the specified position and sets it's frame if a frame was specified. Returns true iff the build was was successful.

Parameters:

  • draft draft
  • x number
  • y number
  • frame number The frame to use for the building. If no frame was specified a random frame will be used (in case the building has multiple frames). (optional)

Returns:

    bool Whether the building has been built successfully.
buildFence (fence, x, y, edge)
Builds fence on the specified edge of a tile.

New feature:

    This is a new feature that was added in version 1.9.99

Parameters:

  • fence draft A fence draft.
  • x int X component of the target position.
  • y int Y component of the target position.
  • edge int Fences can be located at all four edges of a tile. The edges are indexed as follows (for non rotated city): 0 is south-east, 1 is north-east, 2 is north-west, 3 is south-west

Returns:

    bool Whether the fence has been built.
buildFenceAround (fence, x, y, width, height)
Builds fence around the specified rectangle area.

New feature:

    This is a new feature that was added in version 1.9.99

Parameters:

  • fence draft A fence draft.
  • x int X component of the target position.
  • y int Y component of the target position.
  • width int Width of the target area in tiles.
  • height int Height of the target area in tiles.

Returns:

    bool Whether at least one fence has been built.
buildGround (draft, x, y)
Builds the specified ground draft and returns true iff building was successful.

Parameters:

  • draft draft A ground draft. You can alternatively provide true for water or false for land. A generic ground draft will be used then.
  • x int X component of the target position.
  • y int Y component of the target position.

Returns:

    bool Whether the ground has been built.
buildPipe (draft, x0, y0[, x1=x0[, y1=y0]])
Tries to build the given pipe draft along the given line. Returns true if building was successful.

Parameters:

  • draft draft Draft of the pipe to build.
  • x0 number X component of the starting position.
  • y0 number Y component of the starting position.
  • x1 number X component of the end position. (default x0)
  • y1 number Y component of the end position. (default y0)

Returns:

    bool Whether the pipe has been built successfully.
buildRoad (draft, x0, y0, x1, y1[, level0=0[, level1=0[, bridge=false]]])
Tries to build the given road draft along the given line. Returns true if building was successful.

Parameters:

  • draft draft Draft of the road to build.
  • x0 number X component of the starting position.
  • y0 number Y component of the starting position.
  • x1 number X component of the end position.
  • y1 number Y component of the end position.
  • level0 number Level at the start position. Default value is 0. (default 0)
  • level1 number Level at the end position. Default value is 0. (default 0)
  • bridge bool Specifies whether a bridge should be built. For this option to work level0 and level1 must be equal. Default is false. (default false)

Returns:

    bool Whether the road has been built successfully.
buildRoadDeco (draft, x, y, level[, index=nil])
Tries to build the given road decoration draft on the road on the specified location. Returns true iff this was successful.

Parameters:

  • draft draft A road decoration draft.
  • x int X component of the target position.
  • y int Y component of the target position.
  • level int Road level of the target position with 0 being ground level.
  • index int If specified the decoration will be place at the given index if possible (starting with 1). (default nil)

Returns:

    bool Whether the road decoration has been built.
buildTree (draft, x, y[, frame])
Tries to build the given tree draft at the specified position x, y and return true iff this was successful. If frame is specified it also tries to set the frame of the tree accordingly.

Parameters:

  • draft draft The tree draft that should be used.
  • x number X component of the target position.
  • y number Y component of the target position.
  • frame number The frame to use for the tree. A random frame will be picked if it isn't specified. (optional)

Returns:

    bool Whether the tree can be built.
buildWire (draft, x0, y0[, x1[, y1]])
Tries to build the given wire draft along the given line. Returns true if building was successful.

Parameters:

  • draft draft Draft of the wire to build.
  • x0 number X component of the starting position.
  • y0 number Y component of the starting position.
  • x1 number X component of the end position. (optional)
  • y1 number Y component of the end position. (optional)

Returns:

    bool Whether the wire has been built successfully.
buildZone (draft, x, y)
Builds the specified zone draft or removes it if draft is nil.

Parameters:

  • draft draft A zone draft or nil.
  • x int X component of the target position.
  • y int Y component of the target position.
getBuildingPrice (draft, x, y)
Returns the price of the building. May change with time.

Parameters:

  • draft draft
  • x number
  • y number

Returns:

    number The price in Theons.
getGroundPrice (draft, x, y)
Returns the price of the ground. May change with time.

Parameters:

  • draft draft A ground draft. You can alternatively provide true for water or false for land. A generic ground draft will be used then.
  • x number X component of the target position.
  • y number Y component of the target position.

Returns:

    number The price in Theons.
getPipePrice (draft, x0, y0[, x1=x0[, y1=y0]])
Returns the price to build a pipe. May change with time.

Parameters:

  • draft draft Draft of the pipe to build.
  • x0 number X component of the starting position.
  • y0 number Y component of the starting position.
  • x1 number X component of the end position. (default x0)
  • y1 number Y component of the end position. (default y0)

Returns:

    number The price in Theons.
getRoadDecoPrice (draft, x, y, level)
Returns the price of the road deco. May change with time.

Parameters:

  • draft draft A road decoration draft.
  • x int X component of the target position.
  • y int Y component of the target position.
  • level int Road level of the target position with 0 being ground level.

Returns:

    number The price in Theons.
getRoadPrice (draft, x0, y0, x1, y1[, level0=0[, level1=0[, bridge=false]]])
Returns the price of the road. May change with time.

Parameters:

  • draft draft
  • x0 number X component of the starting position.
  • y0 number Y component of the starting position.
  • x1 number X component of the end position.
  • y1 number Y component of the end position.
  • level0 number Level at the start position. Default value is 0. (default 0)
  • level1 number Level at the end position. Default value is 0. (default 0)
  • bridge bool Specifies whether a bridge should be built. For this option to work level0 and level1 must be equal. Default is false. (default false)

Returns:

    number The price in Theons.
getTreePrice (draft, x, y)
Returns the price of the tree. May change with time.

Parameters:

  • draft draft The tree draft that should be used.
  • x number X component of the target position.
  • y number Y component of the target position.

Returns:

    number The price in Theons.
getWirePrice (draft, x0, y0[, x1=x0[, y1=y0]])
Returns the price to build a wire. May change with time.

Parameters:

  • draft draft Draft of the wire to build.
  • x0 number X component of the starting position.
  • y0 number Y component of the starting position.
  • x1 number X component of the end position. (default x0)
  • y1 number Y component of the end position. (default y0)

Returns:

    number The price in Theons.
getZonePrice (draft, x, y)
Returns the price to build the given zone. May change with time.

Parameters:

  • draft draft A zone draft.
  • x int X component of the target position.
  • y int Y component of the target position.

Returns:

    int The price in Theons.
isBuildingBuildable (draft, x, y[, checkZone=true[, checkRoad=true]])
Checks whether the specified building draft can be built at the given position x, y. Returns true iff the building can be built.

Parameters:

  • draft draft A building draft.
  • x number
  • y number
  • checkZone boolean If true and the building needs a specific zone then the function will only return true if that zone is already present or can be built without replacing another zone type. (default true)
  • checkRoad boolean If true and the building needs a road connection then the function will only return true if there is road nearby. (default true)

Returns:

    bool Whether the building can be built.
isFenceBuildable (fence, x, y, edge)
Checks whether the fence can be built on the specified edge of a tile.

New feature:

    This is a new feature that was added in version 1.9.99

Parameters:

  • fence draft A fence draft.
  • x int X component of the target position.
  • y int Y component of the target position.
  • edge int Fences can be located at all four edges of a tile. The edges are indexed as follows (for non rotated city): 0 is south-east, 1 is north-east, 2 is north-west, 3 is south-west

Returns:

    bool Whether the fence can be built.
isGroundBuildable (draft, x, y)
Returns true iff the ground draft can be built at the given location.

Parameters:

  • draft draft A ground draft. You can alternatively provide true for water or false for land. A generic ground draft will be used then.
  • x number X component of the target position.
  • y number Y component of the target position.

Returns:

    bool Whether the ground can be built.
isPipeBuildable (draft, x0, y0[, x1=x0[, y1=y0]])
Checks whether the specified pipe draft can be build along the given line x0,y0 - x1,y1. A valid line has to fulfill the property x0 == x1 or y0 == y1.

Parameters:

  • draft draft Draft of the pipe to build.
  • x0 number X component of the starting position.
  • y0 number Y component of the starting position.
  • x1 number X component of the end position. (default x0)
  • y1 number Y component of the end position. (default y0)

Returns:

    bool Whether the pipe can be built.
isRoadBuildable (draft, x0, y0, x1, y1[, level0=0[, level1=0[, bridge=false]]])
Checks whether the specified road draft can be build along the given line x0,y0 - x1,y1. To build a bridge manually you have to set level0 = level1 and bridge = true Only a single lane will be built so a valid line has to fulfill the property x0 == x1 or y0 == y1

Parameters:

  • draft draft Draft of the road to build.
  • x0 number X component of the starting position.
  • y0 number Y component of the starting position.
  • x1 number X component of the end position.
  • y1 number Y component of the end position.
  • level0 number Level at the start position. Default value is 0. (default 0)
  • level1 number Level at the end position. Default value is 0. (default 0)
  • bridge bool Specifies whether a bridge should be built. For this option to work level0 and level1 must be equal. Default is false. (default false)

Returns:

    bool Whether the road can be built.
isRoadDecoBuildable (draft, x, y, level)
Returns true iff the given road decoration can be applied to the road at the specified location.

Parameters:

  • draft draft A road decoration draft.
  • x number X component of the target position.
  • y number Y component of the target position.
  • level number Road level of the target position with 0 being ground level.

Returns:

    bool Whether the road decoration can be built.
isTreeBuildable (draft, x, y)
Checks whether the specified tree draft can be built at the specified position.

Parameters:

  • draft draft The tree draft that should be used.
  • x number X component of the target position.
  • y number Y component of the target position.

Returns:

    bool Whether the tree can be built.
isWireBuildable (draft, x0, y0[, x1=x0[, y1=y0]])
Checks whether the specified wire draft can be build along the given line x0,y0 - x1,y1. A valid line has to fulfill the property x0 == x1 or y0 == y1.

Parameters:

  • draft draft Draft of the wire to build.
  • x0 number X component of the starting position.
  • y0 number Y component of the starting position.
  • x1 number X component of the end position. (default x0)
  • y1 number Y component of the end position. (default y0)

Returns:

    bool Whether the wire can be built.
remove (x, y)
Removes anything from the specified location.

Parameters:

  • x int X component of the target position.
  • y int Y component of the target position.

Returns:

    bool Whether something was removed.
removeFence (x, y, edge)
Removes the fence on the specified edge of a tile.

New feature:

    This is a new feature that was added in version 1.9.99

Parameters:

  • x int X component of the target position.
  • y int Y component of the target position.
  • edge int Fences can be located at all four edges of a tile. The edges are indexed as follows (for non rotated city): 0 is south-east, 1 is north-east, 2 is north-west, 3 is south-west

Returns:

    bool Whether a fence was removed.
removeFenceWithin (x, y, width, height)
Removes any fence within the specified rectangle area.

New feature:

    This is a new feature that was added in version 1.9.99

Parameters:

  • x int X component of the target position.
  • y int Y component of the target position.
  • width int Width of the target area in tiles.
  • height int Height of the target area in tiles.

Returns:

    bool Whether at least one fence has been removed.
removePipe (x, y)
Dedicated remove function to remove pipes only.

Parameters:

  • x number X component of a tile.
  • y number Y component of a tile.

Returns:

    bool Whether something was removed.
removeRoadDeco (x, y[, level=0[, index=nil]])
Removes all or a specific road decoration from a specified road.

New feature:

    This is a new feature that was added in version 1.9.96

Parameters:

  • x number X component of the target position.
  • y number Y component of the target position.
  • level number Road level of the target position with 0 being ground level. (default 0)
  • index int Index of the road decoration to remove starting with 1, or nil to remove all road decorations on the road (default nil)

Returns:

    bool True iff at least one road decoration was removed.
removeWire (x, y, level)
Dedicated remove function to remove wires only.

Parameters:

  • x number X component of a tile.
  • y number Y component of a tile.
  • level number Level of the wire to remove. The level of normal wires is 0 (-1 for underground and 1 for long distance wires).

Returns:

    bool Whether something was removed.
generated by LDoc 1.4.3 Last updated 2021-10-09 18:54:44