didisaan Posted August 19, 2018 Share Posted August 19, 2018 Hi I have a mod that cycles through all loaded mod-files and I want to be able to skip certain mod-files that have been added to an ini-file or something similar. Anyone has any tips? Link to comment Share on other sites More sharing options...
dubiousintent Posted August 20, 2018 Share Posted August 20, 2018 You are going to need to use the "Lutana functions" from the "JIP LN NVSE plugin" to get the INI file and it's contents.* File Functions* GetINISection* GetINIString just for starters. Load those "exclusion filename" strings into an array, and then check against the array as you loop through the mod-files. You could remove entries from the array as you find a match, which will gradually reduce the array to zero entries, telling you there is no longer a need to check. -Dubious- Link to comment Share on other sites More sharing options...
didisaan Posted August 20, 2018 Author Share Posted August 20, 2018 I'll do some tests. Thanks! Link to comment Share on other sites More sharing options...
didisaan Posted August 20, 2018 Author Share Posted August 20, 2018 ScriptName test array_var aExcludedMods string_var sModName int iNumOfLoadedMods int iCount Begin MenuMode 4 If (GetGameLoaded || GetGameRestarted) let aExcludedMods := GetINISectionNames let iNumOfLoadedMods := GetNumLoadedMods let iCount := 00 while iCount < (iNumOfLoadedMods + 1) let sModName := GetNthModName iCount if eval (Ar_Find $sModName, aExcludedMods) != Ar_BadNumericIndex let iCount += 1 print "not used " + $sModName Continue else print "used " + $sModName let iCount += 1 endif loop endif EndThis should work, right? It seems to be working. Link to comment Share on other sites More sharing options...
dubiousintent Posted August 21, 2018 Share Posted August 21, 2018 That appears to cover the basics. But you only need to use one "let iCount += 1" statement, placed below the "endif" and before the "loop". You are incrementing the loop counter regardless of which result of the conditional you take. And you don't need the "Continue" unless some lower code is going to cause a "break" in the loop that you need to "skip over". Also, develop the habit of indenting to improve readability; taking care to line up "blocks" like "IF/EndIf", "While/Loop", etc.. Not a big issue with this small script but important with more complex ones: For example: Begin MenuMode 4 If (GetGameLoaded || GetGameRestarted) let aExcludedMods := GetINISectionNames let iNumOfLoadedMods := GetNumLoadedMods let iCount := 00 while iCount < (iNumOfLoadedMods + 1) let sModName := GetNthModName iCount if eval (Ar_Find $sModName, aExcludedMods) != Ar_BadNumericIndex print "not used " + $sModName else print "used " + $sModName endif let iCount += 1 loop endif Most "tabs" indent 4 spaces by default, but 2 should be your minimum. -Dubious- Link to comment Share on other sites More sharing options...
didisaan Posted August 21, 2018 Author Share Posted August 21, 2018 I'll change the code according to your recommendations and do some more test later today. I always indent my code, but when i pasted the text, it was removed and well, I'm lazy sometimes ;) Thanks That appears to cover the basics. But you only need to use one "let iCount += 1" statement, placed below the "endif" and before the "loop". You are incrementing the loop counter regardless of which result of the conditional you take. And you don't need the "Continue" unless some lower code is going to cause a "break" in the loop that you need to "skip over". Also, develop the habit of indenting to improve readability; taking care to line up "blocks" like "IF/EndIf", "While/Loop", etc.. Not a big issue with this small script but important with more complex ones: For example: Begin MenuMode 4 If (GetGameLoaded || GetGameRestarted) let aExcludedMods := GetINISectionNames let iNumOfLoadedMods := GetNumLoadedMods let iCount := 00 while iCount < (iNumOfLoadedMods + 1) let sModName := GetNthModName iCount if eval (Ar_Find $sModName, aExcludedMods) != Ar_BadNumericIndex print "not used " + $sModName else print "used " + $sModName endif let iCount += 1 loop endif Most "tabs" indent 4 spaces by default, but 2 should be your minimum. -Dubious- Link to comment Share on other sites More sharing options...
dubiousintent Posted August 22, 2018 Share Posted August 22, 2018 No problem. You just need to paste into "code tags" to preserve your indentations. See the "How to markup images (etc) in forum posts and comments" article. -Dubious- Link to comment Share on other sites More sharing options...
Recommended Posts