xNVSE / NVSE

New Vegas Script Extender (NVSE)
https://git.io/JfSAo
702 stars 55 forks source link

Fixed lambda decompilation. #199

Closed bdemmy closed 3 months ago

bdemmy commented 3 months ago

Should also work in partial scripts (which is what led this to being broken in the first place)

Before

ScriptName nvseRuntimeScript15UpdateQuestpips

Array_var mpNameToEditorId
Int iter
Int edid
Int qname
Array_var tracked
Int i
String_var questPath
String_var questName
String_var editorId

Begin Function { }
    If eval GetActiveMenuMode != 1023
        Return
    EndIf

    Let mpNameToEditorId := ar_Construct ("stringmap")
    ar_ForEach GetQuests Array_var mpNameToEditorId
    Array_var iter
    String_var edid
    String_var qname
    Int tracked
    Int i
    Int questPath
    Int questName
    Int editorId

    Begin Function { }
        Let edid := (GetEditorID (iter[0]))
        Let qname := $iter[0]
        Let mpNameToEditorId[qname] := edid
    End
    Let tracked := (Call CompileScript "SQL/GetTracked.txt" 1)
    Let i := 0

    while i < GetUIFloat ("MapMenu/GLOW_BRANCH/MM_MainRect/MM_QuestsList/childcount")
        Let questPath := "MapMenu/GLOW_BRANCH/MM_MainRect/MM_QuestsList/MM_ListItem:" + $i

        If eval !IsComponentLoaded (questPath)
            break
        EndIf

        Let questName := GetUIString (questPath + "/ListItemText/string")

        If eval !(ar_HasKey mpNameToEditorId questName)
            eval (i := i + 1) - 1
            continue
        EndIf

        Let editorId := mpNameToEditorId[questName]

        If eval IsFormValid (GetActiveQuest)
            If eval $(GetEditorID (GetActiveQuest)) != editorId
                SetUIFloatAlt (questPath + "/MM_Template_ItemMarker/visible") (ar_HasKey tracked editorId)
            Else
                SetUIFloatAlt (questPath + "/MM_Template_ItemMarker/visible") (1)
            EndIf
        Else
            SetUIFloatAlt (questPath + "/MM_Template_ItemMarker/visible") (ar_HasKey tracked editorId)
        EndIf

        eval (i := i + 1) - 1
    loop
End

After

ScriptName nvseRuntimeScript13UpdateQuestPips

Array_var mpNameToEditorId
Int iter
Int edid
Int qname
Array_var tracked
Int i
String_var questPath
String_var questName
String_var editorId
Int x

Begin Function { }
    If eval GetActiveMenuMode != 1023
        Return
    EndIf

    Let mpNameToEditorId := ar_Construct ("stringmap")
    ar_ForEach GetQuests Begin Function { iter }
        Let edid := (GetEditorID (*iter))
        Let qname := $*iter
        Let mpNameToEditorId[qname] := edid
    End
    Let tracked := (Call CompileScript "SQL/GetTracked.txt" 1)
    Let i := 0

    while i < GetUIFloat ("MapMenu/GLOW_BRANCH/MM_MainRect/MM_QuestsList/childcount")
        Let questPath := "MapMenu/GLOW_BRANCH/MM_MainRect/MM_QuestsList/MM_ListItem:" + $i

        If eval !IsComponentLoaded (questPath)
            break
        EndIf

        Let questName := GetUIString ("" + $questPath + "/ListItemText/string")

        If eval !(ar_HasKey mpNameToEditorId questName)
            eval (i := i + 1) - 1
            continue
        EndIf

        Let editorId := mpNameToEditorId[questName]

        If eval IsFormValid (GetActiveQuest)
            If eval $(GetEditorID (GetActiveQuest)) != editorId
                SetUIFloatAlt ("" + $questPath + "/MM_Template_ItemMarker/visible") (ar_HasKey tracked editorId)
            Else
                SetUIFloatAlt ("" + $questPath + "/MM_Template_ItemMarker/visible") (1)
            EndIf
        Else
            SetUIFloatAlt ("" + $questPath + "/MM_Template_ItemMarker/visible") (ar_HasKey tracked editorId)
        EndIf

        eval (i := i + 1) - 1
    loop

    SetModLocalData "__UpdateQuestPips__r" Begin Function { x }
        Print "Hello World"
    End
End
bdemmy commented 3 months ago

(Fixed)

korri123 commented 3 months ago

lgtm