What is the problem with my code

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

I was doing online tutorials to make chunk generation for a 2d game. There is something wrong with my code. It says that the Identifier GRASS isn’t declared in this current scope even though I declared it in an enum, here is my code:

extends Node2D

var noise = preload(“res://Scripts/softnoise.gd”)
var block = preload(“res://Instances/Block.tscn”)
enum block_types{

export var World_Debth = 64
export var Surface_Height = 64
export var Chunk_Width = 32

func _ready():
var softnoise = noise.SoftNoise.new(11989450398487431)
for x in range(0, Chunk_Width):
var y = floor(softnoise.openSimplex2D((get_global_transform().origin.x/32 + x)*.1)*Surface_Height * .2)
new_block(Vector2(x * 32,y * 32),GRASS)
This is where the error shows up saying: the Identifier GRASS isn’t declared
in this current scope

func new_block(pos, type):

var new_block = block.instance()
new_block.block_type = type
:bust_in_silhouette: Reply From: kidscancode

You’ve declared a named enum - the name is block_types, so to reference it, you’d need to say block_types.GRASS.

See here for more information.