Godot Version
4.3 Stable x64 for Win
Question
I am bashing my head into a wall with Dictionaries. I have looked through the documentation profusely and attempted nearly every single syntax suggested (as well as the get_or_add() method) and I cannt get my custom resource to append a Vector2i key or its ENUM value to the resource dictionary.
the key and ENUM prints fine in the parent function, and I can manually add both in the custom resource by declaring them inside the empty dictionary. It also doesnt matter if I convert the vector2i to string, that doesnt seem to work either. I am sure it is something I am missing - Help?
ChunkResource (holds the dictionary I am attempting to modify)
class_name ChunkResource
extends Resource
var chunk_index : Vector2i
var block_dict : Dictionary
var entity_dict : Dictionary
func generate_chunk_res(index: Vector2i) -> ChunkResource:
chunk_index = index
return self
World Generator (attempting to store block data on specified chunk)
func generate_new_chunk(chunks: Array[Vector2i], world_resource: WorldResource) -> ChunkResource:
var chunk_resource = ChunkResource.new()
for chunk in chunks:
chunk_resource.generate_chunk_res(chunk)
for x in range(0, world_resource.CHUNK_SIZE):
for y in range(-world_resource.CHUNK_SIZE, 0):
var noise = world_resource.noise_resource.noise.get_noise_2d(
x * world_resource.CHUNK_SIZE,
y * -world_resource.CHUNK_SIZE)
if noise > world_resource.noise_resource.noise_threshold:
var key:= Vector2i(x, y)
chunk_resource.block_dict[key] = Blocks.block.STONE
chunk_generated.emit()
return chunk_resource