Issue is that initially the item concatenates rather than adds and after unequipping and reequipping it works the way I want. I do not know how to fix this. Below I have tried explaining in more detail.
Example:
<<set $stats = [ 3, 10, 5, 7, 2, 6]>>
<<print $stats[0] + $str>>
<<print $stats[1] + $int>>
<<print $stats[2] + $con >>
<<print $stats[3] + $dex>>
<<print $stats[4] + $def>>
<<print $stats[5] + $char>>
$str, $int, $con, $dex, $def, $char all get their information from any item or spell.
So if a necklace is equipped and it has
"Strength" : 0,
"Intelligence": 0,
"Constitution" : 0,
"Dexterity" : 0,
"Defense" : 100,
"Charisma" : 0,
Those values will be put inside the variable. The code I use for that from my equipment menu to equip and add item stats to a variable is:
<<elseif $gear.Place eq $neck.Type and $neck.Wearing eq false>> <<link [Equip]>><<set $str += $gear.Strength>> <<set $int += $gear.Intelligence>> <<set $con += $gear.Constitution>> <<set $dex += $gear.Dexterity>> <<set $def += $gear.Defense>> <<set $char += $gear.Charisma>> <<set $gear.hasEquip = true>> <<set $head.Wearing eq true>> <</link>>
That is after there are some checks to see if neck has something already equipped.
When
<<print $stats[0] + $str>>
is printed. I get 30, $stats is pulling the 3 and $str the 0. Then later if you look at the defense which
<<print $stats[4] + $def>> I get 2100,
In short what the stats look like before equiping an item,
Strength: 3
Intelligence: 10
Constitution: 5
Dexterity : 7
Defense : 2
Charisma: 6
When item is initially Equipped
Strength: 30
Intelligence: 100
Constitution 50
Dexterity 70
Defense :2100
Charisma: 60
When item is unequipped
Strength: 3
Intelligence: 10
Constitution: 5
Dexterity : 7
Defense : 2
Charisma: 6
When item is reequipped (What I want to happen to begin with)
Strength: 3
Intelligence: 10
Constitution: 5
Dexterity : 7
Defense : 102
Charisma: 6
Code for unequipping and taking away the stats added before:
<<if $gear.hasEquip == true>> Equipped <<link [UnEquip]>> <<set $str -= $gear.Strength>> <<set $int -= $gear.Intelligence>> <<set $con -= $gear.Constitution>> <<set $dex -= $gear.Dexterity>> <<set $def -= $gear.Defense>> <<set $char -= $gear.Charisma>> <<set $gear.hasEquip = false>> <</link>>