Table Index Matching in Luau
Ruby Maelstrom
Currently, when scripting in Luau, indexing of tables does not match between Luau functions and ll. functions.
For example, the following return the same values:
str = ll.List2String(List,2)
and
str = List[3]
This isn't exactly a bug, both are functioning 'correctly', but it's going to cause some issues. Is there a reasonable solution to this?
Log In
Wulfie Reanimator
Can confirm. Mixing LSL calls and Lua loops is sure to cause headaches for years to come like this. As an example, here's a script that simply outputs keys of avatars in the region.
local AGENT_LIST_REGION = 4
local agents = ll.GetAgentList(AGENT_LIST_REGION, {})
ll.OwnerSay("Loop from 0 to list length")
for i=0, #agents, 1 do
ll.OwnerSay(`{i} {ll.List2Key(agents, i)}`)
end
-- 0 779e1d56-5500-4e22-940a-cd7b5adddbe0
-- 1
ll.OwnerSay("Loop by key-value pairs:")
for k,v in pairs(agents) do
ll.OwnerSay(`{k} {ll.List2Key(agents, k)}`)
end
-- 1
ll.OwnerSay("Loop by key-value pairs with Lua indexing:")
for k,v in pairs(agents) do
ll.OwnerSay(`{k} {agents[k]}`)
end
-- 1 779e1d56-5500-4e22-940a-cd7b5adddbe0