World.GetTile

Declaration

World.GetTile(Vector2 Position, number Layer)

Description

Returns the Tile object for a tile at Position.

--Gets the tile and prints its TileType and position to the Scripts Console
local position = V2(1, 1);
local layer = 0;
local tile = World.GetTile(position, layer);
Print(tile.Type);
Print("X: " .. tile.Position.x .. " Y: " .. tile.Position.y);

Declaration

World.GetTile(Dictionary<Vector2> Positions, number Layer)

Description

Returns the Tile objects for tiles at Positions.

--Gets the tiles and prints their TileTypes and positions to the Scripts Console
local positions = {V2(1, 1), V2(1, 2), V2(2, 1), V2(2, 2)};
local layer = 0;
local tiles = World.GetTile(positions, layer);

for i, tile in ipairs(tiles) do 
    Print(tile.Type);
    Print("X: " .. tile.Position.x .. " Y: " .. tile.Position.y);
end

Declaration

World.GetTile(Vector2 Position, number Layer, bool Relative, Vector2 Origin)

Description

Returns the Tile object for a tile at Position. Position can be relative to Origin if Relative parameter is true.

--Gets the tile to the right of the ScriptTile then prints its TileType and position to the Scripts Console
local currentTile = GetCurrentTile();
local relativePosition = V2(1, 0);
local layer = 0;
local relative = true;
local tile = World.GetTile(relativePosition, layer, relative, currentTile.Position);
Print(tile.Type);
Print("X: " .. tile.Position.x .. " Y: " .. tile.Position.y);

Declaration

World.GetTile(Dictionary<Vector2> Positions, number Layer, bool Relative, Vector2 Origin)

Description

Returns the Tile objects for tiles at Positions. Positions can be relative to Origin if Relative parameter is true.

--Gets the tiles around the ScriptTile and prints their TileTypes and positions to the Scripts Console
local currentScriptTile = GetCurrentTile();
local positions = {V2(0, 1), V2(1, 1), V2(1, 0), V2(-1, 0), V2(-1, -1), V2(0, -1), V2(1, -1), V2(-1, 1)}
local layer = 0;
local tiles = World.GetTile(positions, layer, true, currentScriptTile.Position);

for i, tile in ipairs(tiles) do 
    Print(tile.Type);
    Print("X: " .. tile.Position.x .. " Y: " .. tile.Position.y);
end