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
in Engine by (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.

by (21,305 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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.