In the project there are several numbers which contain the script Button.gd
extends KinematicBody2D
var the_number = randi()%22+-3
func _on_Hex_pressed():
$Sprite.modulate = Color(1.0, 1.0, 1.0, 1.0)
Add.numbers_to_add.append(the_number)
Add.button_the_number_came_from.append(self)
They contain an autoload script Add.gd
extends Node
var numbers_to_add : Array = Array()
var button_the_number_came_from : Array = Array()
func _process(delta):
if numbers_to_add.size() > 2:
if numbers_to_add[0] + numbers_to_add[1] == numbers_to_add[2]:
for index in button_the_number_came_from.size():
button_the_number_came_from[index].queue_free()
elif numbers_to_add[0] + numbers_to_add[1] != numbers_to_add[2]:
print("no")
button_the_number_came_from.clear()
numbers_to_add.clear()
print(numbers_to_add)
When the sum of two numbers are not equal to the result no is printed in the output.How can I access this Add.gd
program line below in the func _on_Hex_pressed():
of the Button.gd
script so I can change the sprite color when no is printed ?
elif numbers_to_add[0] + numbers_to_add[1] != numbers_to_add[2]: