Module Building

Building library for TheoTown

A building is a representation object for single buildings in a city.

You can use it for convenience instead of using the building related functions in the Tile module directly.

Usage:

    local building = Tile.getBuilding(x, y)
    print('Building: '..building:getX()..', '..building:getY())
    

Functions

abandonBuilding () Abandons this (RCI) building.
extinguish () Extinguishes the fire of this building in case it's burning.
getAnimationFrame ([slot=1]) Returns the current frame of an animation that is attached to this building.
getBuildHeight () Retruns the height of the building.
getDaysBuilt () Returns the number of days since this building was constructed.
getFrame () Returns the current frame of the building.
getHeight () Retruns the height of the base area of the building.
getId () Shortcut for the id of the building's draft.
getName () Gets the name of this building.
getPerformance () Returns the current performance of this building.
getStorage () Returns the storage table of the building.
getText () Returns the text set to the building.
getWidth () Retruns the width of the base area of the building.
getXY () Returns the pivot position of this building.
hasNeededRoad () Returns true iff this building needs a road connection and also has a road connection.
hasRoad () Returns true iff this building has a road connection (even if it doesn't require one according to its json).
hasUpgrade (upgradeId) Returns true iff this building has a specific upgrade applied to it.
isAnimationPaused ([slot=1]) Resumes an animation that is attached to this building.
isBurning () Returns true iff this building is burning right now.
isEmpty () Returns true iff this building is empty right now.
isFullOfDeadPeople () Returns true iff this building has transport issues with dead bodies right now.
isFullOfWaste () Returns true iff this building is full of garbage right now.
isIll () Returns true iff this building contains ill people right now.
isInConstruction () Returns true iff this building is in construction right now.
isUntouchable () Determines whether this (RCI) building is untouchable.
isUpgradeInConstruction () Returns true iff this building has a pending upgrade right now.
isWorking () Returns true iff this building is working right now.
pauseAnimation ([slot=1]) Pauses an animation that is attached to this building.
resumeAnimation ([slot=1[, speed=1.0]]) Resumes an animation that is attached to this building.
setAnimationFrame (frame[, slot=1]) Sets the current frame of an animation regardless of whether the animation is playing right now.
setFrame (frame) Sets the current frame of the building.
setName (name) Sets the name of this building.
setPerformance (performance) Sets the performance of this building.
setText (text) Sets a building text or resets it.
setUntouchable ([state=true]) Marks this (RCI) building as untouchable or touchable.


Functions

abandonBuilding ()
Abandons this (RCI) building. It will be empty afterwards.
extinguish ()
Extinguishes the fire of this building in case it's burning.
getAnimationFrame ([slot=1])
Returns the current frame of an animation that is attached to this building.

Parameters:

  • slot number The index of the animation to pause. 1 is the first attached animation. (default 1)

Returns:

    number or nil The current frame of the animation or nil if something went wrong.
getBuildHeight ()
Retruns the height of the building. Multiply by 8 to get an estimation for actual pixel height.

Returns:

    int The building's height.
getDaysBuilt ()
Returns the number of days since this building was constructed. Negative values indicate non finished buildings.

Returns:

    number Days since the building was built/completed.
getFrame ()
Returns the current frame of the building.

Returns:

    number The index of the current frame.
getHeight ()
Retruns the height of the base area of the building.

Returns:

    int height of the base area.
getId ()
Shortcut for the id of the building's draft.

Returns:

    string Draft id of the building's building draft.
getName ()
Gets the name of this building.

Returns:

    string Name of the building or nil if no name is set.
getPerformance ()
Returns the current performance of this building. 1.0 represents 100%.

Returns:

    number Performance of this building.
getStorage ()
Returns the storage table of the building. Storage tables can be used to save information into cities/buildings/roads permanently.

Returns:

    table
getText ()
Returns the text set to the building.

Returns:

    string or nil The text of the building or nil if none was set.
getWidth ()
Retruns the width of the base area of the building.

Returns:

    int width of the base area.
getXY ()
Returns the pivot position of this building. The returned point can differ from the location used to retrieve this building object for buildings that have a size bigger than 1.

Returns:

    number,number X and Y component of the pivot position of this building.
hasNeededRoad ()
Returns true iff this building needs a road connection and also has a road connection.

Returns:

    bool True if the building has road or doesn't need it.
hasRoad ()
Returns true iff this building has a road connection (even if it doesn't require one according to its json).

Returns:

    bool True if the building has road.
hasUpgrade (upgradeId)
Returns true iff this building has a specific upgrade applied to it.

Parameters:

  • upgradeId string Id of an upgrade.

Returns:

    bool
isAnimationPaused ([slot=1])
Resumes an animation that is attached to this building.

Parameters:

  • slot number The index of the animation to pause. 1 is the first attached animation. (default 1)

Returns:

    bool or nil Is true iff the specified animation is paused right now, nil if an error occurred.
isBurning ()
Returns true iff this building is burning right now.

Returns:

    bool True iff this building is burning right now.
isEmpty ()
Returns true iff this building is empty right now. This means that people left it. Only happens for RCI buildings.

Returns:

    bool
isFullOfDeadPeople ()
Returns true iff this building has transport issues with dead bodies right now.

Returns:

    bool True iff the building has dead people in it.
isFullOfWaste ()
Returns true iff this building is full of garbage right now.

Returns:

    bool True iff the building is full of garbage.
isIll ()
Returns true iff this building contains ill people right now.

Returns:

    bool True iff there are ill people.
isInConstruction ()
Returns true iff this building is in construction right now.

Returns:

    bool
isUntouchable ()
Determines whether this (RCI) building is untouchable. An untouchable building is protected in terms of it won't be replaced by automatically spawned buildings.

Returns:

    bool True iff the building is untouchable.
isUpgradeInConstruction ()
Returns true iff this building has a pending upgrade right now.

Returns:

    bool
isWorking ()
Returns true iff this building is working right now. A working building has road connection if needed, is not in construction and is not empty. It also has power and water if needed.

Returns:

    bool True iff the building is working.
pauseAnimation ([slot=1])
Pauses an animation that is attached to this building.

Parameters:

  • slot number The index of the animation to pause. 1 is the first attached animation. (default 1)

Returns:

    number or nil The current frame of the animation or nil if something went wrong.
resumeAnimation ([slot=1[, speed=1.0]])
Resumes an animation that is attached to this building.

Parameters:

  • slot number The index of the animation to pause. 1 is the first attached animation. (default 1)
  • speed number A speed multiplier for the animation. (default 1.0)

Returns:

    number or nil The current frame of the animation or nil if something went wrong.
setAnimationFrame (frame[, slot=1])
Sets the current frame of an animation regardless of whether the animation is playing right now.

Parameters:

  • frame number The frame to set.
  • slot number The index of the animation to pause. 1 is the first attached animation. (default 1)

Returns:

    bool or nil Only true if the operation was successful.
setFrame (frame)
Sets the current frame of the building.

Parameters:

  • frame number The frame index to set. Starts at 0.
setName (name)
Sets the name of this building.

Parameters:

  • name string The name that should be used for the building. Use nil to reset it.
setPerformance (performance)
Sets the performance of this building. The performance value will be clipped by the min and max value defined in the building's json.

Parameters:

  • performance number The performance to set. 1.0 represents 100%.
setText (text)
Sets a building text or resets it.

Parameters:

  • text string The text to apply to the buiding. Use nil to remove it.
setUntouchable ([state=true])
Marks this (RCI) building as untouchable or touchable. An untouchable building is protected in terms of it won't be replaced by automatically spawned buildings.

Parameters:

  • state boolean The untouchable state to set for the building. (default true)
generated by LDoc 1.4.3 Last updated 2021-03-02 09:54:23