Stop sucking at GetFormFromFile()
Today's rant brought to you by mods like Auto Unequip Ammo and 80% of the other mods out there.
Dynamic support is great. Do you have devious devices? No? Ok, I'll disable devious device features. This is brilliant.
What is not brilliant is this:
[04/06/2015 - 12:53:43PM] ========== Auto Unequip Ammo: Scanning for supported plugins...
[04/06/2015 - 12:53:43PM] ========== ERRORS RELATED TO MISSING FILES SHOULD BE IGNORED!
[04/06/2015 - 12:53:43PM] ERROR: File "XFLMain.esm" does not exist or is not currently loaded.
stack:
<unknown self>.Game.GetFormFromFile() - "<native>" Line ?
[AUA (1C00C6C2)].AUAQuestScript.GameLoaded() - "AUAQuestScript.psc" Line 40
[AUA (1C00C6C2)].AUAQuestScript.OnUpdate() - "AUAQuestScript.psc" Line 73
How about instead of printing an error about ignoring errors, about how you just not fucking throw any errors to start with? If you honestly don't know how, then, please take note. Make the function Game.GetModByName() your best goddamn friend in the universe.
If you are a programmer outside of Skyrim, especially if you are like a programmer for money... I sure hope you aren't being as bad in that code either. If so you should feel terrible about charging money for failing code. If you are new to coding and Skyrim, then take heed now to prevent starting any retarded habits.
If(Game.GetModByName("MyOptionalMod.esp") != 255) MyForm = Game.GetFormFromFile(0x1234,"MyOptionalMod.esp")EndIf
Wrapping your GetFormFromFile() with a test that your file actually exists (GetModByName()) means that when it does not exist you can do two things: avoid having the game throw excess errors in the log, and then handle the failure gracefully.
From the CK Wiki:
Calling this function on a non-existent plugin will not result in any log output, and so it may be used strategically before calling something like GetFormFromFile() to avoid creating log errors. (Or in place of GetFormFromFile entirely, if you only want to check if the plugin is present).
3 Comments
Recommended Comments