Feivisto ive tried it, that code crashes my game.
duane
im setting them as variables
and i also have a reload func to deplete them
@export var weapons : Array[NodePath]
@export var weaponsammo : Array[int]
var currentweaponammosize : int
@export var weaponIcons : Array[CompressedTexture2D]
@export var currentWeapon = 0
@export var dynamitesticks = 5
@export var selectColor : Color
@export var normalColor : Color
@export var unavailableColor : Color
var weaponIndex = 0
and in ready i setup the inventory
#setup weaponinventory
for slot in weaponIcons.size():
var weaponslot = TextureRect.new()
weaponInventory.add_child(weaponslot)
for icon in weaponInventory.get_children():
var iconindex = icon.get_index()
icon.set_texture(weaponIcons[iconindex])
icon.modulate = normalColor
weaponIndex = currentWeapon
weaponIcon.set_texture(weaponIcons[currentWeapon])
get_node(weapons[currentWeapon]).start()
get_node(weapons[currentWeapon]).totalAmmo = weaponsammo[currentWeapon]
weaponInventory.visible = false
inventoryOpen = false
ideally i would like to make the inventory dynamic, so u start with basic the first 2 weapons (knife and pistol)and pickup others along the way. so i would need code to manipulate the inventory and add them. once a weapon is added it should stay in the inventory, but when its ammo is depleted it should be unavailable to select.