the identifier "i" isnt declared in the current scope. MIght be just little mistake and i havent notice it

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

export  (int) var width;
export (int) var height;
export (int) var x_start;
export (int) var y_start;
export (int) var offset;

var possible_pieces = [
preload("res://bananapiec.tscn"),
preload("res://heartpiece.tscn"),
preload("res://rubkpiece.tscn"),
preload("res://piece12.tscn")
];


var all_pieces = [];

func spawn_pieces():
    for i in width:
        for j in height:
            var rand = floor(rand_range(0, possible_pieces.size()));
            var pieces = possible_pieces[rand].instance();
            add_child(pieces);
            pieces.position = grid_to_pixel(i, j);
            all_pieces[i][j] = pieces;

func match_at(column, row, color):
    if i > 1:
        if all_pieces[i - 1][j] != null && all_pieces[i - 2][j] != null:
            if all_pieces[i - 1][j].color == color && all_pieces[i - 2][j].color == color:
                return true;
    pass;

func grid_to_pixel(column, row):
    var new_x = x_start + offset * column;
    var new_y = y_start + -offset * row;
    return Vector2(new_x, new_y);

func make_2d_array():
    var array = [];
    for i in width:
        array.append([]);
        for j in height:
            array[i].append(null);
    return array; 
func _ready():
    randomize();
    all_pieces = make_2d_array();
    spawn_pieces();

problem: if i > 1:

:bust_in_silhouette: Reply From: kidscancode

In your match_at() function, there is no variable i declared, so if i > 1 will definitely be a problem.

Shouldn’t you be using one of the parameters being passed in? What exactly are you trying to do there?