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

In the project there are several numbers which contain the script

extends KinematicBody2D 

var the_number = randi()%22+-3

func _on_Hex_pressed():
    $Sprite.modulate = Color(1.0, 1.0, 1.0, 1.0)

They contain an autoload script

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():
        elif numbers_to_add[0] + numbers_to_add[1]  != numbers_to_add[2]:

When the sum of two numbers are not equal to the result no is printed in the output.How can I access this program line below in the func _on_Hex_pressed(): of the Button.gdscript so I can change the sprite color when no is printed ?

  elif numbers_to_add[0] + numbers_to_add[1]  != numbers_to_add[2]:
in Engine by (141 points)

1 Answer

0 votes
Best answer

Are you trying to read the output console? Don't know if it's possible. But you could emit a signal for this situation.

An example: 
    signal printed_no
func _process(delta):
elif numbers_to_add[0] + numbers_to_add[1]  != numbers_to_add[2]:
func _ready():
    Add.connect("printed_no", self, "_on_printed_no")
func _on_printed_no():
    #do stuff
by (190 points)
selected by

Thank You; It worked .

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.