So I am working on Tic Tac Toe logic and practicing using groups. I have an array acting as a state machine to handle whether a button is empty, has_x or has_o. (0,1,2 in the index to be specific). This part of my logic works great and it's all running off only two very short scripts.
I have the buttons sorted into arrays to check for their variable values. My goal is to see if their local state variable either has_x or has_o to determine the win.
(Yes, my singleton is named StateMachine but it is not the machine, I ended up doing that local because it made sense for the smaller objects in this app).
My arrays, sorted at ready:
onready var myButtons = get_tree().get_nodes_in_group('all_buttons')
onready var row1 = get_tree().get_nodes_in_group('row_1')
onready var row2 = get_tree().get_nodes_in_group('row_2')
onready var row3 = get_tree().get_nodes_in_group('row_3')
onready var column1 = get_tree().get_nodes_in_group('column_1')
onready var column2 = get_tree().get_nodes_in_group('column_2')
onready var column3 = get_tree().get_nodes_in_group('column_3')
onready var across1 = get_tree().get_nodes_in_group('across_1')
onready var across2 = get_tree().get_nodes_in_group('across_2')
And each button has this variable and array:
var stateMachine = ["EMPTY", "HAS_X", "HAS_O"]
var state = stateMachine[0]
So what I am trying to do is check if the local variable "state" shares a value across a group.