diff --git a/src/init.luau b/src/init.luau index 6c52dad1..79ea5d6f 100644 --- a/src/init.luau +++ b/src/init.luau @@ -739,7 +739,7 @@ do local lastArchetype: number local archetype: Archetype local queryOutput: { any } - local queryLength: number + local entities: { number } local i: number @@ -768,7 +768,6 @@ do end queryOutput = {} - queryLength = #ids entities = archetype.entities i = #entities @@ -810,7 +809,7 @@ do e = columns[records[E]] f = columns[records[F]] g = columns[records[G]] - elseif H then + elseif not I then a = columns[records[A]] b = columns[records[B]] c = columns[records[D]] @@ -873,7 +872,7 @@ do e = columns[records[E]] f = columns[records[F]] g = columns[records[G]] - elseif H then + elseif not I then a = columns[records[A]] b = columns[records[B]] c = columns[records[D]] @@ -919,7 +918,7 @@ do e[row], f[row], g[row] - elseif H then + elseif not I then return entityId, a[row], b[row], @@ -1108,12 +1107,12 @@ do for id in firstArchetypeMap.cache do local compatibleArchetype = archetypes[id] - local archetypeRecords = compatibleArchetype.records + local tr = compatibleArchetype.records local skip = false for i, componentId in components do - local index = archetypeRecords[componentId] + local index = tr[componentId] if not index then skip = true break diff --git a/test/tests.luau b/test/tests.luau index 7904ccf4..82535c4e 100644 --- a/test/tests.luau +++ b/test/tests.luau @@ -283,6 +283,32 @@ TEST("world:query()", function() CHECK(counter == 0) end + do CASE "query more than 8 components" + local world = jecs.World.new() + local components = {} + + for i = 1, 9 do + local id = world:component() + components[i] = id + end + local e = world:entity() + for i, id in components do + world:set(e, id, 13^i) + end + + for entity, a, b, c, d, e, f, g, h, i in world:query(unpack(components)) do + CHECK(a == 13^1) + CHECK(b == 13^2) + CHECK(c == 13^3) + CHECK(d == 13^4) + CHECK(e == 13^5) + CHECK(f == 13^6) + CHECK(g == 13^7) + CHECK(h == 13^8) + CHECK(i == 13^9) + end + end + do CASE "should be able to get next results" local world = jecs.World.new() :: World world:component()