There are two issues with your code, I think. The first problem is that get_sets() is only run once at login and item.broth is a string and thus undergoes static assignment. So the way that you have it set up right now, sets.JA['Call Beast'].ammo should be "none" regardless what item.broth changes to. The second is probably mostly a syntactic problem in the "item.broth = item.broth[BrothArray[BrothIndex]]" assignment, which isn't possible because item.broth isn't a table.
Anyway, there are two ways to solve the first problem and they both also solve the second:
1: (you no longer need the item table)
Code:
function self_command(command)
if command == 'broth' then
BrothIndex = (BrothIndex % #BrothArray) + 1
add_to_chat(8,'Use Broth: ' .. BrothArray[BrothIndex])
sets.JA.['Call Beast'].ammo = BrothArray[BrothIndex]
end
end
2: (make item.broth into a table)
Code:
function get_sets()
item={}
item.broth={name="none"}
sets.JA = {}
sets.JA['Call Beast'] = {ammo=item.broth,hands="Ankusa Gloves +1"}
BrothIndex = 1
BrothArray = {"Lucky Broth","Fizzy Broth","Spicy Broth","Saline Broth"}
end
...
function self_command(command)
if command == 'broth' then
BrothIndex = (BrothIndex % #BrothArray) + 1
add_to_chat(8,'Use Broth: ' .. BrothArray[BrothIndex])
item.broth.name = BrothArray[BrothIndex]
end
end