add null check for loading empty saves

pull/2/head
vstrucovski 2023-09-26 20:20:24 +07:00
parent cf39dd98cd
commit e290301784
1 changed files with 3 additions and 1 deletions

@ -127,6 +127,7 @@ func update_cash():
func action_save():
if Input.is_action_just_pressed("save"):
print("Saving map...")
map.structures.clear()
for cell in gridmap.get_used_cells():
@ -147,7 +148,8 @@ func action_load():
gridmap.clear()
map = ResourceLoader.load("user://map.res")
if not map:
map = DataMap.new()
for cell in map.structures:
gridmap.set_cell_item(Vector3i(cell.position.x, 0, cell.position.y), cell.structure, cell.orientation)