lua/wrappers/game/lua_map.cpp
/**
	 * Sets the tiles for this map from a table of tile names and frames.
	 * This function changes the size of the map to fit the parameters given.
	 * <pre>
	 * am.engine.using_tile_set("nature")
	 * map = am.map.new("testMap")
	 * map:tiles({
	 *     "dirt", "dirt:1", "castle/dirt:1",
	 *     "grass:2", "water", "castle/water"
	 * }, 3, 2)
	 * </pre>
	 * <span>Each tile name is in the following form.</span>
	 * <pre>
	 * [tileSetName/]tile_name[:frameNumber]
	 * </pre>
	 * <span>The tileSetName is optional and allows you to specify the tile set
	 * which the tile is from. If none is provided then the top level tile set
	 * or any tile sets specified with the <code>Engine.using_tile_set</code> function.
	 * The frameNumber is also optional and allows for specifying which
	 * frame of the tile sprite.</span>
	 *
	 * @param table tiles An table of tiles to set onto the map.
	 * @param integer width The width of the table given.
	 * @param integer height The height of the table given.
	 * @returns am.map This
	 */
Sets the tiles for this map from a table of tile names and frames.
This function changes the size of the map to fit the parameters given.

@param table tiles An table of tiles to set onto the map.
@param integer width The width of the table given.
@param integer height The height of the table given.
Sets the tiles for this map from a table of tile names and frames . This function changes the size of the map to fit the parameters given . @param table tiles An table of tiles to set onto the map . @param integer width The width of the table given . @param integer height The height of the table given .
int Map_tiles(lua_State *lua)
	{
		Map *map = castUData<Map>(lua, 1);
		if (map)
		{
			int args = lua_gettop(lua);
			if (!lua_istable(lua, 2) || (args == 3 && !lua_isnum(lua, 3) && !lua_isnum(lua, 4)))
			{
				return LuaState::expectedArgs(lua, "tiles", 2, "table tiles", "table tiles, integer width, integer height");
			}
			if (args == 3)
			{
				map->setMapSize(lua_tointeger(lua, 3), lua_tointeger(lua, 4));
			}
			int total = map->getMapWidth() * map->getMapHeight();
			lua_pushnil(lua);
			int i = 0;
			TileInstance *insts = map->getTiles();
			while (lua_next(lua, -2) != 0)
			{
				if (lua_isstring(lua, -1))
				{
					insts[i].setTileName(lua_tostring(lua, -1));
				}
				else
				{
					Tile *tile = castUData<Tile>(lua, -1);
					insts[i].setTile(tile);
				}
				lua_pop(lua, 1);
				i++;
				if (i >= total)
				{
					break;
				}
			}
			map->getTileRenderer()->updateAssetSprites();
			lua_first(lua);
		}
		return LuaState::expectedContext(lua, "tiles", "am.map");
	}
int Map_tiles ( lua_State * lua ) { Map * map = castUData < Map > ( lua , 1 ) ; if ( map ) { int args = lua_gettop ( lua ) ; if ( ! lua_istable ( lua , 2 ) || ( args == 3 && ! lua_isnum ( lua , 3 ) && ! lua_isnum ( lua , 4 ) ) ) { return LuaState :: expectedArgs ( lua , " " , 2 , " " , " " ) ; } if ( args == 3 ) { map -> setMapSize ( lua_tointeger ( lua , 3 ) , lua_tointeger ( lua , 4 ) ) ; } int total = map -> getMapWidth ( ) * map -> getMapHeight ( ) ; lua_pushnil ( lua ) ; int i = 0 ; TileInstance * insts = map -> getTiles ( ) ; while ( lua_next ( lua , -2 ) != 0 ) { if ( lua_isstring ( lua , -1 ) ) { insts [ i ] . setTileName ( lua_tostring ( lua , -1 ) ) ; } else { Tile * tile = castUData < Tile > ( lua , -1 ) ; insts [ i ] . setTile ( tile ) ; } lua_pop ( lua , 1 ) ; i ++ ; if ( i >= total ) { break ; } } map -> getTileRenderer ( ) -> updateAssetSprites ( ) ; lua_first ( lua ) ; } return LuaState :: expectedContext ( lua , " " , " " ) ; }
Sets the tiles for this map from a table of tile names and frames.
Sets the tiles for this map from a table of tile names and frames .