Trouble getting data to persist
Posted: Sat Mar 16, 2019 2:58 pm
Hey, I'm having trouble keeping track of animations I've created across loads. My code looks like this:
This code works fine during a given run, in that only one animation is created per lab. However, when I save and load the game, new animations get created in addition to the ones in the save. I expect the table global.labAnimations to persist, and lab.unit_number to be persistent across save/load. What am I missing?
Code: Select all
if global.labAnimations == nil then
global.labAnimations = {}
end
local labAnimations = global.labAnimations
-- table is filled out like this when iterating through all labs:
if labAnimations[lab.unit_number] == nil then
labAnimations[lab.unit_number] = rendering.draw_animation({
...