Module Draft

Draft library for TheoTown A draft can be considered a single "plugin object" like a building.

This library contains functions and methods to access drafts and query basic information about them. Multiple scripts can be attached to a single draft.

Usage:

    local d = Draft.getDraft('$park00')
    print(tostring(d))
    

Functions

getDraft (id) Returns the draft of the given id.
getDrafts ([tag]) Returns an array of drafts that have the given tag defined.
callAll (name[, arg1[, arg2[, ...]]]) Calls the event function called *name* on all scripts if defined.

Class Draft

Draft:getId () Returns the id of the draft.
Draft:getTitle () Returns the localized title of the draft.
Draft:getText () Returns the localized description of the draft.
Draft:getAuthor () Returns the author of the draft as defined in it's definition.
Draft:getType () Returns a string that represents the concrete type of the draft.
Draft:isBuilding () Returns **true** iff the draft defines a building.
Draft:isRCI () Returns **true** iff the draft defines a building that is either residential, commercial or industrial.
Draft:isResidential () Returns **true** iff the draft defines a residential building.
Draft:isCommercial () Returns **true** iff the draft defines a commercial building.
Draft:isIndustrial () Returns **true** iff the draft defines a industrial building.
Draft:isRoad () Returns **true** iff the draft defines a road.
Draft:isRoadDecoration () Returns **true** iff the draft defines a road decoration.
Draft:isAnimation () Returns **true** iff the draft defines a building.
Draft:isGround () Returns **true** iff the draft defines a ground type.
Draft:isCar () Returns **true** iff the draft defines a car.
Draft:isTree () Returns **true** iff the draft defines a tree.
Draft:isTemplate () Returns **true** iff the draft defines a draft template.
Draft:isCategory () Returns **true** iff the draft defines a category.
Draft:getFrameCount () Returns the number of frames defined in that draft.
Draft:getFrame (frameIndex) Returns a frame specified by it's index (starting with 1).
Draft:setFrame (frameIndex, frame) Overrides a frame by index.
Draft:getPrice () Returns the price defined for this draft.
Draft:getMonthlyPrice () Returns the monthly price defined for this draft.
Draft:getWidth () Returns the width of the building.
Draft:getHeight () Returns the height of the building.
Draft:setVisible (state) Sets the visibility state of the draft.
Draft:isVisible () Returns **true** iff the draft is visible.
Draft:getMeta () Returns the meta table of the draft if available.
Draft:getContent () For template and data drafts only: returns the raw json definition of the draft.
Draft:getScripts () Returns an array of all attached scripts to this draft.
Draft:call (name[, arg1[, arg2[, ...]]]) Calls the event function called *name* on all scripts of the draft if defined.


Functions

getDraft (id)
Returns the draft of the given id. **nil** is returned if no draft of the given id was found.

Parameters:

Returns:

    draft
getDrafts ([tag])
Returns an array of drafts that have the given tag defined. If no tag is provided this function returns a list of all available drafts.

Parameters:

Returns:

    array
callAll (name[, arg1[, arg2[, ...]]])
Calls the event function called *name* on all scripts if defined.

Parameters:

  • name string
  • arg1 (optional)
  • arg2 (optional)
  • ... (optional)

Class Draft

This type represents drafts.
Draft:getId ()
Returns the id of the draft.

Returns:

    string The id.
Draft:getTitle ()
Returns the localized title of the draft.

Returns:

    string The title.
Draft:getText ()
Returns the localized description of the draft.

Returns:

    string The description.
Draft:getAuthor ()
Returns the author of the draft as defined in it's definition.

Returns:

    string The author.
Draft:getType ()
Returns a string that represents the concrete type of the draft.

Returns:

    string
Draft:isBuilding ()
Returns **true** iff the draft defines a building.

Returns:

    bool
Draft:isRCI ()
Returns **true** iff the draft defines a building that is either residential, commercial or industrial.

Returns:

    bool
Draft:isResidential ()
Returns **true** iff the draft defines a residential building.

Returns:

    bool
Draft:isCommercial ()
Returns **true** iff the draft defines a commercial building.

Returns:

    bool
Draft:isIndustrial ()
Returns **true** iff the draft defines a industrial building.

Returns:

    bool
Draft:isRoad ()
Returns **true** iff the draft defines a road.

Returns:

    bool
Draft:isRoadDecoration ()
Returns **true** iff the draft defines a road decoration.

Returns:

    bool
Draft:isAnimation ()
Returns **true** iff the draft defines a building.

Returns:

    bool
Draft:isGround ()
Returns **true** iff the draft defines a ground type.

Returns:

    bool
Draft:isCar ()
Returns **true** iff the draft defines a car.

Returns:

    bool
Draft:isTree ()
Returns **true** iff the draft defines a tree.

Returns:

    bool
Draft:isTemplate ()
Returns **true** iff the draft defines a draft template.

Returns:

    bool
Draft:isCategory ()
Returns **true** iff the draft defines a category.

Returns:

    bool
Draft:getFrameCount ()
Returns the number of frames defined in that draft. Only available for draft types that use frames (e.g. buildings, roads and cars).

Returns:

    number
Draft:getFrame (frameIndex)
Returns a frame specified by it's index (starting with 1).

Parameters:

  • frameIndex number

Returns:

    number A frame, represented by a single number.
Draft:setFrame (frameIndex, frame)
Overrides a frame by index. Starting index is 1.

Parameters:

  • frameIndex number The frame position to overwrite.
  • frame number New frame.
Draft:getPrice ()
Returns the price defined for this draft. Not all draft types support to have a price.

Returns:

    number
Draft:getMonthlyPrice ()
Returns the monthly price defined for this draft. Not all draft types support to have a monthly price.

Returns:

    number
Draft:getWidth ()
Returns the width of the building. Only available for building drafts.

Returns:

    number
Draft:getHeight ()
Returns the height of the building. Only available for building drafts.

Returns:

    number
Draft:setVisible (state)
Sets the visibility state of the draft. For buildings the visibility state defined whether they are present in the toolbar.

Parameters:

  • state bool The new visibility state.
Draft:isVisible ()
Returns **true** iff the draft is visible.

Returns:

    bool
Draft:getMeta ()
Returns the meta table of the draft if available. nil otherwise.

Returns:

    table
Draft:getContent ()
For template and data drafts only: returns the raw json definition of the draft.

Returns:

    table
Draft:getScripts ()
Returns an array of all attached scripts to this draft. Don't modify the returned array.

Returns:

    array
Draft:call (name[, arg1[, arg2[, ...]]])
Calls the event function called *name* on all scripts of the draft if defined.

Parameters:

  • name string
  • arg1 (optional)
  • arg2 (optional)
  • ... (optional)
generated by LDoc 1.4.3 Last updated 2019-07-03 15:00:59