Godot Version 4.3
Good day to you! I recently started programming in Godot and I had a problem with the code, here it is (invalid access to a property or key “texture” of a base object of type Nill) the error comes out in three code fragments at once, here they are (where the * is there and the error comes out):
extends Panel
@onready var item_visual: Sprite2D = $item_display
func update(item: InvItem):
if item:
item_visual.visible = false
else:
item_visual.visible = true
*item_visual.texture = item.texture
And here are the last two errors that are in one piece of code:
extends Control
@onready var inv: Inv = preload(“res://inventory/player_inv.tres”)
@onready var slots: Array = $NinePatchRect/GridContainer.get_children()
var is_open = false
func _ready() → void:
*update_slots()
close()
func update_slots():
for i in range(min(inv.items.size(), slots.size())):
*slots[i].update(inv.items[i])
func _process(delta):
if Input.is_action_just_pressed(“i”):
if is_open:
close()
else:
open()
func open():
visible = true
is_open = true
func close():
visible = false
is_open = false
I will be grateful for any help! All the best to you!