Godot Version
4.6
Question
hello! :3
Im following a tut on how to make an inventory (How to Make an Inventory in Godot 4.1 #2: Inventory model and Godot resources | How to Make an ARPG [timestamp at nine minutes]) and i typed in the code:
extends Control
func update():
for i in range(nin(inventory.items.size(), slots.size())):
slots[i].update(inventory.items[i])
and its not giving me the error “Error at (9, 20): Function “nin()” not found in base self.”
did i type it in wrong? (my screens very blurry so i might have just mistaken a letter for another)
Heres my whole code if you need it
:
extends Control
@onready var inventory: Inventory = preload("res://Resources/Playerinv.tres")
@onready var slots: Array = $NinePatchRect.get_children()
var isopen: bool = false
func update():
for i in range(nin(inventory.items.size(), slots.size())):
slots[i].update(inventory.items[i])
func open():
visible = true
isopen = true
func close():
visible = false
isopen = false
func _ready() -> void:
hide()
func _on_visibility_changed() -> void:
if visible:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
else:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
func _unhandled_input(event: InputEvent) -> void:
if event.is_action_pressed("Inventory"):
if visible:
hide()
else:
show()