Tile (class)

From PGE Wiki
Jump to: navigation, search

This class provides fields/functions for managing Tiles on the overworld.

Static functions

Static Tile Functions
Function Return values Description
Tile.count() number How many tiles are on the overworld.
Tile.get() table of Tile Returns all tiles on the overworld.
Tile.get(number or table ids) table of Tile Returns all tiles with the matching item ids.
Tile.getIntersecting(number x1, number y1, number x2, number y2) table of Tile Returns all tiles which are intersecting with an area from x1/y1 to x2/y2.

Instance functions

These fields and functions are part of Tile Objects and have to be called for that object. Trying to call them from the static Tile class will result in an error. Example (feel free to copy it into your lua file to see how it works):

function onTick()
    for index,myTile in ipairs(Tile.get()) do
        myTile.id = 1
    end
end
Tile class
Type Function/Field Return values/Value type Description
Field Tile.id double The id of the tile object.
Field Tile.x double The x position of the tile object.
Field Tile.y double The y position of the tile object.
Field Tile.width double The width of the tile object.
Field Tile.height double The height of the tile object.
Field Tile.isValid boolean Whether the object is valid or not.