-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Since runs in Hades and Hades 2 do not have a unique ID associated with them (and we decide to not use position in run history because it is often tampered with) you cannot store data against a historical run via ModData, and therefore must add your own field to the run's table, which may cause complications if many mods try to do this at the same time.
Since ModUtil is quite generalised, it should not automatically do this (a 'run' is very game logic specific), but it could provide a 'ModData injector' function that a mod that wants to store ModData on a table can run and returns a proxy to a namespaced table in that injected ModData field.
Technically, this can already be done:
(where thing is a table to inject into, e.g. a local reference to a 'run' table)
(Hades 2 / hell2modding style, so the environment likely has _PLUGIN.guid)
local thing_ModData = thing.ModData or {}
thing.ModData = thing_ModData
local my_thing_ModData = thing_ModData[_PLUGIN.guid] or {}
thing_ModData[_PLUGIN.guid] = my_thing_ModData
local my_thing_Data = modutil.mod.Entangled.ModData(my_thing_Data)
-- my_thing_Data is now a proxy like mod.Data(Hades 1 / modimporter style, which likely has local mod = ModUtil.Mod.Register("ModName"))
local thingModData = thing.ModData or { }
thing.ModData = thingModData
local modName = ModUtil.Mods.Inverse[ mod ]
local myThingModData = thingModData[ modName ] or { }
thingModData[ modName ] = myThingModData
local myThingData = ModUtil.Entangled.ModData( myThingData )
-- myThingData is now a proxy like mod.Data