I am working on an equipment screen for my current project.
I have one table that represents all of my characters, stats, and equipment.
local myData = { [1] = {name = "Blair", frame = 3, active = nil, class = "Warrior", maxHealth = 100, health = 100, strength = 10, armor = 10, speed = .12, weaponEquip = nil, shieldEquip = nil, trinket1 = nil, trinket2 = nil, }, [2] = {name = "Lily", frame = 4, active = nil, class = "Rogue", maxHealth = 100, health = 100, strength = 10, armor = 10, speed = .16, weaponEquip = nil, shieldEquip = nil, trinket1 = nil, trinket2 = nil, }, [3] = {name = "Kylianna", frame = 2, active = nil, class = "Mage", maxHealth = 100, health = 100, strength = 10, armor = 10, speed = .12, weaponEquip = nil, shieldEquip = nil, trinket1 = nil, trinket2 = nil, }, }
I have another table that represents all the equipment in the players inventory.
local equipInventory = { [1] = {name = nil, frame = 4, description = "Weapon", class = "Warrior", strength = 5, armor = 0, plusHealth = 0, plusSpeed = 0, }, [2] = {name = nil, frame = 2, description = "Armor", class = "Warrior", strength = 0, armor = 5, plusHealth = 0, plusSpeed = 0, }, [3] = {name = nil, frame = 3, description = "Trinket", class = "Warrior", strength = 0, armor = 0, plusHealth = 0, plusSpeed = 0, }, }
The first question is this, when i’m on the equipment screen, I am trying to change the value of myData[1].weaponEquip to equipInventory[1] that way when I look up the value of myData[1].weaponEquip, I can then see all the characteristics of the weapon that was equipped.
Would it be something as simple as creating a function that states myData[1].weaponEquip = equipInventory[1]?
Second question, once the above is achieved, I need some guidance to access a specific table value. within equipInventory[1] you can see that I have a value for frame as 4. This represents an image on a sprite sheet.
I would want to be able to change the image of an object based on that value, would this value be found with myData[1].weaponEquip.frame?
basically im trying to figure out how to look inside the character table to find the equipment table that was placed in a value and then find a single value on that table.
Sorry if its a little confusing, I’ll try to clear it up if need be