Godot Version
4.3
Question
I’m trying to use resource.duplicate to make a copy of weapons/armor in the player’s inventory to show on an equipment menu. Here is the code snippet that uses duplicate:
#print(player_inv_slots[0].num_equipped)
for i in range(player_inv_slots.size()):
var cat = player_inv_slots[i].item.category
if cat == "Weapons" or cat == "Armor":
var dup = player_inv_slots[i].duplicate(true)
shown_equip.append(dup)
#print(dup.num_equipped)
Here I try to build an array shown_equip that is used to control what displays in the equipment menu. The first print returns the correct num_equipped from the original item in the inventory. However, the second print does not get the same value from the duplicate (dup) once it’s created. Not sure what’s going wrong; num_equipped is just an int, and to my understanding those should be carried over when using duplicate(true). How would I fix this problem and/or find a different solution?