Compare commits

..

2 commits

Author SHA1 Message Date
Marcus
267e30acfc
Merge 95a9fecbd0 into bee92f489c 2025-06-29 19:01:30 +00:00
Ukendio
95a9fecbd0 fix jecs.meta for adding values
Some checks failed
analysis / Run Luau Analyze (push) Has been cancelled
unit-testing / Run Luau Tests (push) Has been cancelled
2025-06-29 20:58:26 +02:00
2 changed files with 13 additions and 9 deletions

View file

@ -2034,18 +2034,16 @@ local function ecs_bulk_insert(world: World, entity: Entity, ids: { Entity }, va
local value = values[i] :: any local value = values[i] :: any
local on_add = idr.hooks.on_add local on_add = idr.hooks.on_add
local on_change = idr.hooks.on_change
if value then if value ~= nil then
columns_map[id][row] = value columns_map[id][row] = value
local on_change = idr.hooks.on_change
local hook = if set then on_change else on_add local hook = if set then on_change else on_add
if hook then if hook then
hook(entity, id, value :: any) hook(entity, id, value :: any)
end end
else elseif on_add then
if on_add then on_add(entity, id)
on_add(entity, id, value)
end
end end
end end
end end
@ -2812,7 +2810,7 @@ local function world_new()
if value == NULL then if value == NULL then
inner_world_add(world, i, ty) inner_world_add(world, i, ty)
else else
inner_world_add(world, i, ty, value) inner_world_set(world, i, ty, value)
end end
end end
end end

View file

@ -93,7 +93,10 @@ TEST("bulk", function()
CHECK(world:get(e, B) == 2) CHECK(world:get(e, B) == 2)
CHECK(world:get(e, C) == 3) CHECK(world:get(e, C) == 3)
jecs.bulk_insert(world, e, { D, E, F }, { 4, nil, 5 }) jecs.bulk_insert(world, e,
{ D, E, F },
{ 4, nil, 5 }
)
CHECK(world:get(e, A) == 1) CHECK(world:get(e, A) == 1)
CHECK(world:get(e, B) == 2) CHECK(world:get(e, B) == 2)
CHECK(world:get(e, C) == 3) CHECK(world:get(e, C) == 3)
@ -102,7 +105,10 @@ TEST("bulk", function()
CHECK(world:get(e, E) == nil and world:has(e, E)) CHECK(world:get(e, E) == nil and world:has(e, E))
CHECK(world:get(e, F) == 5) CHECK(world:get(e, F) == 5)
jecs.bulk_insert(world, e, { A, D, E, F, C }, { 10, 40, nil, 50, 30 }) jecs.bulk_insert(world, e,
{ A, D, E, F, C },
{ 10, 40, nil, 50, 30 }
)
CHECK(world:get(e, A) == 10) CHECK(world:get(e, A) == 10)
CHECK(world:get(e, B) == 2) CHECK(world:get(e, B) == 2)