PajaKulebrc Posted May 7, 2015 Share Posted May 7, 2015 Hello fellow modders, I have a question regarding mod compatibility issues... Iam quite new to this and I have creating a couple of basic mods for myself that work just fine. But before I do anything bigger and start sharing it with other, I want to make sure, that my mod wont cause any issues, crashes and that its compatible with other mods... Ive been trying to add functionality to a character on a general level... Iam using following code:function characterpostinit(inst)"here is my code that gives character some additional stuff"endfor _,charactername in ipairs(CHARACTERLIST) doAddPrefabPostInit(charactername, characterpostinit)endIt works fine with all the regular character that are in the game. But it doesnt seem to work with any custom characters from other mods... Iam not very familiar with character modding ( didnt get that far in my career yet ), so I dont know how they work and why theyre not in the CHARACTERLIST. Can anyone give me advice? Also a similar issue - When Iam making a mod that changes some prefabs ( weapons, structures etc. ) and I want it to be compatible with other mods - can I somehow check if a prefab of given name exists and if so, then change it as well? For instance if another modder makes a Katana Sword prefab... Can I somehow check if that mod was loaded and the katana prefab is there, and if the check returns true, then run some kind of prefabpostinit and change the katana as well? Lastly - is there any specific order the mods load in the game? Is there some kind of priority as to how theyre loaded? Because even if I add the prefab exist check ( in the katana example ) and my mod loads into the game before the mod with the katana, then my mod wouldnt see the katana yet and wont change it... Can I somehow force my mod to load last? Or perhaps check if other mod exists ( the one I want to be compatible with ) and force it to load before mine? Any info on this will help me tremendously.... Link to comment Share on other sites More sharing options...
Mobbstar Posted May 7, 2015 Share Posted May 7, 2015 There is indeed a mod priority system. If you add the field "priority" to your modmain.lua, you can control the load order (default is 0). You can find the exact function in data/scripts/mods.lua, function "LoadMods". EDIT: A lower priority means your mod loads later. As such, if you want to modify another mod, it's better to have a negative priority. If your mod allows for other mods to plug-in, you may want to raise the priority. Link to comment Share on other sites More sharing options...
PajaKulebrc Posted May 7, 2015 Author Share Posted May 7, 2015 Ok, so if I want other mods to load first then I just put priority = 1 into my modinfo.lua, right? All other mods will have priority 0 ( default ), so when my mod is loading, all the other will be already loaded... Link to comment Share on other sites More sharing options...
Mobbstar Posted May 7, 2015 Share Posted May 7, 2015 Ok, so if I want other mods to load first then I just put priority = 1 into my modinfo.lua, right? All other mods will have priority 0 ( default ), so when my mod is loading, all the other will be already loaded... No it's the other way around, the highest priority is loaded first, a negative priority assures your mod is loaded last (unless another mod does so too with an even lower number, of course). If you're the visual kind, here's what the list would look like: 3 : "Super HUD Base mod feat. Plugin System"1 : "Tweaking some core stuff, idk"0 : "Some tiny mod"0 : "Another negligible mod"0 : "Foo"-5 : "This mod overrides EVERYTHING muhaha" Link to comment Share on other sites More sharing options...
Blueberrys Posted May 7, 2015 Share Posted May 7, 2015 But it doesnt seem to work with any custom characters from other mods Use this instead to affect any/every player:function PlayerPostInit(player) -- ...endAddSimPostInit(PlayerPostInit)- Can I somehow check if that mod was loaded To see if another mod has loaded:KnownModIndex = GLOBAL.KnownModIndexif (KnownModIndex:IsModEnabled("mods_folder_name")) then -- ...endChanging custom prefabs is the same as with any prefab. Use AddPrefabPostInit with the corresponding prefab name. Link to comment Share on other sites More sharing options...
Mobbstar Posted May 7, 2015 Share Posted May 7, 2015 To see if another mod has loaded:KnownModIndex = GLOBAL.KnownModIndexif (KnownModIndex:IsModEnabled("mods_folder_name")) then -- ...end I should add that the mods folder name changes when downloaded via Steam Workshop, so it's tricky to check that way. A vague way to test for mods I use is "PrefabExists". Vague because other mods might also add a prefab called that, which doesn't do what you expect it to do. I think it's possible to manually go through the loaded mods table, I'm not sure Link to comment Share on other sites More sharing options...
Blueberrys Posted May 7, 2015 Share Posted May 7, 2015 To check with fancy names instead of folder names.KnownModIndex = GLOBAL.KnownModIndexfancy_folder_names = {}for _, mod_folder_name in pairs(KnownModIndex:GetModNames()) do mod_fancy_name = KnownModIndex:GetModFancyName(mod_folder_name) fancy_folder_names[mod_fancy_name] = mod_folder_nameendlocal function IsModEnabled_Fancy(mod_fancy_name) mod_folder_name = fancy_folder_names[mod_fancy_name] if mod_folder_name then return KnownModIndex:IsModEnabled(mod_folder_name) else return false endend--if IsModEnabled_Fancy("mod_fancy_name") then -- ...end Anyone who comes across this, feel free to use it however you like. Edit: Fixed table creation. Edit2: Fixed "then".. whoops. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.