0 votes

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 WorldDebth = 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
var y = floor(softnoise.openSimplex2D((getglobaltransform().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
asked May 7 in Projects by Coder8188 (16 points)

1 Answer

0 votes

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.

answered May 7 by kidscancode (17,762 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.