Really i don,t undestand nothing

Godot Version

4.5.1

Question

1)I create a Hboxcontainer in my main scene,2) I go to my script of cards, which is istanciated at start the game a lot times, but not is at main scene root if i dont start game, then i get the referencing pressing at the create Hboxcontainer and dragging to my script to create @onready,3) i try print the Hboxcontainer object doing print in that script and i get<Object#null> always, i can call the from any place except from there.

I create more Hboxcontainer, buttons, textures, node2d, control to test, same result always. Right now i can,t create nothing can reference in that script, worst what is? My game is actually working, the old nodes working perfectly and the cycle of a deckbuilder have created. Old nodes are Hboxcontainer, buttons, control.

I try using referencing unique names with option % and nothing.

The question is: Is that script cursed?

https://imgur.com/a/oZ9cPyF

Whenever people ask for help with a particular piece of code, I often ask myself why they don’t include that code as part of the initial post. Please, please, please show your code if you want help. Otherwise, I can refer you to a website where ranting is the default: www.reddit.com

Seriously though, I find it hard to parse your description of the problem. Looking at the code in question would be much more productive – especially since your actual question refers to a specific cursed script.

1 Like

Also scene tree if referencing it from code.

My code is bad structure right now, i need at least 10 images not represent nothing useful.

Control(root) named Control have child HBoxContainer named PlayedCards with access to unique name. In the script:

extends TextureButton

@onready var played_cards: HBoxContainer = %PlayedCards

func _ready() → void:

print(played_cards)

result in console: <Object#null>

https://imgur.com/a/oZ9cPyF

╴Control
┠╴Market
┃ ┠╴Card
┃ ┠╴@TextureButton@2
┃ ┠╴@TextureButton@3
┃ ┠╴@TextureButton@4
┃ ┠╴@TextureButton@5
┃ ┖╴@TextureButton@6
┠╴PlayedCards
┠╴Hand
┃ ┠╴Card
┃ ┠╴@TextureButton@7
┃ ┠╴@TextureButton@8
┃ ┠╴@TextureButton@9
┃ ┖╴@TextureButton@10
┠╴Button
┠╴CanvasLayer
┃ ┖╴HBoxContainer
┃ ┠╴Label
┃ ┠╴Label2
┃ ┠╴Label3
┃ ┖╴Label4
┠╴Button2
┠╴discard_view
┃ ┠╴ColorRect
┃ ┠╴MarginContainer
┃ ┃ ┖╴VBoxContainer
┃ ┃ ┠╴Label
┃ ┃ ┖╴ScrollContainer
┃ ┃ ┠╴GridContainer
┃ ┃ ┠╴_h_scroll
┃ ┃ ┠╴_v_scroll
┃ ┃ ┖╴_focus
┃ ┖╴BackButton
┠╴Button3
┠╴champions_view
┃ ┠╴ColorRect
┃ ┠╴MarginContainer
┃ ┃ ┖╴VBoxContainer
┃ ┃ ┖╴ScrollContainer
┃ ┃ ┠╴GridContainer
┃ ┃ ┠╴_h_scroll
┃ ┃ ┠╴_v_scroll
┃ ┃ ┖╴_focus
┃ ┖╴Button
┖╴NewDeck

sorry for this disaster, i am still learning

Does the node “PlayedCards” have “% Access as unique name” checked when you right-click it?

yes, of course

Which node has the script attached? I would expect it to be on the root Control, but it extends TextureButton…

the node is a texturebutton, all the cards in my game are texturebuttons with only the texturebutton how root the scene and nothing more, all the cards are only images really, and i want pressed() function and can sort them easily in boxcontainer

Is the script attached to this node named Control?

No. like i was saying, the script(problematic script) is attached to only card scene, which is only a texturebutton, he is not initially in the main scene where Control is.

Same-scene limitation

A scene unique node can only be retrieved by a node inside the same scene.

Since your card scene is a different scene than the one containing the unique node %PlayedCards, you can’t (directly) use that reference in its script.

3 Likes

you save my life.

I was very confused; I had the feeling I was always doing the same thing, but I've been calling the objects in the script in various ways. I need to analyze it carefully. Thank you so much; I was going crazy thinking it was the Godot program being inconsistent.