0 votes

When i run this script, the value of NT changes every time i input a valid number, but only for a moment, before turning back into the original value, why is this happening?

Here's the code:

extends LineEdit

func _process(delta):
    update()

var GridSize_Range = range(1,99)

var NT = 5

onready var GridGenerator_Script = load("res://Scripts/Grid Generator.gd").new()

func _on_LineEdit_text_entered(new_text):
    if new_text.is_valid_integer():
        var new_text2 = int(new_text)
        for i in GridSize_Range:
            if new_text2 == i:
                NT = int(new_text)
                print(NT)
                GridGenerator_Script.ValidGridSize = true
                break; # No need to keep running the loop
                self.clear()
    else:
        GridGenerator_Script.ValidGridSize = false
        self.clear()
Godot version Godot 3.2.3
in Engine by (34 points)

I don't think it is happening in this part of code. Search other places, which may influence NT from outside, maybe You tested something and forgot about some mechanism that restores your NT. Or you queue free line edit every time you enter text and create one anew ?

You were right! The actual code is working just fine, it really is an outside factor, thanks for the help!

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 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 webmaster@godotengine.org with your username.