Ryan F. Mercer
Whys
1.) You need to have the "include" line near the top of every file-scope that wants to use the SaveUtils functionality. Without looking at your code, I assume you are correct that it would be included in both your main mod and the modified UnitPanel.
2.) There are two considerations regarding load order.
2a.) As long as SaveUtils is included near the top of each file-scope that uses it, then load order isn't necessarily a problem. SaveUtils itself isn't loaded, but rather embeds global functions into the file-scope, such as save() and load().
2b.) The shared cache is a load order issue and is explained somewhat in the documentation here:
For maximum performance and to avoid potential desyncronization of data, if you are calling save() or load() prior to Events.LoadScreenClose(), such as within the global-scope of a modded built-in lua file, then you want to call share_SaveUtils() first (after the "include" line). However, doing so will require that ShareData.lua be loaded near the top of InGame.xml.
Perhaps a simpler alternative is to just disable the cache with setCacheState( 0 ), but this results in slower performance.
2.) There are two considerations regarding load order.
2a.) As long as SaveUtils is included near the top of each file-scope that uses it, then load order isn't necessarily a problem. SaveUtils itself isn't loaded, but rather embeds global functions into the file-scope, such as save() and load().
2b.) The shared cache is a load order issue and is explained somewhat in the documentation here:
Code:
Automatically shares cache and cache-state upon Events.LoadScreenClose().
Call share_SaveUtils() explicitly to share cache and cache-state immediately.
Explicit call necessary when shared data operations performed from global
scope or any point prior to Events.LoadScreenClose(). Avoid explicit call
whenever possible for greater interoperability of concurrent mods.
For maximum performance and to avoid potential desyncronization of data, if you are calling save() or load() prior to Events.LoadScreenClose(), such as within the global-scope of a modded built-in lua file, then you want to call share_SaveUtils() first (after the "include" line). However, doing so will require that ShareData.lua be loaded near the top of InGame.xml.
Perhaps a simpler alternative is to just disable the cache with setCacheState( 0 ), but this results in slower performance.