Check dependent optics on storebox content change

Changes to the stack stored in a storebox do not trigger a node update,
which meant that affected optics to not get updated until the next ABM.

Use the newly introduced storebox_register_on_stack_change to trigger
a check on dependent optics just like node updates.
This commit is contained in:
Giuseppe Bilotta 2022-03-13 23:21:11 +01:00
parent 925de33418
commit 26ca863b68

View File

@ -294,11 +294,15 @@ do
end)
end
nodecore.register_on_nodeupdate(function(pos)
local t = dependency_index[hashpos(pos)]
if t then
for k in pairs(t) do
optic_check(unhash(k))
end
local function optic_check_dependents(pos)
local t = dependency_index[hashpos(pos)]
if t then
for k in pairs(t) do
optic_check(unhash(k))
end
end)
end
end
nodecore.optic_check_dependents = optic_check_dependents
nodecore.register_on_nodeupdate(optic_check_dependents)
nodecore.storebox_register_on_stack_change(optic_check_dependents)