$ operator and get_node are now assuming everything is a basic Node

Godot Version

Version 4.2.2

Question

I have recently started attempting to make a game for the first time, and was fiddling around with the project settings. Unfortunately, toggling “Use Hidden Project Data Directory” has caused most of the code I’ve written to stop working, specifically areas that call other nodes. Here’s an example of one of the areas with an error:

$TimeVal.text = str(time_val)
$SpeedVal.text = str(speed_val)
$TotalVal.text = str(time_val * speed_val)

The specific error message I am getting is: “The property “text” is not present on the inferred type “Node” (but may be present on a subtype). (Warning treated as error.)”

All 3 nodes called are Label nodes, and it has worked fine in the past. If anyone has a way to salvage this, I would greatly appreciate it.

Hey

Does it work if you cache it with type hint?
Something like

@onready var time_val: Label = $TimeVal
1 Like

I didn’t know you could do that, and now it’s working again! Thanks a lot for the help!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.