Jump to content

[help] Excluding mod-files with INI-file


didisaan

Recommended Posts

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

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


End

This should work, right? It seems to be working.

Link to comment
Share on other sites

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

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...