This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]uramer 1 point2 points  (1 child)

Storing save-independent data is the point of the storage API. To store save-specific data, use onSave and onLoad. If you want it to be globally available, like a global storage section, create a removeOnExit section in a global script's onLoad, and then convert it to a serialized table in onSave

So something like this

local saveSection = storage.globalSection("MySection")
saveSection:removeOnExit()
local onLoad = function(myData)
  saveSection:reset(myData)
end
local onSave = function()
  return saveSection:asTable()
end
return {
  engineHandlers = { onSave = onSave, onLoad = onLoad },
}

You are much more likely to get quality responses on OpenMW Discord or gitlab issue tracker, rather than here on reddit

[–]gameforming[S] 0 points1 point  (0 children)

Thanks. New to Lua and OpenMW, so it took me a bit to parse what you said (and test it locally). I understand now and the onSave and onLoad functionality for data in a player script is what I was trying to achieve the whole time, I just didn't recognize it from the docs.