0 votes

https://imgur.com/gallery/cfQm0N1

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 addinputline().

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?

in Engine by (26 points)
reshown by

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 onInputMapperinit() 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.

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 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 webmaster@godotengine.org with your username.