IsharaMeradin Posted August 5, 2016 Share Posted August 5, 2016 I've been using this in my own mods for a while now. But I've been wondering about something.Here is the example code block Chesko posted on the Legacy of the Dragonborn mod page last year (where I think I'd gotten the code idea from). bool function IsPluginLoaded(int iFormID, string sPluginName) int i = Game.GetModByName(sPluginName) if i != 255 debug.trace("[YourModNameHere] Loaded: " + sPluginName) return true else return false endif endFunction The question is: Why use the "int iFormID"? That variable is not used at all in the function. I would think that it should be safe to drop the "int iFormID" from the function completely and it still behave as intended. Thoughts? Link to comment Share on other sites More sharing options...
FrankFamily Posted August 5, 2016 Share Posted August 5, 2016 I'd say its a leftover from a GetFormFromFile check, so safe to remove.Maybe it was left there to avoid having to recompile other scripts calling it? It doesn't do any harm by just being there anyway Why not do: if (Game.GetModByName(sPluginName)) != 255directly? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted August 5, 2016 Author Share Posted August 5, 2016 Probably, could do it directly now that you mention it. (provided I can do it without breaking the current script :P ) The reason it is "harming" by being there is that its annoying to have to pass a value in. When I originally used it, I hadn't paid attention and thought it was required and I took the effort to locate a valid ID number and convert it properly into an int. Tedious and unnecessary work if you ask me. Link to comment Share on other sites More sharing options...
cdcooley Posted August 5, 2016 Share Posted August 5, 2016 Just use the GetModByName test directly. The first version of the IsPluginLoaded() function was implemented with the game's own GetFormFromFile() but when SKSE added the GetModMyName function IsPluginLoaded was changed to use that. General programming "best practices" guidelines dictate you should never change function parameters after they've been used so now there's a pointless first parameter for that function. Chesko loves to follow "best practices" when programming but best practice for scripting is to avoid those sorts of helper functions unless they really give you some significant benefit. In this case the only remaining "benefit" of IsPluginLoaded() is the ability to generate log spam messages when plugins are found. Link to comment Share on other sites More sharing options...
Recommended Posts