Var is changed, but is immediately reset to original value

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Megatt4

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").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

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 ?

Inces | 2021-10-24 21:21

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

Megatt4 | 2021-10-31 00:56