This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Hy everyone,

I have a code that needs to retrieve an array containing arrays. When I test, it gives me [[Reference:1261]]. but it doesn't indicate any error. The code is meant to make an edge-based astar to block certain directions. I use a tilemap

A class to hold information :

class Wall:

var Direction : Vector2
var Diagonals : Array

func _init(dir : Vector2, diago:Array):
    Direction = dir
    Diagonals = diago

I make a list of directions, which I combine :

const DIRECTION = {
"N" :Vector2(0,1),
"S" :Vector2(0,-1),
"E" :Vector2(0,1), etc...

onready var WALL = {
"S" : DIRECTION["S"], [DIRECTION["S_E"], DIRECTION["S_O"]]), etc...

onready var WALLS_ON_EDGES = {
TYPE_WALLS.CORNER_N_E : [WALL["N"], WALL["E"]], etc...


At each tilemap index, I give it the array contained in WALLS_ ON_ EDGES

func Add_connect_type(n:int, type_walls:int):

 ///... code

if WALLS_ON_EDGES.has(type_walls):  
    _cells_index_with_wall[n] = WALLS_ON_EDGES[type_walls]

Then, I select the index of a particular tile and store the array of that tile to do operations with :

func Create_all_Walls_on_edges():
var all_index_with_wall = _cells_index_with_wall.keys()

///... code

for idx in all_index_with_wall:

    #array of all cells with idx
    var cells_idx = get_used_cells_by_id (idx)

    #Walls of idx
    var ar_walls_of_idx = _cells_index_with_wall[idx]

    print("ar_walls_of_idx : " + str(ar_walls_of_idx))
    if ///...code

the ar_ walls _of _idx indicates: [[Reference:1261]]

Do you know how to interpret it?
Good Day,

Godot version V 3.4.3
in Engine by (87 points)
edited by

Arrays are passed via references. All variables made equal to certain array will behave like hyperlinks to just one array value. Still, that doesn't explain why printing returns this reference instead of value. Did You try it without str()? Or could it be that original array was freed before print() line ?

Thank you for the answer.

"Did You try it without str()? Or could it be that original array was freed before print() line ?"
The array is used as a reference so once initialized, I don't touch it anymore. I tried without the str() by putting directly the value -> print(arwallsof_idx), but it tells me the same thing.

On the other hand, I managed to access the values they contain.

Please log in or register to answer this question.

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 [email protected] with your username.