didisaan Posted March 16, 2018 Share Posted March 16, 2018 Hi I'm the author of the Item Distribution Framework mod. I have been trying to get INI/Text-file-handling to work, so that the users of the mod can exclude mods that they don't want processed by my mod, but have hade no luck.Anyone who is a master at this and willing to help? Link to comment Share on other sites More sharing options...
EPDGaffney Posted March 16, 2018 Share Posted March 16, 2018 I'm no master, but I do like a bit of puzzle-solving, so let's have a look. First, why don't you get really specific about what you're trying to do, what your current scripting attempt looks like, what function you were hoping to work, and all that? Link to comment Share on other sites More sharing options...
didisaan Posted March 16, 2018 Author Share Posted March 16, 2018 Nice. Well, the master script as it is now, goes through all the loaded mods. Then it reads all weapons/armors and distributes them through subscripts.What I want to do is: Whenever it loads in a new modfile, before it does anything else, it should first check the ini/txt-file if that mod is excluded and if it is, it should "restart" the loop and check the next modfile. If have messed around with GetINISectionNames, but can't get it working. Link to comment Share on other sites More sharing options...
EPDGaffney Posted March 16, 2018 Share Posted March 16, 2018 Could I see your script? Do you know where it's failing? Also, I've found that sometimes, when you do stuff like this, though most of the time people use a GameMode block with GetGameRestarted and this seems to have proliferated the practise, it doesn't always work. I've found that in such rare circumstances, MenuMode 4 works (I assume you're using JIP LN). My idea for this was to use this:https://geckwiki.com/index.php/ReadArrayFromFile Users would have to make a text file for it, but maybe we can get that other function working. I think seeing your whole script would be the best way for that, though. Link to comment Share on other sites More sharing options...
didisaan Posted March 16, 2018 Author Share Posted March 16, 2018 (edited) ScriptName aaaWeaponDistributionMainScript <lots of variables> Begin GameMode If (GetGameLoaded || GetGameRestarted) let iCount := 00 let iNumOfLoadedMods := GetNumLoadedMods while iCount < (iNumOfLoadedMods + 1) let sModName := GetNthModName iCount ; Checks for excluded mods if eval sModName == "FalloutNV.esm" let iCount += 1 Continue <lots of excluded mods> else ;Gets all weapons from the current modindex and adds them to the correct formid/leveled lists foreach AllWeapons <- (GetLoadedTypeArray 40 iCount) let rWeaponId := *AllWeapons let rRepairList := GetRepairList rWeaponId ; Gets the Repair List from the current weapon let sIconPath := GetIconPath rWeaponId ; Gets the icon path from the current weapon ; If a Repair List is found, call the corresponding script. if rRepairList == "Repair10mmPistol" call aaaRepair10mmPistolScript rWeaponId <lots more repair list checking action> endif loop Break endif loop let iCount += 1 endif StopQuest aaaWeaponDistributionMain EndThis is the script, with repeating code shortened down. Edited March 16, 2018 by didisaan Link to comment Share on other sites More sharing options...
EPDGaffney Posted March 17, 2018 Share Posted March 17, 2018 (edited) Great. So, where is this script failing and where are you trying to use the function that isn't working? I'd rather you just post the entire script as it appears in your mod file, especially with the indentations, as this is a little hard to read (not impossible or anything, but not as smooth as it could be). If you're concerned about length, just put the spoiler tag code round the code block code. As in, put the word spoiler in [brackets] before the code block starts, and then put the word spoiler in [brackets] after it as well, but with a stroke before spoiler, like so: [sp0iler] [c0de]This is some spoilery code, this is.[/c0de] [/sp0iler] This is not spoilery code. Edited March 17, 2018 by EPDGaffney Link to comment Share on other sites More sharing options...
didisaan Posted March 17, 2018 Author Share Posted March 17, 2018 Haha, managed to post the wrong version of the code... Sorry.Here's the correct code. ScriptName aaaWeaponDistributionMainScript array_var AllWeapons ref rWeaponId ref rRepairList int iNumOfLoadedMods int iCount string_var sModName string_var sIconPath Array_Var tempArrOuter String_var iniSection Begin GameMode If (GetGameLoaded || GetGameRestarted) let iCount := 00 let iNumOfLoadedMods := GetNumLoadedMods while iCount < (iNumOfLoadedMods + 1) let sModName := GetNthModName iCount ForEach tempArrOuter <- GetINISectionNames let iniSection := $tempArrOuter["value"] if eval sModName == iniSection print "not used " + iniSection Break else ;Gets all weapons from the current modindex and puts them in the correct formid/leveled lists print "used " + iniSection foreach AllWeapons <- (GetLoadedTypeArray 40 iCount) let rWeaponId := *AllWeapons let rRepairList := GetRepairList rWeaponId ; Gets the Repair List from the current weapon let sIconPath := GetIconPath rWeaponId ; Gets the icon path from the current weapon ; If a Repair List is found, call the corresponding script. Reveal hidden contents if rRepairList == "Repair10mmPistol" call aaaRepair10mmPistolScript rWeaponId elseif rRepairList == "Repair10mmSubmachineGun" call aaaRepair10mmSubmachineGunScript rWeaponId elseif rRepairList == "Repair127mmSubmachineGun" call aaaRepair127mmSubmachineGunScript rWeaponId elseif rRepairList == "Repair9Iron" call aaaRepair9IronScript rWeaponId elseif rRepairList == "RepairBaseballBat" call aaaRepairBaseballBatScript rWeaponId elseif rRepairList == "RepairBBGun" call aaaRepairBBGunScript rWeaponId elseif rRepairList == "RepairCattleProd" call aaaRepairCattleProdScript rWeaponId elseif rRepairList == "RepairFlamer" call aaaRepairFlamerScript rWeaponId elseif rRepairList == "RepairGaussRifle" call aaaRepairGaussRifleScript rWeaponId elseif rRepairList == "RepairHuntingRifle" call aaaRepairHuntingRifleScript rWeaponId elseif rRepairList == "RepairKnife" call aaaRepairKnifeScript rWeaponId elseif rRepairList == "RepairKnifeCombat" call aaaRepairKnifeCombatScript rWeaponId elseif rRepairList == "RepairLaserPistol" call aaaRepairLaserPistolScript rWeaponId elseif rRepairList == "RepairLaserRifle" call aaaRepairLaserRifleScript rWeaponId elseif rRepairList == "RepairMinigun" call aaaRepairMinigunScript rWeaponId elseif rRepairList == "RepairMinigunForRealzImSeriousGuys" call aaaRepairMinigunScript rWeaponId elseif rRepairList == "RepairMissileLauncher" call aaaRepairMissileLauncherScript rWeaponId elseif rRepairList == "RepairNailBoard" call aaaRepairNailBoardScript rWeaponId elseif rRepairList == "RepairNV127mmPistol" call aaaRepairNV127mmPistolScript rWeaponId elseif rRepairList == "RepairNV357Revolver" call aaaRepairNV357RevolverScript rWeaponId elseif rRepairList == "RepairNV44Magnum" call aaaRepairNV44MagnumScript rWeaponId elseif rRepairList == "RepairNV9mmPistol" call aaaRepairNV9mmPistolScript rWeaponId elseif rRepairList == "RepairNV9mmSMG" call aaaRepairNV9mmSMGScript rWeaponId elseif rRepairList == "RepairNVAntiMaterielRifle" call aaaRepairNVAntiMaterielRifleScript rWeaponId elseif rRepairList == "RepairNVAssaultCarbine" call aaaRepairNVAssaultCarbineScript rWeaponId elseif rRepairList == "RepairNVBrushGun" call aaaRepairNVBrushGunScript rWeaponId elseif rRepairList == "RepairNVBumperSword" call aaaRepairNVBumperSwordScript rWeaponId elseif rRepairList == "RepairNVCaravanShotgun" call aaaRepairNVCaravanShotgunScript rWeaponId elseif rRepairList == "RepairNVChainsaw" call aaaRepairNVChainsawScript rWeaponId elseif rRepairList == "RepairNVCowboyRepeater" call aaaRepairNVCowboyRepeaterScript rWeaponId elseif rRepairList == "RepairNVDLC04SMMG" call aaaRepairNVDLC04SMMGScript rWeaponId elseif rRepairList == "RepairNVFireaxe" call aaaRepairNVFireaxeScript rWeaponId elseif rRepairList == "RepairNVGrenadeLauncher" call aaaRepairNVGrenadeLauncherScript rWeaponId elseif rRepairList == "RepairNVGrenadeMachineGun" call aaaRepairNVGrenadeMachineGunScript rWeaponId elseif rRepairList == "RepairNVGrenadeRifle" call aaaRepairNVGrenadeRifleScript rWeaponId elseif rRepairList == "RepairNVHatchet" call aaaRepairNVHatchetScript rWeaponId elseif rRepairList == "RepairNVHuntingRevolver" call aaaRepairNVHuntingRevolverScript rWeaponId elseif rRepairList == "RepairNVHuntingShotgun" call aaaRepairNVHuntingShotgunScript rWeaponId elseif rRepairList == "RepairNVLaserRCW" call aaaRepairNVLaserRCWScript rWeaponId elseif rRepairList == "RepairNVLeverActionShotgun" call aaaRepairNVLeverActionShotgunScript rWeaponId elseif rRepairList == "RepairNVLightMachineGun" call aaaRepairNVLightMachineGunScript rWeaponId elseif rRepairList == "RepairNVMachete" call aaaRepairNVMacheteScript rWeaponId elseif rRepairList == "RepairNVMantisGauntlet" call aaaRepairNVMantisGauntletScript rWeaponId elseif rRepairList == "RepairNVMarksmanCarbine" call aaaRepairNVMarksmanCarbineScript rWeaponId elseif rRepairList == "RepairNVMultiPlasRifle" call aaaRepairNVMultiPlasRifleScript rWeaponId elseif rRepairList == "RepairNVServiceRifle" call aaaRepairNVServiceRifleScript rWeaponId elseif rRepairList == "RepairNVSilenced22Pistol" call aaaRepairNVSilenced22PistolScript rWeaponId elseif rRepairList == "RepairNVSilenced22SMG" call aaaRepairNVSilenced22SMGScript rWeaponId elseif rRepairList == "RepairNVSingleShotgun" call aaaRepairNVSingleShotgunScript rWeaponId elseif rRepairList == "RepairNVThermicLance" call aaaRepairNVThermicLanceScript rWeaponId elseif rRepairList == "RepairNVTrailCarbine" call aaaRepairNVTrailCarbineScript rWeaponId elseif rRepairList == "RepairNVTribeamLaserRifle" call aaaRepairNVTribeamLaserRifleScript rWeaponId elseif rRepairList == "RepairPlasmaCaster" call aaaRepairPlasmaCasterScript rWeaponId elseif rRepairList == "RepairPlasmaPistol" call aaaRepairPlasmaPistolScript rWeaponId elseif rRepairList == "RepairPlasmaRifle" call aaaRepairPlasmaRifleScript rWeaponId elseif rRepairList == "RepairPoliceBaton" call aaaRepairPoliceBatonScript rWeaponId elseif rRepairList == "RepairPoolCue" call aaaRepairPoolCueScript rWeaponId elseif rRepairList == "RepairPowerFist" call aaaRepairPowerFistScript rWeaponId elseif rRepairList == "RepairRipper" call aaaRepairRipperScript rWeaponId elseif rRepairList == "RepairSledgeHammer" call aaaRepairSledgeHammerScript rWeaponId elseif rRepairList == "RepairSawedOffShotgun" call aaaRepairSawedOffShotgunScript rWeaponId elseif rRepairList == "RepairShishkebab" call aaaRepairShishkebabScript rWeaponId elseif rRepairList == "RepairSniperRifle" call aaaRepairSniperRifleScript rWeaponId elseif rRepairList == "RepairSuperSledge" call aaaRepairSuperSledgeScript rWeaponId elseif rRepairList == "RepairSwitchblade" call aaaRepairSwitchbladeScript rWeaponId elseif rRepairList == "RepairTeslaCannon" call aaaRepairTeslaCannonScript rWeaponId elseif rRepairList == "RepairThrowingHatchet" call aaaRepairThrowingHatchetScript rWeaponId elseif rRepairList == "RepairThrowingKnife" call aaaRepairThrowingKnifeScript rWeaponId elseif rRepairList == "RepairThrowingSpear" call aaaRepairThrowingSpearScript rWeaponId elseif rRepairList == "RepairVarmintRifle" call aaaRepairVarmintRifleScript rWeaponId elseif rRepairList == "NVDLC01RepairAutomaticRifle" call aaaNVDLC01RepairAutomaticRifleScript rWeaponId elseif rRepairList == "NVDLC01RepairHolorifle" call aaaNVDLC01RepairHolorifleScript rWeaponId elseif rRepairList == "NVDLC02Repair45AutoPistol" call aaaNVDLC02Repair45AutoPistolScript rWeaponId elseif rRepairList == "NVDLC03RepairLAERLIST" call aaaNVDLC03RepairLAERLISTScript rWeaponId elseif rRepairList == "NVDLC05RepairKatana" call aaaNVDLC05RepairKatanaScript rWeaponId elseif rRepairList == "RepairAlienBlaster" call aaaRepairAlienBlasterScript rWeaponId elseif rRepairList == "RepairBallisticFist" call aaaRepairBallisticFistScript rWeaponId elseif rRepairList == "RepairBladedGauntlet" call aaaRepairBladedGauntletScript rWeaponId elseif rRepairList == "RepairBoxingGloves" call aaaRepairBoxingGlovesScript rWeaponId elseif rRepairList == "RepairBoxingTape" call aaaRepairBoxingTapeScript rWeaponId elseif rRepairList == "RepairBrassKnuckles" call aaaRepairBrassKnucklesScript rWeaponId elseif rRepairList == "RepairDisplacerGlove" call aaaRepairDisplacerGloveScript rWeaponId elseif rRepairList == "RepairFatMan" call aaaRepairFatManScript rWeaponId elseif rRepairList == "RepairGatlingLaser" call aaaRepairGatlingLaserScript rWeaponId elseif rRepairList == "RepairIncinerator" call aaaRepairIncineratorScript rWeaponId elseif rRepairList == "RepairLeadPipe" call aaaRepairLeadPipeScript rWeaponId elseif rRepairList == "RepairNVCleaver" call aaaRepairNVCleaverScript rWeaponId elseif rRepairList == "RepairNVDLC04ArcWelder" call aaaRepairNVDLC04ArcWelderScript rWeaponId elseif rRepairList == "RepairNVDLC04FlareGun" call aaaRepairNVDLC04FlareGunScript rWeaponId elseif rRepairList == "RepairNVDLC04NailGun" call aaaRepairNVDLC04NailGunScript rWeaponId elseif rRepairList == "RepairNVRebarClub" call aaaRepairNVRebarClubScript rWeaponId elseif rRepairList == "RepairNVRechargerPistol" call aaaRepairNVRechargerPistolScript rWeaponId elseif rRepairList == "RepairNVStraightRazor" call aaaRepairNVStraightRazorScript rWeaponId elseif rRepairList == "RepairRollingPin" call aaaRepairRollingPinScript rWeaponId elseif rRepairList == "RepairShovel" call aaaRepairShovelScript rWeaponId elseif rRepairList == "RepairTireIron" call aaaRepairTireIronScript rWeaponId elseif rRepairList == "RepairZapGlove" call aaaRepairZapGloveScript rWeaponId elseif rRepairList == "NVDLC01RepairBearTrapFist" call aaaNVDLC01RepairBearTrapFistScript rWeaponId elseif rRepairList == "NVDLC01RepairCosmicKnife" call aaaNVDLC01RepairCosmicKnifeScript rWeaponId elseif rRepairList == "NVDLC01RepairKnifeSpear" call aaaNVDLC01RepairKnifeSpearScript rWeaponId elseif rRepairList == "NVDLC01RepairPolicePistol" call aaaNVDLC01RepairPolicePistolScript rWeaponId elseif rRepairList == "NVDLC02Repair45AutoSubmachineGun" call aaaNVDLC02Repair45AutoSubmachineGunScript rWeaponId elseif rRepairList == "NVDLC02RepairWarClub" call aaaNVDLC02RepairWarClubScript rWeaponId elseif rRepairList == "NVDLC02RepairYaoGuaiGauntlet" call aaaNVDLC02RepairYaoGuaiGauntletScript rWeaponId elseif rRepairList == "NVDLC03RepairProtonAxeLIST" call aaaNVDLC03RepairProtonAxeLISTScript rWeaponId elseif rRepairList == "NVDLC05RepairPlasmaDefenderCustom" call aaaNVDLC05RepairPlasmaDefenderCustomScript rWeaponId elseif eval sIconPath == "Interface\Icons\PipboyImages\Weapons\weapons_mine.dds" call aaaFragMine rWeaponId elseif eval sIconPath == "Interface\Icons\PipboyImages\Weapons\weapons_plasma_mine.dds" call aaaPlasmaMine rWeaponId elseif eval sIconPath == "Interface\Icons\PipboyImages\Weapons\weapons_pulse_mine.dds" call aaaPulseMine rWeaponId elseif eval sIconPath == "Interface\Icons\PipboyImages\Weapons\weapons_bottlecap_mine.dds" call aaaBottlecapMine rWeaponId elseif eval sIconPath == "NVDLC04\Interface\icons\NVDLC04weapon_satchel_charge.dds" call aaaSatchelCharge rWeaponId elseif eval sIconPath == "interface\icons\pipboyimages\weapons\weapons_time_bomb.dds" call aaatimebomb rWeaponId elseif eval sIconPath == "interface\icons\pipboyimages\weapons\weapons_C4.dds" call aaaC4 rWeaponId elseif eval sIconPath == "NVDLC01\interface\icons\NVDLC01weapon_gas_bomb.dds" call aaagasbomb rWeaponId elseif eval sIconPath == "interface\icons\pipboyimages\weapons\weapons_powder_charge.dds" call aaaPowderCharge rWeaponId elseif eval sIconPath == "Interface\Icons\PipboyImages\Weapons\weapons_frag_grenade.dds" call aaaFragGrenade rWeaponId elseif eval sIconPath == "interface\icons\pipboyimages\weapons\weapons_incendiary_grenade.dds" call aaaIncendiaryGrenade rWeaponId elseif eval sIconPath == "interface\icons\pipboyimages\weapons\weapons_dynamite.dds" call aaaDynamite rWeaponId elseif eval sIconPath == "Interface\Icons\PipboyImages\Weapons\weapons_plasma_grenade.dds" call aaaPlasmaGrenade rWeaponId elseif eval sIconPath == "Interface\Icons\PipboyImages\Weapons\weapons_pulse_grenade.dds" call aaaPulseGrenade rWeaponId elseif eval sIconPath == "NVDLC02\interface\icons\NVDLC02weapons_fire_bomb.dds" call aaaFireBomb rWeaponId else call aaaWeaponsGeneric rWeaponId Continue ;Not currently in use. ;elseif eval sIconPath == "NVDLC05\interface\icons\NVDLC05weapons_fat_mine.dds" ;elseif eval sIconPath == "interface\icons\pipboyimages\weapons\weapons_stun_grenade.dds" ;elseif eval sIconPath == "NVDLC05\interface\icons\NVDLC05weapons_mfc_grenade.dds" ;elseif eval sIconPath == "interface\icons\pipboyimages\weapons\weapons_nuka_grenade.dds" ;RepairBinoculars ;RepairChineseAssaultRifle ;RepairChineseOfficerSword ;RepairChinesePistol ;RepairDartGun ;RepairMesmetron ;RepairNVDogTagFist ;RepairNVDoubleBarrelShotgun ;RepairNVDressCane ;RepairNVGPMachineGun ;RepairNVHeavyRiveter ;RepairRailwayRifle ;RepairRockItLauncher ;NVDLC03RepairCyberdogGun ;NVDLC03X13FieldGunRepairListendif loop Break endif loop let iCount += 1 loop endif StopQuest aaaWeaponDistributionMain End It seems to work at first, but then it stops checking the file. Link to comment Share on other sites More sharing options...
EPDGaffney Posted March 17, 2018 Share Posted March 17, 2018 Ah that makes sense. So, as I've said, I'm no expert, but I've done things similar to this before and currently find success with them the most rewarding things to script, probably because the results are so far-reaching and because they take a lot of logic to put together. What I'm saying is, this is my first thought, but it's possible I've missed something simple: Are you not using break where you'd want to use continue ? Also, I have to think it was unnecessary to look at every single repair list individually. I'd need to have a think on how to do it properly, but I'm sceptical on that one. Link to comment Share on other sites More sharing options...
DoctaSax Posted March 17, 2018 Share Posted March 17, 2018 (edited) If there's another way of distinguishing the different weapons than repair lists, eg by icon or mesh path, you could skip all those elseifs by parking all the UDFs in a stringmap, with the paths as key, and simply call them straight through the stringmap:call MyStringmap[$svPath] rWeaponIDThat's one line instead of dozens of elseif checks, which in a loop really makes a difference. On second thought, you might do the same based off a repair list, if you convert it to a string using RefToString.if IsFormValid rRepairList let svKey := RefToString rRepairList else let svKey := GetIconPath rWeaponID endif call MyStringMap[$svKey] rWeaponID Edited March 17, 2018 by DoctaSax Link to comment Share on other sites More sharing options...
didisaan Posted March 18, 2018 Author Share Posted March 18, 2018 I got some inspiration from your comments and I will test some new code later today. :) Link to comment Share on other sites More sharing options...
Recommended Posts