While everything sdahlka said was correct, a few additions:
1. " don't work in the above code because the command handler uses those to group tokens together. It will work when you use it in an addon file, but if you enter it via the chat box or Windower console, you need to resort to using ' or escaping the " with a backslash: //eval print(\"word\")
2. The outer if in the example code is not required.
3. You don't need to check if the type of v is a table, only if v exists. If no item is in a certain treasure pool slot, the value will be nil.
4. Re-using windower.ffxi.get_items() is a bad idea, as it's a very expensive function. In the above code snippet you call it up to 11 times every time the code runs, instead of just one, which is all you need.
5. pairs, unlike ipairs, also doesn't guarantee the order. ipairs always enumerates elements from 1 to n, where n is the size of the table as defined by the # operator. pairs enumerates the elements in an arbitrary order (although it will often, but not always, coincide with ipairs on numerically indexed tables).
All said, the code can be prettified a bit more if you're using common libraries. If you want, for example, a set of IDs, you can do this:
S(windower.ffxi.get_items().treasure):map(table.get-{'item_id'})
i have only seen codeing like this once and did not know how it worked
so these are the same thing only one is less resource intensive
require('luau') print(res.items[S(windower.ffxi.get_items().treasure):map(table.get-{'item_id'})].name) res = require('resources') if windower.ffxi.get_items().treasure[0] then for i,v in pairs(windower.ffxi.get_items().treasure) do if type(windower.ffxi.get_items().treasure[i]) == "table" then print(res.items[windower.ffxi.get_items().treasure[i].item_id].name) end end end