Jump to content

​[SOLUTION] GetFileFromForm() - A complementary function to GetFormFromFile()


Recommended Posts

This is sort of the reverse of GetFormFromFile().
Gives back the plugin filename a reference comes from, or "RUNTIME" if it was created at runtime:

String Function GetFileFromForm(ObjectReference queryForm)
    int formId = queryForm.GetFormID()
    int msByte = Math.RightShift(formId, 24)
    if (msByte == 0xff)
        ; runtime form
        return "RUNTIME"
    endif
    Game:PluginInfo[] pluginsList
    int pluginIndex = 0
    if (msByte == 0xfe)
        ; light plugin
        pluginsList = Game.GetInstalledLightPlugins()
        pluginIndex = Math.LeftShift(formId, 8)
        pluginIndex = Math.RightShift(pluginIndex, 20)
    else
        ; regular plugin
        pluginsList = Game.GetInstalledPlugins()
        pluginIndex = msByte
    endIf
    return pluginsList[pluginIndex].name
EndFunction

In case anyone else needs it.
Requires F4SE.
 

  • Like 3
Link to comment
Share on other sites

Yes, I found that - thanks. It's a huge improvement.

The Oblivion versions are a little less intrusive as they don't require the console. Mind you Oblivion has console debugging so it might have more information readily available.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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