Invalid set index 'rng' (on base: 'Spatial()') with value of type 'RandomNumerGenerator'

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

I getting the error in the title but I don’t know why at the line that says: self.rng =

extends Node

# This is the GameManager, the base of the game

func _ready():
    var x =
	Vector3(0, 0, 0), # origin
	1, # xdim
	1 # zdim

class Colony extends Spatial:

    # origin
    var origin : Vector3
    # x dimension (loops start at 0 and ends in xdim-1 in general)
    var xdim : int
    # z dimension (loops start at 0 and ends in zdim-1 in general)
    var zdim : int
    # number of points in the xz plane
    var xzdim : int

    # camera
    var camera : Camera

    func _init(origin, xdim, zdim):
	    # random generator
	    self.rng =
	    self.origin = origin
	    self.xdim = xdim
	    self.zdim = zdim
	    self.xzdim = xdim*zdim
:bust_in_silhouette: Reply From: Thomas Karcher

You didn’t define the variable rng before in class Colony, and it is also not part of the parent class Spatial. Just add…

var rng : RandomNumberGenerator

…in the class header (before the init function), and the error should be gone.