Godot Version
3
I have this code
extends Node2D
onready var tilemap_ground = $Ground
onready var tilemap_grass = $Grass
onready var tilemap_trees = $Tree
var grid_width = 100
var grid_height = 100
var debug_frequency = 20
var grass_count = 0
var tree_count = 0
func _ready():
if tilemap_ground == null:
push_error("TileMap 'Ground' is not found!")
return
if tilemap_grass == null:
push_error("TileMap 'Grass' is not found!")
return
if tilemap_trees == null:
push_error("TileMap 'Tree' is not found!")
return
print("Map generation started...")
generate_map()
print("Map generation completed!")
print("Total grass tiles placed: ", grass_count)
print("Total tree tiles placed: ", tree_count)
func generate_map():
for x in range(grid_width):
for y in range(grid_height):
place_ground_tile(x, y)
if (x + y) % debug_frequency == 0:
print("Progress: (", x, ", ", y, ")")
place_grass_tile(x, y)
place_tree_tile(x, y)
func place_ground_tile(x, y):
var ground_tile_id = 0
if tilemap_ground != null:
tilemap_ground.set_cell(x, y, ground_tile_id)
if (x + y) % debug_frequency == 0:
print("Placed ground tile at position: (", x, ", ", y, ") with ID: ", ground_tile_id)
else:
push_error("TileMap 'Ground' is null!")
func place_grass_tile(x, y):
var grass_tile_id = 1
if randi() % 100 < 30:
if tilemap_grass != null:
tilemap_grass.set_cell(x, y, grass_tile_id)
grass_count += 1
if (x + y) % debug_frequency == 0:
print("Placed grass tile at position: (", x, ", ", y, ") with ID: ", grass_tile_id)
else:
push_error("TileMap 'Grass' is null!")
func place_tree_tile(x, y):
var tree_tile_id = 2
if randi() % 100 < 10:
if tilemap_trees != null:
tilemap_trees.set_cell(x, y, tree_tile_id)
tree_count += 1
if (x + y) % debug_frequency == 0:
print("Placed tree tile at position: (", x, ", ", y, ") with ID: ", tree_tile_id)
else:
push_error("TileMap 'Tree' is null!")
And i cant understand where to look for Id of tiles