okamstudio/godot — pull request #116 by olifly (2014-02-18 10:13:46+00:00)
Title: Added function "get_tiles_ids" to TreeSet.

Added a function to TileSet that returns all the tile ids in an Array. Since tile ids can be any int number then they aren't guaranteed to be from 0 to get_last_unused_tile_id()-1. Getting all the ids back in an array allows for scripts that, for example, randomize the cells in a TileMap.

```
extends TileMap

export(int) var tilesX = 16
export(int) var tilesY = 16

func _ready():
clear()

var tileset = get_tileset()

var tiles_ids = tileset.get_tiles_ids() #new function
var no_tiles = tiles_ids.size()

randomize()

for x in range(tilesX):
for y in range(tilesY):
set_cell(x,y,tiles_ids[randi() % no_tiles],false,false)
```