- Edited
I am using Godot v3.3.2 stable. I am using the 2d builder simulation found here.
https://github.com/GDQuest/godot-2d-builder
I've managed to add a few things and make a few changes but I have yet to get it from Iso to standard square tiles. I think I know how so not an issue, yet. I then started messing with the tutorial on saving and loading procedurally generated tilemaps by Nerd Everyday on YouTube.
I followed this tutorial to the very end as I want to have procedurally generated tilemaps in my builder game I'm working on from the GDQuest builder game example. At the moment the tutorial from Nerd Everyday isn't working. When I run scene it throws the following in the debugger 0 - res://TileMap.gd:49 - at function:
And when the in-editor play screen finally pops up it's blank. The scene is just a TileMap node with the TileMap.gd script, the tileset.res, and a child TileMap node labeled Loaded. The tileset.res is just the Godot icon in four different colors. The following is the TileMap.gd script.
extends TileMap
var noise := OpenSimplexNoise.new()
func _ready():
randomize()
noise.seed = randi()
#randomizes the seed
if load_world() == false:
for x in range(3):
for y in range(3):
generate_chunk(x,y)
load_world()
#generates initial chunks
func generate_chunk (x_chunk,y_chunk):
if $Loaded.get_cell(x_chunk,y_chunk) != -1:
return
$Loaded.set_cell(x_chunk,y_chunk,0)
#checks if chunk is already generated
for x in range(32):
for y in range(32):
set_cell(x+x_chunk*32,y+y_chunk*32,noise.get_noise_2d(x+x_chunk*32,y+y_chunk*32)*4+4)
func _notification(what):
if what == NOTIFICATION_EXIT_TREE:
save_world()
func save_world():
var save_file := File.new()
save_file.open("user://save_file.dat",File.WRITE)
for chunk in $Loaded.get_used_cells():
save_file.store_double(chunk.x)
save_file.store_double(chunk.y)
for x in range(32):
for y in range (32):
save_file.store_8(get_cell(x+chunk.x*32,y+chunk.y*32))
save_file.close()
func load_world()->bool:
var save_file := File.new()
if not save_file.file_exists("user://save_file.dat"):
return false
save_file.open("user://save_file.dat",File.READ)
while save_file.get_position() != save_file.get_len():
var chunk := vector2()
chunk.x = save_file.get_double()
chunk.y = save_file.get_double()
$Loaded.set_cellv(chunk,0)
for x in range(32):
for y in range(32):
set_cell(x+chunk.x*32,y+chunk.y*32,save_file.get_8())
save_file.close()
return true
I need to get this running before I try and make it work in the builder. Thank you for your time...