local a = {["a"] = "rofl", ["b"] = "lol"}
function IndexDictionary(dictionary,index)
local i = 0
for _,value in pairs(dictionary) do
i=i+1
if i == index then
return value
end
end
end
print(IndexDictionary(a,1))
And here’s another:
local a = {["a"] = "rofl", ["b"] = "lol"}
local a2 = {}
for _,value in pairs(a) do
table.insert(a2,value)
end
print(a2[1])
But the first is probably better.
But for what reason are you trying to index a dictionary via a number?
The order and the IndexDictionary function could be non-deterministic. You shouldn’t rely on a behavior that is expliticly undefined.
You could either hardcode the keys in a table as an array, or you could create a new array then iterate the old table but disregarding the order and then do an ordered insertion to the new table. Then you could use that array as the key in that case.