Hi, I'm the author of !skins (skins-factored), and I'm trying to use the 'register_characters' remote interface to add skins that my library creates. However, there's two separate bugs with how the interface adds the characters.
Note: this post is quite long and detailed because I want to include as much information as is helpful to try and fix the issue. I also have a 13 MB log file with minime debug output enabled if you want to see that (I kept track of the noteworthy stuff in it so you don't have to sift through all the debug output, there's a lot!)
Bug #1:
Adding a character in script.on_load fails to do anything because minime's on_configuration_changed resets the global.minime_characters
table, removing the entry the remote interface just created.
Here's a "stack trace" of what happens:
- the global.minime_characters
table is reset at scripts/character.lua:728 in minime_character.make_character_list()
- which is called in minime_character.update_character_list()
: scripts/character.lua:860
- which is called in init()
: control.lua:210
- which is called in script.on_configuration_changed
: control.lua:330
- on_configuration_changed runs after skins-factored loads and calls the remote interface in it's script.on_load handler
Unfortunately, skins-factored cannot depend on minime to make minime load before it, as that would cause a circular dependency (skin mod -> !skins -> minime -> skin mod).
A fix for this that I can think of would be to keep track of which characters are added by the remote interface, and re-add them in make_character_list() after adding the characters found by pattern searching and from "CharSelect", at around line 830 in character.lua. This would require passing the old list to make_character_list() and having it check each skin for a flag like "from_remote_interface" or something like that.
Bug #2:
Adding a character during runtime doesn't seem to create the data in global.minime_character_properties
, causing issues when minime expects that data to exist (such as when Jetpack raises the on_character_swapped event).
The remote interface calls minime_character.set_character_data() to add the character to global.minime_characters
, but entries are only added to global.minime_character_properties
by minime_character.make_character_list() in scripts/character.lua:836, which only runs during init().
I think a fix for this would be to also run global.minime_character_properties = get_minime_character_properties()
when interface_functions.register_characters() is called.
For reference, the code I'm running to call the interface looks like this:
if script.active_mods["minime"] then
local skin_prototypes = {}
for _, skin in ipairs(Common.available_skins) do
table.insert(skin_prototypes, Common.skin_to_prototype(skin))
end
log("minime compat: " .. serpent.line(skin_prototypes))
remote.call("minime", "register_characters", skin_prototypes)
log("called")
end
skin_prototypes
is just a list of the prototypes of each character skin my mod has generated (example: {"character", "character-gear-girl"}
(yes character shouldn't be in there but minime just ignores it))
If there's any other information that I can provide that would be helpful for figuring this out, I'd be glad to provide it! minime is a really impressive mod, and it's clear you've put a lot of effort into it :)