Loading TileMap from code (tileset not appearing)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By saoded

I used to have a TileMap as a child of my root Node. I created basic floor & walls in the graphical editor and it worked fine.
Since I want a game with multiple levels I want to load/free its scene from code.

My parent has:

var curr_level
func _ready():
    curr_level = load("res://src/levels/Lv0.gd").new()
    add_child(curr_level)

But my tiles aren’t loaded. I know for a fact that the TileMap node itself is loaded, since its _ready function initializes a few NPC’s and they appear. When I print(tile_set)I get a null object, so I wonder if I’m missing a step here