Godot Version
4.4.1.stable
Question
I’m working on a settings menu, though right now I just have the sensitivity in it. What should be happening is when the textbox is updated, the slider and the sensitivity variable is updated and same for the slider (save for updating the textbox instead). But for some reason, a specific check always reads true. I tried replacing the check with a different one for similarly buggy behavior.
Here’s the function that manages things:
func _process(delta: float) -> void:
ReadValue += $HSlider.value
if $TextEdit2.text.to_float() != Sensitivity:
Sensitivity = $TextEdit2.text.to_float()
$HSlider.value = floor($TextEdit2.text.to_float()*100)/100
elif ReadValue != floor(($TextEdit2.text.to_float())*100)/100 and not (Sensitivity > 0.1 or Sensitivity < -0.1):
print("Pulled value: ", $HSlider.value, "; Read Value: ", ReadValue, "; Sensitivity: ", Sensitivity, "; $TextEdit2.text.to_float(): ", $TextEdit2.text.to_float(), "; Floor: ", floor($TextEdit2.text.to_float()*100)/100,"; Is different: ", ReadValue != floor($TextEdit2.text.to_float()*100)/100)
Sensitivity = $HSlider.value
$TextEdit2.text = str(Sensitivity)
if $Button.button_pressed:
FileAccess.open("res://Settings.txt", FileAccess.WRITE).store_string("This is your settings file! I heavily advise against touching it.\n:CamSensitivity:" + str(Sensitivity) + ":")
ReadValue = 0.0
More specifically the check ReadValue != floor(($TextEdit2.text.to_float())*100)/100 always reads true. This renders the textbox useless, making it difficult to set any sensitivity not approved by the slider.
I had put in the print code to check that it should be false, and sure enough, every single thing I checked had the same exact value, but the check still read true
print("Pulled value: ", $HSlider.value, "; Read Value: ", ReadValue, "; Sensitivity: ", Sensitivity, "; $TextEdit2.text.to_float(): ", $TextEdit2.text.to_float(), "; Floor: ", floor($TextEdit2.text.to_float()*100)/100,"; Is different: ", ReadValue != floor($TextEdit2.text.to_float()*100)/100)
This isn’t the first unsolvable error I’ve had so far. I had another error with my door system that I had to code in checks and work arounds for a point float point precision error. Is this the same thing? Is it something different? Did I miss something specific?