i'm currently learning the ins and outs of godot (especially the script part) and i've come across a problem i don't understand on a conceptual level and i hope to find the underlying problem and solution here.
i'm practising around with a checkers game and would like to manipulate variables from one script to another like this:
the tree looks like this with the Game Node being the root
- Game Node
- Board Sprite
- Control Node
- Button Node
The Game Node handles the setup process and is in control of the board and its functionality. Inside of it, there is a 2D array called board2d that is 8x8.
Since i want to populate the board with the red and blue stones of the players, i want to update the board2d array from another script with a function called
set_stone_on_board(x, y, stone):
Because my button is so far down in the tree, i have to make the call like this (which is almost definitely not the way to go but i couldnt find anything better and using the full res:// patch didnt work for me):
get_node("..").get_node("..").get_node("..").set_stone_on_board(1, 1, stone)
unfortunately my board_2d array is empty upon calling and i dont quite understand why that is since i didnt change the scene and the game node is a parent node of the button
Could anyone bring light to my darkened mind?
Also any form of "it might be better to use/do this that way" is appreciated :)
Thanks in advance