Godot Version
4.2.2
video Godot version 4.0
Question
this line of code has been giving me some trouble. im following a tutorial and tried following along but i’m unsure what i did to get an error. does anyone have time to help me out?
this is my error cannot find property “size” on base Arrary[ my class name from resource]
this is the line im having trouble with
for i in range(min(playerinv.Item_list.size(), slots.size())):
slots[i].update(playerinv.Item_list.size[i]) ```
this is what im watching https://youtu.be/X3J0fSodKgs?si=u2UX3f5mc_rKUuwn
my time stamp is 20:35. if you can help thanks in advance
Hi,
Don’t use Item_list.size[i]
to access an item at index i
, just use Item_list[i]
and that should work better.
By typing size[i]
, Godot is looking for a property called “size” to get its element at index i
, which is invalid as such a property does not exist. size()
is, however, a function returning the number of elements in an array (which you already know since you’re using it).
2 Likes
thank you ! i also wanted to know why when i use three backticks they format my words into a code but when i do it again instead of cutting off it just keep writting things in script
example
hi my name is func _ready():
but instead of stopping it keeps going ???
Your next three back ticks must be on a new line, single back ticks are for in-line code
`inline code sample`, maybe for a function name like `_ready()`
inline code sample
, maybe for a function name like _ready()
```gd
multi-line code sample
with indentation and everything
the first 'gd' makes the code sample use GDScript-
highlight colors, which wont look good on this text
Notice the ending ticks are on it’s own line
```
multi-line code sample
with indentation and everything
the first 'gd' makes the code sample use GDScript-
highlight colors, which wont look good on this text
Notice the ending ticks are on it's own line
And now I can type normally again.
1 Like