Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | pixelinkmedia |
I am going through a tutorial. But the project generate errors because I believe the tutorial is outdated from 2017
I first try to pre-load a scene2 that contains a list item
I try to get node from this preloaded scene
But, error says node not found “number” & “Label”
What is the correct way to get a node or I suspect that the preload scene 2 is not loading.
CODE:
const ListItem = preload("listitem.tscn")
var listIndex = 0
func additem( value):
var item = ListItem.instance()
listIndex += 1
item.get_node("number").text = str( listIndex )
item.get_node("Label").text = value
$ScrollContainer/list.add_child(item)
func _ready():
for i in range(10):
additem("List Text String")
What’s the tutorial you’re following?
Code seems normal to me. Check if the nodes’ names are correct. Note that it’s case-sensitive.
Dlean Jeans | 2019-06-11 10:16
Yeah… have case sensitive right on this one.
pixelinkmedia | 2019-06-11 10:21
Add item.print_tree_pretty()
to your additem
and paste the output here. Might help seeing what’s wrong.
Dlean Jeans | 2019-06-11 10:29
** Debug Process Started **
OpenGL ES 3.0 Renderer: GeForce GT 640/PCIe/SSE2
┖╴Node2D
┖╴Panel
┠╴number
┖╴Label
┖╴@Node2D@2
┖╴Panel
┠╴number
┖╴Label
┖╴@Node2D@3
┖╴Panel
┠╴number
┖╴Label
┖╴@Node2D@4
┖╴Panel
┠╴number
┖╴Label
┖╴@Node2D@5
┖╴Panel
┠╴number
┖╴Label
┖╴@Node2D@6
┖╴Panel
┠╴number
┖╴Label
┖╴@Node2D@7
┖╴Panel
┠╴number
┖╴Label
┖╴@Node2D@8
┖╴Panel
┠╴number
┖╴Label
┖╴@Node2D@9
┖╴Panel
┠╴number
┖╴Label
┖╴@Node2D@10
┖╴Panel
┠╴number
┖╴Label
** Debug Process Stopped **
pixelinkmedia | 2019-06-11 10:38
Use the { }
button. The tree format is broken without it.
Dlean Jeans | 2019-06-11 10:41
What is { } button.
And where is it?
pixelinkmedia | 2019-06-11 10:43
This is the exact error on lines “number” & “Label” of get_node…
Invalid set index ‘text’ (on base: ‘null instance’) with value of type ‘String’.
On the Error(s) tab of debugger it just says…
E 0:00:01:0064 Node not found: number
pixelinkmedia | 2019-06-11 11:04
Here:
Dlean Jeans | 2019-06-11 11:06
Oh… the code button, I assume you meant in Godot itself
** Debug Process Started **
OpenGL ES 3.0 Renderer: GeForce GT 640/PCIe/SSE2
┖╴Node2D
┖╴Panel
┠╴number
┖╴Label
┖╴@Node2D@2
┖╴Panel
┠╴number
┖╴Label
┖╴@Node2D@3
┖╴Panel
┠╴number
┖╴Label
┖╴@Node2D@4
┖╴Panel
┠╴number
┖╴Label
┖╴@Node2D@5
┖╴Panel
┠╴number
┖╴Label
┖╴@Node2D@6
┖╴Panel
┠╴number
┖╴Label
┖╴@Node2D@7
┖╴Panel
┠╴number
┖╴Label
┖╴@Node2D@8
┖╴Panel
┠╴number
┖╴Label
┖╴@Node2D@9
┖╴Panel
┠╴number
┖╴Label
┖╴@Node2D@10
┖╴Panel
┠╴number
┖╴Label
** Debug Process Stopped **
pixelinkmedia | 2019-06-11 11:07