Jump to content

Using GetFormFromFile() with ESL flagged plugins


IWantMyMod

Recommended Posts

NOTE: edited this (completely change it) so it makes the point I was trying to make it the first place.

 

If your script saves FormIDs to later use with GetFormFromFile() you'll most likely need to update your script to accommodate ESL flagged plugins.

 

With normal plugins you would replace the first byte (8 bits) with 0 before saving it.

result = Math.LogicalAnd(formID, 0xFFFFFF)

With ESL flagged plugins you need to replace the first 20 bits with 0 or you'll end up with an FormID that will not work with GetFormFromFile().

result = Math.LogicalAnd(formID, 0xFFF)
Edited by IWantMyMod
Link to comment
Share on other sites

Back when the function came out, it was described as those first two digits not being used at all. Your example which shows a load order position as well as 00 working with ESP / ESM files indicates that that is indeed the behavior. However, standard practice has been to replace load order position with 00.

 

I suspect that when Bethesda added in the coding to handle ESL files, they followed standard practice while leaving ESP / ESM handling alone as it wasn't worth the effort to change them.

 

In all honesty, there is no "bug" here. Just a bit of confusion on how to use the function. Which is understandable as this is only briefly touched on as a short note within a single example on the CK wiki.

Link to comment
Share on other sites

Those tests make perfect sense and the function is working exactly as described on the CK Wiki page.

 

In your example you are using "FE002801" as the FormID for an item in the ESL file. The first two digits are completely unused (as demonstrated by your checks for the ESP file) but the other digits do matter and 2801 isn't a valid choice since ESL only supports values between 800 and FFF.

 

 

That 2801 is the constructed, in-game ID not the original FormID specified in the .ESL file itself. In the file, the ID would be encoded as one of "01000801", "02000801", etc. depending on how many masters the plugin has.

 

The expectation when using GetFormFromFile() is that you are writing your code by looking at the FormID value from the file itself not by manipulating the in-game IDs like you are doing in your test case.

Link to comment
Share on other sites

After rereading my post it was clear that the test script that I posted was not really showing what I was trying to say and the point I was trying to make was getting lost.

 

I complete rewrote the post so that it make my point clear (i hope).

 

However, I would like to point out that there was nothing in my original post that claimed that GetFormFromFile() was not working as expected or that there was a bug with GetFormFromFile(). In fact my test script was intended to showing that GetFormFromFile() was working exactly as expected.

Edited by IWantMyMod
Link to comment
Share on other sites

  • Recently Browsing   0 members

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