Jump to content

[Papyrus] GetLightModName how?


Recommended Posts

Posted

So.... I am saving IDs + ModNames into a JSON to later be able to recover the item across game profiles via "GetFormFromFile".

 

Now I discovered that Skyrim SE uses ESLs and they cannot be detected by this script:

 

            TempId       = TempShield.GetFormID()
            iFormId      = Math.RightShift(Math.LeftShift(TempId,8),8)
            iModIndex    = Math.RightShift(TempId, 24)                     
            sFileName    = Game.GetModName(iModIndex) 
            SetINTValue("../Naked Defeat/weapon" +weaponNum+ ".json", "ID_Shield", iFormId as int)    
            SetStringValue("../Naked Defeat/weapon" +weaponNum+ ".json", "STRING_Shield", sFileName)
            SetINTValue("../Naked Defeat/weapon" +weaponNum+ ".json", "IsShield", 1 as int)

 

 

Game.GetModName(iModIndex)  does not work on ESLs.

 

I found GetLightModName function but I dont see how this can do the same job?

Meaning how can I still put the ID and the ESL together? 

 

From what I understand the iModIndex in my script will fail to return the correct Index for the ESL since all ESL have the same? 

 iModIndex    = Math.RightShift(TempId, 24)

int Numberoflightmods
String Nameofmod
String NameofAuth
String Description

Function PrintModlist()
	Numberoflightmods = Game.GetLightModCount() ;The number of active mods.
	while NumberofMods
		Numberoflightmods -= 1
		Nameofmod = Game.GetLightModName(NumberofMods) ;Gets Name of Mod eg. Skyrim.esm, Update.esm, Hearthfire.esm, etc.
		NameofAuth = Game.GetLightModAuthor(NumberofMods) ; If a Author is specified then it will return a name if not will be blank
		Description = Game.GetLightModDescription(NumberofMods) ;If a Description is available then it will be shown otherwise will be blank
		Debug.Trace(NumberofMods + "th index contains " + NameofMod)
		Debug.Trace("Author: " + NameofAuth)
		Debug.Trace("Description: " + Description)
	EndWhile
EndFunction
Posted

ESLs will all be ID=x'FE', and they differ in the next byte. 

Left/right shifts will extract that byte, and the formid part will only be two bytes long. 

You will need an IF to parse the full form ID three ways. FF is a dynamically created item, that did not come directly from a file, FE is from an esl, and the rest work the way you're doing it now.

 

The dynamic ones are things like upgraded weapons, where the base weapon is a regular form, but after you used the grindstone, it changed. The "form" is essentially in the save file, not an esp, esm, or esl.

Posted (edited)

i Use

Name
powerofthree's Papyrus Extender

string ModName = GetFormModName(ModForm, false)

 

ID
 

string ModID = GetModFormID(ModForm.GetFormID())

 

string function GetModFormID(int decimal)
	int decimalx = Math.LogicalAnd(decimal, 0xFFFFFF)
	string hex = IntToHex(decimalx)
    return "0x" + hex
endFunction

 

string function IntToHex(int decimal)
    int quotient = decimal
	int[] hexValues = new int[128]
    string hex = ""
    int i=1
    int temp
    while quotient != 0
        temp = quotient % 16
        if temp < 10
            temp += 48
        else
            temp += 55
        endIf
        hexValues[i] = temp
        i += 1
        quotient = quotient / 16
    endWhile
    i -= 1
    while i > 0
        hex += StringUtil.AsChar(hexValues[i])
        i -= 1
    endWhile
    return hex
endFunction

 

Edited by Swe-DivX

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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