Container node not detected in script

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

I have a panel node as the root node, and there are a few child containers. I am designing a control configuration scene for my game.

In the script, I’ve initialized the node in the root’s script as

onready var action_list = get_node("Column/Scrollable/ActionList");

func _on_InputMapper_init(input_profile):
  for inp_act in input_profile.keys():
    var line = action_list.add_input_line(inp_act, input_profile[inp_act]);
      #the error drops here. It says:
      #Invalid call. Nonexistent function 'add_input_line' in base 'Nil'.

Here, the Column has a few children other than Scrollable, Scrollable is a scroll container with a single child ActionList, and ActionList is an empty container. In it, there exists a function add_input_line().

I’ve checked thoroughly whether there is a spelling error or something of the sort in the path, or if there is a whitespace I’m not aware of. When I re-typed the path for ActionList, the compiler even autocompleted the path and it still drops the same error.
I’ve also tried to make children of ActionList and then simply set their values, so that the ActionList isn’t empty when I call it in the script. The same error still shows.

So, to sum it up, there is a Container as a child, and the path is correct to my knowledge, and yet it keeps saying that the variable is Nil.
If a container is empty, is it not detected in script by its path?

Apparently it was a very interesting thing.
SO basically what happened was, an ‘onready var’ statement was being slow, and it wasn’t completely executed by the time on_InputMapper_init() was called. So, the compiler kept saying that it was nil.

Lesson to be learnt: write code in a stringent fashion. You must know how your code runs.

strive_and_conjure | 2020-05-23 12:57