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):

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)
                GridGenerator_Script.ValidGridSize = true
                break; # No need to keep running the loop
        GridGenerator_Script.ValidGridSize = false
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 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.