You also don’t need range() unless you’re walking the array in an unusual order; for i in array.size() works.
Assuming @wchc is right and nothing is calling populate_cities(), the fix should be making sure that function gets called. If you are calling it somewhere and you aren’t getting the results you’re expecting, there’s a couple of things to check:
Are your tile coords what you expect? Maybe do something like:
func populate_cities() -> void:
for city in cities_array:
var map_loc: Vector2i = local_to_map(cities_location_array[city])
print("New city @ (%d %d)" % [map_loc.x, map_loc.y])
# You may want to be able to change tiles per city or something...
var tile: Vector2i = Vector2i(0, 0) # city_tile_array[city]
set_cell(map_loc, 0, tile)
Are you sure (0, 0) is a valid tile in your tileset? If it’s not explicitly marked in the tileset as being in use, you’ll get a blank tile…
The function “populate_cities” is called, just not in the same node. I updated my code accordingly, just for convenience. I tried the code you suggested and the following is shown in the output:
I find this odd, because the coordinates in my array are based on what I found on the tilemaplayer screen (not to mention the coordinates for both tiles are different in my array):
But even at the (4, 10) coordinates, I don’t see the tile I am using as a city marker. Is the tilemaplayer “behind” the background image or something? This is how I have the nodes organized so far:
The TileMapLayer may be in front of or behind your background image, depending on z_index (see “Ordering->Z Index” in the inspector panel). Make sure your TileMapLayer is at a higher value for Z Index than your background image. I think you can also do this with ordering in the node tree as well, but explicit ordering should be more reliable.