im trying to get into more gdscript so i think knowing how to change properties of items trough code would be a good starter (at the very least)
What properties are you talking about? Properties of an item are stored in the item so you can use item.property to access it.
ex: item.position.x = 0
would set the x position of the item to zero.
thats what im talking about, im also half trying to know how to access nodes in scenes since i dont really know how
Nodes are accessed using a dollar sign. You can see this by dragging the node from the tree onto the script.
It sounds like you’re really starting from scratch so you might want to take a look at a tutorial. This one is very in depth.
The ultimate introduction to godot 4
how would i access the nodes inside the nodes and/or the parent node?
Are you talking about children nodes? You can get the children with get_node() or $ as a shortcut.
what about the parent or the node of the script?
you can get parent with “get_parent()” and you can access properties of the node the script is on directly by name.
can you do “$node.get_parent()”
You could, but that would just refer to the current node.
why would it be the current node
$node means get the child of the current node that has the name of the node. .get_parent() means get the parent of the previous node, and the parent is just the original node.
how would i refer to the current node without doing $node.get_parent()
you can use self. But don’t do something like “self.position”, you can just use “position” in that case.
so you just type “position” and done?
i tried using position, there is an error saying “identifier ‘position’ is not declared in the current scope.” could you help me?
position is a property of classes that inherit from Node2 or Node3 (and maybe some others).
In your script at the top there should be something like:
Extends means they inherit their properties and functions from something.
If you extend from Node (not Node2D or 3D) there will be no position.
From your questions I really recommend to check out the
beginner tutorials, there is one for 2d and one for 3d.
They are pretty good to get started.