diff --git a/jecs.luau b/jecs.luau index cc3e20d..f9a4174 100755 --- a/jecs.luau +++ b/jecs.luau @@ -2157,13 +2157,12 @@ local function world_new() local eindex_dense_array = {} :: { Entity } local eindex_sparse_array = {} :: { Record } local eindex_alive_count = 0 - local eindex_max_id = 0 local entity_index = { dense_array = eindex_dense_array, sparse_array = eindex_sparse_array, alive_count = eindex_alive_count, - max_id = eindex_max_id, + max_id = 0, } :: EntityIndex local component_index = {} :: ComponentIndex @@ -2605,7 +2604,7 @@ local function world_new() return entity else - for i = eindex_max_id + 1, index do + for i = entity_index.max_id + 1, index do eindex_sparse_array[i] = { dense = i } :: Record eindex_dense_array[i] = i end diff --git a/test/tests.luau b/test/tests.luau index bac14da..8c48708 100755 --- a/test/tests.luau +++ b/test/tests.luau @@ -24,6 +24,16 @@ type Id = jecs.Id local entity_visualiser = require("@tools/entity_visualiser") local dwi = entity_visualiser.stringify +TEST("dai", function() + local world = jecs.world() + local C = world:component() + + world:set(C, jecs.Name, "C") + CHECK(world:get(C, jecs.Name) == "C") + world:entity(2000) + CHECK(world:get(C, jecs.Name) == "C") +end) + TEST("another axen banger", function() -- taken from jecs.luau local world = jecs.world()