From 14c32a9b91d6b36d5c83684e18cd47123307b5ae Mon Sep 17 00:00:00 2001 From: William Robb Date: Thu, 4 Jun 2020 19:41:27 +0100 Subject: [PATCH 1/5] Added FLORA, Leveled Items, Weapon and the ability to get location information about where these items are placed in the map --- Edit scripts/ExportAll.fo76pas | 18 ++++++ Edit scripts/ExportCore.pas | 93 +++++++++++++++++++++++++++++ Edit scripts/ExportFlatList.pas | 30 ++++++++++ Edit scripts/ExportTabularARMO.pas | 19 +++++- Edit scripts/ExportTabularFLORA.pas | 70 ++++++++++++++++++++++ Edit scripts/ExportTabularLVLI.pas | 71 ++++++++++++++++++++++ Edit scripts/ExportTabularMISC.pas | 10 +++- Edit scripts/ExportTabularWEAP.pas | 90 ++++++++++++++++++++++++++++ 8 files changed, 397 insertions(+), 4 deletions(-) create mode 100644 Edit scripts/ExportTabularFLORA.pas create mode 100644 Edit scripts/ExportTabularLVLI.pas create mode 100644 Edit scripts/ExportTabularWEAP.pas diff --git a/Edit scripts/ExportAll.fo76pas b/Edit scripts/ExportAll.fo76pas index 3b0769c..113527c 100644 --- a/Edit scripts/ExportAll.fo76pas +++ b/Edit scripts/ExportAll.fo76pas @@ -5,13 +5,16 @@ uses ExportTabularARMO, ExportTabularCOBJ, ExportTabularENTM, ExportTabularFACT, + ExportTabularFLORA, ExportTabularGLOB, ExportTabularGMST, ExportTabularIDs, + ExportTabularLVLI, ExportTabularMISC, ExportTabularNPC_, ExportTabularOTFT, ExportTabularRACE, + ExportTabularWEAP, ExportWikiBOOK, ExportWikiDIAL, ExportWikiNOTE, @@ -25,13 +28,16 @@ begin ExportTabularCOBJ.initialize(); ExportTabularENTM.initialize(); ExportTabularFACT.initialize(); + ExportTabularFLORA.initialize(); ExportTabularGLOB.initialize(); ExportTabularGMST.initialize(); ExportTabularIDs.initialize(); + ExportTabularLVLI.initialize(); ExportTabularMISC.initialize(); ExportTabularNPC_.initialize(); ExportTabularOTFT.initialize(); ExportTabularRACE.initialize(); + ExportTabularWEAP.initialize(); ExportWikiBOOK.initialize(); ExportWikiDIAL.initialize(); ExportWikiNOTE.initialize(); @@ -54,6 +60,9 @@ begin end; if ExportTabularFACT.canProcess(e) then begin ExportTabularFACT.process(e); + end; + if ExportTabularFLORA.canProcess(e) then begin + ExportTabularFLORA.process(e); end; if ExportTabularGLOB.canProcess(e) then begin ExportTabularGLOB.process(e); @@ -63,6 +72,9 @@ begin end; if ExportTabularIDs.canProcess(e) then begin ExportTabularIDs.process(e); + end; + if ExportTabularLVLI.canProcess(e) then begin + ExportTabularLVLI.process(e); end; if ExportTabularMISC.canProcess(e) then begin ExportTabularMISC.process(e); @@ -75,6 +87,9 @@ begin end; if ExportTabularRACE.canProcess(e) then begin ExportTabularRACE.process(e); + end; + if ExportTabularWEAP.canProcess(e) then begin + ExportTabularWEAP.process(e); end; if ExportWikiBOOK.canProcess(e) then begin ExportWikiBOOK.process(e); @@ -97,13 +112,16 @@ begin ExportTabularCOBJ.finalize(); ExportTabularENTM.finalize(); ExportTabularFACT.finalize(); + ExportTabularFLORA.finalize(); ExportTabularGLOB.finalize(); ExportTabularGMST.finalize(); ExportTabularIDs.finalize(); + ExportTabularLVLI.finalize(); ExportTabularMISC.finalize(); ExportTabularNPC_.finalize(); ExportTabularOTFT.finalize(); ExportTabularRACE.finalize(); + ExportTabularWEAP.finalize(); ExportWikiBOOK.finalize(); ExportWikiDIAL.finalize(); ExportWikiNOTE.finalize(); diff --git a/Edit scripts/ExportCore.pas b/Edit scripts/ExportCore.pas index f84410d..307f94f 100644 --- a/Edit scripts/ExportCore.pas +++ b/Edit scripts/ExportCore.pas @@ -260,5 +260,98 @@ function parseFloatToInt(float: String): String; result := intToStr(round(strToFloat(float))); end; +function getReferenceByIndexAndSig(e: IInterface; i: Integer; sig: String): IwbElement; +var ref: IwbElement; +begin + ref := referencedByIndex(e, i); + if signature(ref) = sig then begin + result := ref; + exit; + end; +end; + +function getLocationData(e: IInterface): TStringList; +var ExportTabularLOC_outputLines: TStringList; +var ref: IwbElement; +var i: Integer; + +var data: IInterface; +var cell: IInterface; +var worldspace: IInterface; +begin + ExportTabularLOC_outputLines := TStringList.create(); + + for i := 0 to referencedByCount(e) - 1 do begin + + ref := getReferenceByIndexAndSig(e,i,'REFR'); + + if isRefLocation(ref) then begin + // we only want the ones in the Appalachia worldspace + data := ElementBySignature(ref, 'DATA'); + + ExportTabularLOC_outputLines.add( + escapeCsvString(getFileName(getFile(ref))) + ', ' + + escapeCsvString(stringFormID(ref)) + ', ' + + escapeCsvString(evBySign(e, 'EDID')) + ', ' + + escapeCsvString(evBySign(e, 'FULL')) + ', ' + + escapeCsvString(evBySign(ref, 'XLYR')) + ', ' + + escapeCsvString(gev(ElementByName(ref, 'Cell'))) + ', ' + + escapeCsvString(vec3ToString(ElementByName(data,'Position'))) + ', ' + + escapeCsvString(vec3ToString(ElementByName(data,'Rotation'))) + ); + end; + end; + + result := ExportTabularLOC_outputLines; +end; + +function initializeLocationTabular(): TStringList; +var ExportTabularLOC_outputLines: TStringList; +begin + ExportTabularLOC_outputLines := TStringList.create(); + ExportTabularLOC_outputLines.add( + '"File"' // Name of the originating ESM + + ', "Form ID"' // Form ID + + ', "Editor ID"' // Editor ID of item + + ', "Name"' // Full name of item + + ', "Layer"' // Layer the reference is linked to + + ', "Cell"' // World Cell + + ', "Position"' // Vector3 Position + + ', "Rotation"' // Vector3 Rotation + ); + result := ExportTabularLOC_outputLines; +end; + +function vec3ToString(e: IInterface): String; +begin + result := gev(ElementByName(e,'X')) + ':' + gev(ElementByName(e,'Y')) + ':' + gev(ElementByName(e,'Z')); +end; + +function debugPrint(e: IInterface): Boolean; +var i: Integer; +var ei: IwbElement; +begin + for i := 0 to ElementCount(e) - 1 do begin + ei := ElementByIndex(e,i); + addMessage('Found: ' + name(ei) + ' sig: ' + Signature(ei) + ' name: ' + gev(ei)); + + end; + result := True; +end; + +function isRefLocation(e: IInterface): Boolean; +var data: IInterface; +begin + result := false; + + data := eBySign(e, 'DATA'); + if (signature(e) = 'REFR') AND ElementExists(data,'Position') then begin + result := True; + exit; + end; + +end; + + end. diff --git a/Edit scripts/ExportFlatList.pas b/Edit scripts/ExportFlatList.pas index 61557bf..6421173 100644 --- a/Edit scripts/ExportFlatList.pas +++ b/Edit scripts/ExportFlatList.pas @@ -4,6 +4,36 @@ unit ExportFlatList; +(** + * Returns the leveled list entries of [e] as a comma-separated list of editor IDs. + * + * @param e the element to return the keywords of + * @return the entries of [e] as a comma-separated list + *) +function getFlatLeveledList(e: IInterface): String; +var i: Integer; + reference, quantity, level, entry, entries: IInterface; + resultList: TStringList; + +begin + resultList := TStringList.create(); + + entries := ElementByName(e, 'Leveled List Entries'); + + for i := 0 to eCount(entries) - 1 do begin + entry := ElementBySignature(ElementByIndex(entries, i), 'LVLO'); + reference := ElementByName(entry, 'Reference'); + level := ElementBySignature(ElementByIndex(entries, i), 'LVLV'); + quantity := ElementBySignature(ElementByIndex(entries, i), 'LVIV'); + + resultList.add(gev(reference) + ':' + gev(level) + ':' + gev(quantity)); + + end; + + resultList.sort(); + result := listToJson(resultList); + resultList.free(); +end; (** * Returns the keywords of [e] as a comma-separated list of editor IDs. diff --git a/Edit scripts/ExportTabularARMO.pas b/Edit scripts/ExportTabularARMO.pas index 10be0b1..a9e9a6b 100644 --- a/Edit scripts/ExportTabularARMO.pas +++ b/Edit scripts/ExportTabularARMO.pas @@ -6,7 +6,7 @@ var ExportTabularARMO_outputLines: TStringList; - +var ExportTabularLOC_outputLines: TStringList; function initialize: Integer; begin @@ -29,6 +29,10 @@ function initialize: Integer; + ', "Equip slots"' // Sorted JSON array of equipment slots used by the armor + ', "Keywords"' // Sorted JSON array of keywords. Each keyword is represented by its editor ID ); + + + ExportTabularLOC_outputLines := initializeLocationTabular(); + end; function canProcess(e: IInterface): Boolean; @@ -47,12 +51,12 @@ function process(armo: IInterface): Integer; data := eBySign(armo, 'DATA'); ExportTabularARMO_outputLines.add( - escapeCsvString(getFileName(getFile(armo))) + ', ' + escapeCsvString(getFileName(getFile(armo))) + ', ' + escapeCsvString(stringFormID(armo)) + ', ' + escapeCsvString(evBySign(armo, 'EDID')) + ', ' + escapeCsvString(evBySign(armo, 'FULL')) + ', ' + escapeCsvString(evByName(data, 'Weight')) + ', ' - + escapeCsvString(evByName(data, 'Value')) + ', ' + + escapeCsvString(evByName(data, 'Value')) + ', ' + escapeCsvString(evByName(data, 'Health')) + ', ' + escapeCsvString(evBySign(armo, 'RNAM')) + ', ' + escapeCsvString(getFlatChildList(eBySign(armo, 'EILV'))) + ',' @@ -64,12 +68,21 @@ function process(armo: IInterface): Integer; + escapeCsvString(getFlatChildNameList(eByIndex(eBySign(armo, 'BOD2'), 0))) + ', ' + escapeCsvString(getFlatKeywordList(armo)) ); + + ExportTabularLOC_outputLines.AddStrings( + getLocationData(armo) + ); + end; + + function finalize: Integer; begin createDir('dumps/'); ExportTabularARMO_outputLines.saveToFile('dumps/ARMO.csv'); + ExportTabularLOC_outputLines.saveToFile('dumps/ARMOLOC.csv'); + ExportTabularLOC_outputLines.free(); ExportTabularARMO_outputLines.free(); end; diff --git a/Edit scripts/ExportTabularFLORA.pas b/Edit scripts/ExportTabularFLORA.pas new file mode 100644 index 0000000..32d7006 --- /dev/null +++ b/Edit scripts/ExportTabularFLORA.pas @@ -0,0 +1,70 @@ +unit ExportTabularFLORA; + +uses ExportCore, + ExportTabularCore, + ExportFlatList; + + +var ExportTabularFLORA_outputLines: TStringList; +var ExportTabularLOC_outputLines: TStringList; + +function initialize: Integer; +begin + ExportTabularFLORA_outputLines := TStringList.create(); + ExportTabularFLORA_outputLines.add( + '"File"' // Name of the originating ESM + + ', "Form ID"' // Form ID + + ', "Editor ID"' // Editor ID + + ', "Name"' // Full name + + ', "Ingredient"' // Item weight in pounds + + ', "Keywords"' // Sorted JSON array of keywords. Each keyword is represented by its editor ID + ); + + + ExportTabularLOC_outputLines := initializeLocationTabular(); + +end; + +function canProcess(e: IInterface): Boolean; +begin + result := signature(e) = 'FLOR'; +end; + +function process(flora: IInterface): Integer; +var data: IInterface; +begin + if not canProcess(flora) then begin + addMessage('Warning: ' + name(flora) + ' is not a FLORA. Entry was ignored.'); + exit; + end; + + data := eBySign(flora, 'DATA'); + + ExportTabularFLORA_outputLines.add( + escapeCsvString(getFileName(getFile(flora))) + ', ' + + escapeCsvString(stringFormID(flora)) + ', ' + + escapeCsvString(evBySign(flora, 'EDID')) + ', ' + + escapeCsvString(evBySign(flora, 'FULL')) + ', ' + + escapeCsvString(evByName(flora, 'PFIG')) + ', ' + + escapeCsvString(getFlatKeywordList(flora)) + ); + + ExportTabularLOC_outputLines.AddStrings( + getLocationData(flora) + ); + +end; + + + +function finalize: Integer; +begin + createDir('dumps/'); + ExportTabularFLORA_outputLines.saveToFile('dumps/FLORA.csv'); + ExportTabularLOC_outputLines.saveToFile('dumps/FLORALOC.csv'); + ExportTabularLOC_outputLines.free(); + ExportTabularFLORA_outputLines.free(); +end; + + +end. diff --git a/Edit scripts/ExportTabularLVLI.pas b/Edit scripts/ExportTabularLVLI.pas new file mode 100644 index 0000000..4afaf4c --- /dev/null +++ b/Edit scripts/ExportTabularLVLI.pas @@ -0,0 +1,71 @@ +unit ExportTabularLVLI; + +uses ExportCore, + ExportTabularCore, + ExportFlatList; + + +var ExportTabularLVLI_outputLines: TStringList; +var ExportTabularLOC_outputLines: TStringList; + +function initialize: Integer; +begin + ExportTabularLVLI_outputLines := TStringList.create(); + ExportTabularLVLI_outputLines.add( + '"File"' // Name of the originating ESM + + ', "Form ID"' // Form ID + + ', "Editor ID"' // Editor ID + + ', "Name"' // Full name + + ', "Leveled List"' // Leveled list + ); + + + ExportTabularLOC_outputLines := initializeLocationTabular(); + +end; + +function canProcess(e: IInterface): Boolean; +begin + result := signature(e) = 'LVLI'; +end; + +function process(lvli: IInterface): Integer; +var data: IInterface; +begin + if not canProcess(lvli) then begin + addMessage('Warning: ' + name(lvli) + ' is not a LVLI. Entry was ignored.'); + exit; + end; + + data := eBySign(lvli, 'DATA'); + //debugPrint(evBySign(lvli, 'LVLF')); + //debugPrint(evByName(lvli, 'Leveled List Entries')); + ExportTabularLVLI_outputLines.add( + escapeCsvString(getFileName(getFile(lvli))) + ', ' + + escapeCsvString(stringFormID(lvli)) + ', ' + + escapeCsvString(evBySign(lvli, 'EDID')) + ', ' + + escapeCsvString(evBySign(lvli, 'FULL')) + ', ' + //https://github.com/fireundubh/xedit-scripts/blob/master/all/Relevel%20Leveled%20Lists.pas + + escapeCsvString(getFlatLeveledList(lvli)) + + ); + + ExportTabularLOC_outputLines.AddStrings( + getLocationData(lvli) + ); + +end; + + + +function finalize: Integer; +begin + createDir('dumps/'); + ExportTabularLVLI_outputLines.saveToFile('dumps/LVLI.csv'); + ExportTabularLOC_outputLines.saveToFile('dumps/LVLILOC.csv'); + ExportTabularLOC_outputLines.free(); + ExportTabularLVLI_outputLines.free(); +end; + + +end. diff --git a/Edit scripts/ExportTabularMISC.pas b/Edit scripts/ExportTabularMISC.pas index d999ddd..ee7d89f 100644 --- a/Edit scripts/ExportTabularMISC.pas +++ b/Edit scripts/ExportTabularMISC.pas @@ -6,7 +6,7 @@ var ExportTabularMISC_outputLines: TStringList; - +var ExportTabularLOC_outputLines: TStringList; function initialize: Integer; begin @@ -21,6 +21,7 @@ function initialize: Integer; + ', "Components"' // Sorted JSON array of the components needed to craft. Each component is formatted as // `[component editor id] ([amount])` ); + ExportTabularLOC_outputLines := initializeLocationTabular(); end; function canProcess(e: IInterface): Boolean; @@ -44,12 +45,19 @@ function process(misc: IInterface): Integer; + escapeCsvString(evByPath(eBySign(misc, 'DATA'), 'Value')) + ', ' + escapeCsvString(getFlatComponentList(misc)) ); + + ExportTabularLOC_outputLines.AddStrings( + getLocationData(misc) + ); + end; function finalize: Integer; begin createDir('dumps/'); ExportTabularMISC_outputLines.saveToFile('dumps/MISC.csv'); + ExportTabularLOC_outputLines.saveToFile('dumps/MISCLOC.csv'); + ExportTabularLOC_outputLines.free(); ExportTabularMISC_outputLines.free(); end; diff --git a/Edit scripts/ExportTabularWEAP.pas b/Edit scripts/ExportTabularWEAP.pas new file mode 100644 index 0000000..3976269 --- /dev/null +++ b/Edit scripts/ExportTabularWEAP.pas @@ -0,0 +1,90 @@ +unit ExportTabularWEAP; + +uses ExportCore, + ExportTabularCore, + ExportFlatList; + + +var ExportTabularWEAP_outputLines: TStringList; +var ExportTabularLOC_outputLines: TStringList; + +function initialize: Integer; +begin + ExportTabularWEAP_outputLines := TStringList.create(); + ExportTabularWEAP_outputLines.add( + '"File"' // Name of the originating ESM + + ', "Form ID"' // Form ID + + ', "Editor ID"' // Editor ID + + ', "Name"' // Full name + + ', "Weight"' // Item weight in pounds + + ', "Value"' // Item value in bottlecaps + + ', "Health"' // Item health in points + + ', "Race"' // The race that can wear this weapr + + ', "Levels"' // Sorted JSON array of possible weapr levels + + ', "DR curve"' // Damage Resistance curve + + ', "Durability min curve"' // Min durability curve + + ', "Durability max curve"' // Max durability curve + + ', "Condition dmg curve"' // Condition damage scale factor curve + + ', "Attach slots"' // Sorted JSON array of attachment slots available to the weapr + + ', "Equip slots"' // Sorted JSON array of equipment slots used by the weapr + + ', "Keywords"' // Sorted JSON array of keywords. Each keyword is represented by its editor ID + ); + + + ExportTabularLOC_outputLines := initializeLocationTabular(); + +end; + +function canProcess(e: IInterface): Boolean; +begin + result := signature(e) = 'WEAP'; +end; + +function process(weap: IInterface): Integer; +var data: IInterface; +begin + if not canProcess(weap) then begin + addMessage('Warning: ' + name(weap) + ' is not a WEAP. Entry was ignored.'); + exit; + end; + + data := eBySign(weap, 'DATA'); + + ExportTabularWEAP_outputLines.add( + escapeCsvString(getFileName(getFile(weap))) + ', ' + + escapeCsvString(stringFormID(weap)) + ', ' + + escapeCsvString(evBySign(weap, 'EDID')) + ', ' + + escapeCsvString(evBySign(weap, 'FULL')) + ', ' + + escapeCsvString(evByName(data, 'Weight')) + ', ' + + escapeCsvString(evByName(data, 'Value')) + ', ' + + escapeCsvString(evByName(data, 'Health')) + ', ' + + escapeCsvString(evBySign(weap, 'RNAM')) + ', ' + + escapeCsvString(getFlatChildList(eBySign(weap, 'EILV'))) + ',' + + escapeCsvString(evBySign(weap, 'CVT0')) + ',' + + escapeCsvString(evBySign(weap, 'CVT1')) + ',' + + escapeCsvString(evBySign(weap, 'CVT3')) + ',' + + escapeCsvString(evBySign(weap, 'CVT2')) + ',' + + escapeCsvString(getFlatChildList(eBySign(weap, 'APPR'))) + ',' + + escapeCsvString(getFlatChildNameList(eByIndex(eBySign(weap, 'BOD2'), 0))) + ', ' + + escapeCsvString(getFlatKeywordList(weap)) + ); + + ExportTabularLOC_outputLines.AddStrings( + getLocationData(weap) + ); + +end; + + + +function finalize: Integer; +begin + createDir('dumps/'); + ExportTabularWEAP_outputLines.saveToFile('dumps/WEAP.csv'); + ExportTabularLOC_outputLines.saveToFile('dumps/WEAPLOC.csv'); + ExportTabularLOC_outputLines.free(); + ExportTabularWEAP_outputLines.free(); +end; + + +end. From 5c0cfb1909921ba909d4f6dd81190297a125fe36 Mon Sep 17 00:00:00 2001 From: William Robb Date: Thu, 4 Jun 2020 19:46:42 +0100 Subject: [PATCH 2/5] replaced tabs with spaces --- Edit scripts/ExportAll.fo76pas | 24 +++---- Edit scripts/ExportCore.pas | 104 ++++++++++++++-------------- Edit scripts/ExportFlatList.pas | 16 ++--- Edit scripts/ExportTabularARMO.pas | 26 +++---- Edit scripts/ExportTabularFLORA.pas | 24 +++---- Edit scripts/ExportTabularLVLI.pas | 32 ++++----- Edit scripts/ExportTabularMISC.pas | 16 ++--- Edit scripts/ExportTabularWEAP.pas | 26 +++---- 8 files changed, 134 insertions(+), 134 deletions(-) diff --git a/Edit scripts/ExportAll.fo76pas b/Edit scripts/ExportAll.fo76pas index 113527c..4bf60ec 100644 --- a/Edit scripts/ExportAll.fo76pas +++ b/Edit scripts/ExportAll.fo76pas @@ -5,16 +5,16 @@ uses ExportTabularARMO, ExportTabularCOBJ, ExportTabularENTM, ExportTabularFACT, - ExportTabularFLORA, + ExportTabularFLORA, ExportTabularGLOB, ExportTabularGMST, ExportTabularIDs, - ExportTabularLVLI, + ExportTabularLVLI, ExportTabularMISC, ExportTabularNPC_, ExportTabularOTFT, ExportTabularRACE, - ExportTabularWEAP, + ExportTabularWEAP, ExportWikiBOOK, ExportWikiDIAL, ExportWikiNOTE, @@ -28,16 +28,16 @@ begin ExportTabularCOBJ.initialize(); ExportTabularENTM.initialize(); ExportTabularFACT.initialize(); - ExportTabularFLORA.initialize(); + ExportTabularFLORA.initialize(); ExportTabularGLOB.initialize(); ExportTabularGMST.initialize(); ExportTabularIDs.initialize(); - ExportTabularLVLI.initialize(); + ExportTabularLVLI.initialize(); ExportTabularMISC.initialize(); ExportTabularNPC_.initialize(); ExportTabularOTFT.initialize(); ExportTabularRACE.initialize(); - ExportTabularWEAP.initialize(); + ExportTabularWEAP.initialize(); ExportWikiBOOK.initialize(); ExportWikiDIAL.initialize(); ExportWikiNOTE.initialize(); @@ -61,7 +61,7 @@ begin if ExportTabularFACT.canProcess(e) then begin ExportTabularFACT.process(e); end; - if ExportTabularFLORA.canProcess(e) then begin + if ExportTabularFLORA.canProcess(e) then begin ExportTabularFLORA.process(e); end; if ExportTabularGLOB.canProcess(e) then begin @@ -73,7 +73,7 @@ begin if ExportTabularIDs.canProcess(e) then begin ExportTabularIDs.process(e); end; - if ExportTabularLVLI.canProcess(e) then begin + if ExportTabularLVLI.canProcess(e) then begin ExportTabularLVLI.process(e); end; if ExportTabularMISC.canProcess(e) then begin @@ -88,7 +88,7 @@ begin if ExportTabularRACE.canProcess(e) then begin ExportTabularRACE.process(e); end; - if ExportTabularWEAP.canProcess(e) then begin + if ExportTabularWEAP.canProcess(e) then begin ExportTabularWEAP.process(e); end; if ExportWikiBOOK.canProcess(e) then begin @@ -112,16 +112,16 @@ begin ExportTabularCOBJ.finalize(); ExportTabularENTM.finalize(); ExportTabularFACT.finalize(); - ExportTabularFLORA.finalize(); + ExportTabularFLORA.finalize(); ExportTabularGLOB.finalize(); ExportTabularGMST.finalize(); ExportTabularIDs.finalize(); - ExportTabularLVLI.finalize(); + ExportTabularLVLI.finalize(); ExportTabularMISC.finalize(); ExportTabularNPC_.finalize(); ExportTabularOTFT.finalize(); ExportTabularRACE.finalize(); - ExportTabularWEAP.finalize(); + ExportTabularWEAP.finalize(); ExportWikiBOOK.finalize(); ExportWikiDIAL.finalize(); ExportWikiNOTE.finalize(); diff --git a/Edit scripts/ExportCore.pas b/Edit scripts/ExportCore.pas index 307f94f..ea71163 100644 --- a/Edit scripts/ExportCore.pas +++ b/Edit scripts/ExportCore.pas @@ -263,13 +263,13 @@ function parseFloatToInt(float: String): String; function getReferenceByIndexAndSig(e: IInterface; i: Integer; sig: String): IwbElement; var ref: IwbElement; begin - ref := referencedByIndex(e, i); - if signature(ref) = sig then begin - result := ref; - exit; - end; + ref := referencedByIndex(e, i); + if signature(ref) = sig then begin + result := ref; + exit; + end; end; - + function getLocationData(e: IInterface): TStringList; var ExportTabularLOC_outputLines: TStringList; var ref: IwbElement; @@ -279,77 +279,77 @@ function getLocationData(e: IInterface): TStringList; var cell: IInterface; var worldspace: IInterface; begin - ExportTabularLOC_outputLines := TStringList.create(); - - for i := 0 to referencedByCount(e) - 1 do begin - - ref := getReferenceByIndexAndSig(e,i,'REFR'); - - if isRefLocation(ref) then begin - // we only want the ones in the Appalachia worldspace - data := ElementBySignature(ref, 'DATA'); - - ExportTabularLOC_outputLines.add( - escapeCsvString(getFileName(getFile(ref))) + ', ' - + escapeCsvString(stringFormID(ref)) + ', ' - + escapeCsvString(evBySign(e, 'EDID')) + ', ' - + escapeCsvString(evBySign(e, 'FULL')) + ', ' - + escapeCsvString(evBySign(ref, 'XLYR')) + ', ' - + escapeCsvString(gev(ElementByName(ref, 'Cell'))) + ', ' - + escapeCsvString(vec3ToString(ElementByName(data,'Position'))) + ', ' - + escapeCsvString(vec3ToString(ElementByName(data,'Rotation'))) - ); - end; - end; - - result := ExportTabularLOC_outputLines; -end; + ExportTabularLOC_outputLines := TStringList.create(); + + for i := 0 to referencedByCount(e) - 1 do begin + + ref := getReferenceByIndexAndSig(e,i,'REFR'); + + if isRefLocation(ref) then begin + // we only want the ones in the Appalachia worldspace + data := ElementBySignature(ref, 'DATA'); + + ExportTabularLOC_outputLines.add( + escapeCsvString(getFileName(getFile(ref))) + ', ' + + escapeCsvString(stringFormID(ref)) + ', ' + + escapeCsvString(evBySign(e, 'EDID')) + ', ' + + escapeCsvString(evBySign(e, 'FULL')) + ', ' + + escapeCsvString(evBySign(ref, 'XLYR')) + ', ' + + escapeCsvString(gev(ElementByName(ref, 'Cell'))) + ', ' + + escapeCsvString(vec3ToString(ElementByName(data,'Position'))) + ', ' + + escapeCsvString(vec3ToString(ElementByName(data,'Rotation'))) + ); + end; + end; + + result := ExportTabularLOC_outputLines; +end; function initializeLocationTabular(): TStringList; var ExportTabularLOC_outputLines: TStringList; begin - ExportTabularLOC_outputLines := TStringList.create(); - ExportTabularLOC_outputLines.add( + ExportTabularLOC_outputLines := TStringList.create(); + ExportTabularLOC_outputLines.add( '"File"' // Name of the originating ESM + ', "Form ID"' // Form ID + ', "Editor ID"' // Editor ID of item + ', "Name"' // Full name of item + ', "Layer"' // Layer the reference is linked to - + ', "Cell"' // World Cell - + ', "Position"' // Vector3 Position - + ', "Rotation"' // Vector3 Rotation + + ', "Cell"' // World Cell + + ', "Position"' // Vector3 Position + + ', "Rotation"' // Vector3 Rotation ); - result := ExportTabularLOC_outputLines; + result := ExportTabularLOC_outputLines; end; function vec3ToString(e: IInterface): String; begin - result := gev(ElementByName(e,'X')) + ':' + gev(ElementByName(e,'Y')) + ':' + gev(ElementByName(e,'Z')); + result := gev(ElementByName(e,'X')) + ':' + gev(ElementByName(e,'Y')) + ':' + gev(ElementByName(e,'Z')); end; function debugPrint(e: IInterface): Boolean; var i: Integer; var ei: IwbElement; begin - for i := 0 to ElementCount(e) - 1 do begin - ei := ElementByIndex(e,i); - addMessage('Found: ' + name(ei) + ' sig: ' + Signature(ei) + ' name: ' + gev(ei)); - - end; - result := True; + for i := 0 to ElementCount(e) - 1 do begin + ei := ElementByIndex(e,i); + addMessage('Found: ' + name(ei) + ' sig: ' + Signature(ei) + ' name: ' + gev(ei)); + + end; + result := True; end; function isRefLocation(e: IInterface): Boolean; var data: IInterface; begin - result := false; - - data := eBySign(e, 'DATA'); - if (signature(e) = 'REFR') AND ElementExists(data,'Position') then begin - result := True; - exit; - end; - + result := false; + + data := eBySign(e, 'DATA'); + if (signature(e) = 'REFR') AND ElementExists(data,'Position') then begin + result := True; + exit; + end; + end; diff --git a/Edit scripts/ExportFlatList.pas b/Edit scripts/ExportFlatList.pas index 6421173..8f6b5c8 100644 --- a/Edit scripts/ExportFlatList.pas +++ b/Edit scripts/ExportFlatList.pas @@ -14,20 +14,20 @@ function getFlatLeveledList(e: IInterface): String; var i: Integer; reference, quantity, level, entry, entries: IInterface; resultList: TStringList; - + begin resultList := TStringList.create(); entries := ElementByName(e, 'Leveled List Entries'); - + for i := 0 to eCount(entries) - 1 do begin - entry := ElementBySignature(ElementByIndex(entries, i), 'LVLO'); - reference := ElementByName(entry, 'Reference'); - level := ElementBySignature(ElementByIndex(entries, i), 'LVLV'); - quantity := ElementBySignature(ElementByIndex(entries, i), 'LVIV'); - + entry := ElementBySignature(ElementByIndex(entries, i), 'LVLO'); + reference := ElementByName(entry, 'Reference'); + level := ElementBySignature(ElementByIndex(entries, i), 'LVLV'); + quantity := ElementBySignature(ElementByIndex(entries, i), 'LVIV'); + resultList.add(gev(reference) + ':' + gev(level) + ':' + gev(quantity)); - + end; resultList.sort(); diff --git a/Edit scripts/ExportTabularARMO.pas b/Edit scripts/ExportTabularARMO.pas index a9e9a6b..dea8625 100644 --- a/Edit scripts/ExportTabularARMO.pas +++ b/Edit scripts/ExportTabularARMO.pas @@ -29,10 +29,10 @@ function initialize: Integer; + ', "Equip slots"' // Sorted JSON array of equipment slots used by the armor + ', "Keywords"' // Sorted JSON array of keywords. Each keyword is represented by its editor ID ); - - - ExportTabularLOC_outputLines := initializeLocationTabular(); - + + + ExportTabularLOC_outputLines := initializeLocationTabular(); + end; function canProcess(e: IInterface): Boolean; @@ -51,12 +51,12 @@ function process(armo: IInterface): Integer; data := eBySign(armo, 'DATA'); ExportTabularARMO_outputLines.add( - escapeCsvString(getFileName(getFile(armo))) + ', ' + escapeCsvString(getFileName(getFile(armo))) + ', ' + escapeCsvString(stringFormID(armo)) + ', ' + escapeCsvString(evBySign(armo, 'EDID')) + ', ' + escapeCsvString(evBySign(armo, 'FULL')) + ', ' + escapeCsvString(evByName(data, 'Weight')) + ', ' - + escapeCsvString(evByName(data, 'Value')) + ', ' + + escapeCsvString(evByName(data, 'Value')) + ', ' + escapeCsvString(evByName(data, 'Health')) + ', ' + escapeCsvString(evBySign(armo, 'RNAM')) + ', ' + escapeCsvString(getFlatChildList(eBySign(armo, 'EILV'))) + ',' @@ -68,11 +68,11 @@ function process(armo: IInterface): Integer; + escapeCsvString(getFlatChildNameList(eByIndex(eBySign(armo, 'BOD2'), 0))) + ', ' + escapeCsvString(getFlatKeywordList(armo)) ); - - ExportTabularLOC_outputLines.AddStrings( - getLocationData(armo) - ); - + + ExportTabularLOC_outputLines.AddStrings( + getLocationData(armo) + ); + end; @@ -81,8 +81,8 @@ function finalize: Integer; begin createDir('dumps/'); ExportTabularARMO_outputLines.saveToFile('dumps/ARMO.csv'); - ExportTabularLOC_outputLines.saveToFile('dumps/ARMOLOC.csv'); - ExportTabularLOC_outputLines.free(); + ExportTabularLOC_outputLines.saveToFile('dumps/ARMOLOC.csv'); + ExportTabularLOC_outputLines.free(); ExportTabularARMO_outputLines.free(); end; diff --git a/Edit scripts/ExportTabularFLORA.pas b/Edit scripts/ExportTabularFLORA.pas index 32d7006..3e73f68 100644 --- a/Edit scripts/ExportTabularFLORA.pas +++ b/Edit scripts/ExportTabularFLORA.pas @@ -19,10 +19,10 @@ function initialize: Integer; + ', "Ingredient"' // Item weight in pounds + ', "Keywords"' // Sorted JSON array of keywords. Each keyword is represented by its editor ID ); - - - ExportTabularLOC_outputLines := initializeLocationTabular(); - + + + ExportTabularLOC_outputLines := initializeLocationTabular(); + end; function canProcess(e: IInterface): Boolean; @@ -41,18 +41,18 @@ function process(flora: IInterface): Integer; data := eBySign(flora, 'DATA'); ExportTabularFLORA_outputLines.add( - escapeCsvString(getFileName(getFile(flora))) + ', ' + escapeCsvString(getFileName(getFile(flora))) + ', ' + escapeCsvString(stringFormID(flora)) + ', ' + escapeCsvString(evBySign(flora, 'EDID')) + ', ' + escapeCsvString(evBySign(flora, 'FULL')) + ', ' + escapeCsvString(evByName(flora, 'PFIG')) + ', ' + escapeCsvString(getFlatKeywordList(flora)) ); - - ExportTabularLOC_outputLines.AddStrings( - getLocationData(flora) - ); - + + ExportTabularLOC_outputLines.AddStrings( + getLocationData(flora) + ); + end; @@ -61,8 +61,8 @@ function finalize: Integer; begin createDir('dumps/'); ExportTabularFLORA_outputLines.saveToFile('dumps/FLORA.csv'); - ExportTabularLOC_outputLines.saveToFile('dumps/FLORALOC.csv'); - ExportTabularLOC_outputLines.free(); + ExportTabularLOC_outputLines.saveToFile('dumps/FLORALOC.csv'); + ExportTabularLOC_outputLines.free(); ExportTabularFLORA_outputLines.free(); end; diff --git a/Edit scripts/ExportTabularLVLI.pas b/Edit scripts/ExportTabularLVLI.pas index 4afaf4c..10b224f 100644 --- a/Edit scripts/ExportTabularLVLI.pas +++ b/Edit scripts/ExportTabularLVLI.pas @@ -18,10 +18,10 @@ function initialize: Integer; + ', "Name"' // Full name + ', "Leveled List"' // Leveled list ); - - - ExportTabularLOC_outputLines := initializeLocationTabular(); - + + + ExportTabularLOC_outputLines := initializeLocationTabular(); + end; function canProcess(e: IInterface): Boolean; @@ -38,22 +38,22 @@ function process(lvli: IInterface): Integer; end; data := eBySign(lvli, 'DATA'); - //debugPrint(evBySign(lvli, 'LVLF')); - //debugPrint(evByName(lvli, 'Leveled List Entries')); + //debugPrint(evBySign(lvli, 'LVLF')); + //debugPrint(evByName(lvli, 'Leveled List Entries')); ExportTabularLVLI_outputLines.add( - escapeCsvString(getFileName(getFile(lvli))) + ', ' + escapeCsvString(getFileName(getFile(lvli))) + ', ' + escapeCsvString(stringFormID(lvli)) + ', ' + escapeCsvString(evBySign(lvli, 'EDID')) + ', ' + escapeCsvString(evBySign(lvli, 'FULL')) + ', ' - //https://github.com/fireundubh/xedit-scripts/blob/master/all/Relevel%20Leveled%20Lists.pas - + escapeCsvString(getFlatLeveledList(lvli)) + //https://github.com/fireundubh/xedit-scripts/blob/master/all/Relevel%20Leveled%20Lists.pas + + escapeCsvString(getFlatLeveledList(lvli)) ); - - ExportTabularLOC_outputLines.AddStrings( - getLocationData(lvli) - ); - + + ExportTabularLOC_outputLines.AddStrings( + getLocationData(lvli) + ); + end; @@ -62,8 +62,8 @@ function finalize: Integer; begin createDir('dumps/'); ExportTabularLVLI_outputLines.saveToFile('dumps/LVLI.csv'); - ExportTabularLOC_outputLines.saveToFile('dumps/LVLILOC.csv'); - ExportTabularLOC_outputLines.free(); + ExportTabularLOC_outputLines.saveToFile('dumps/LVLILOC.csv'); + ExportTabularLOC_outputLines.free(); ExportTabularLVLI_outputLines.free(); end; diff --git a/Edit scripts/ExportTabularMISC.pas b/Edit scripts/ExportTabularMISC.pas index ee7d89f..bea9b21 100644 --- a/Edit scripts/ExportTabularMISC.pas +++ b/Edit scripts/ExportTabularMISC.pas @@ -21,7 +21,7 @@ function initialize: Integer; + ', "Components"' // Sorted JSON array of the components needed to craft. Each component is formatted as // `[component editor id] ([amount])` ); - ExportTabularLOC_outputLines := initializeLocationTabular(); + ExportTabularLOC_outputLines := initializeLocationTabular(); end; function canProcess(e: IInterface): Boolean; @@ -45,19 +45,19 @@ function process(misc: IInterface): Integer; + escapeCsvString(evByPath(eBySign(misc, 'DATA'), 'Value')) + ', ' + escapeCsvString(getFlatComponentList(misc)) ); - - ExportTabularLOC_outputLines.AddStrings( - getLocationData(misc) - ); - + + ExportTabularLOC_outputLines.AddStrings( + getLocationData(misc) + ); + end; function finalize: Integer; begin createDir('dumps/'); ExportTabularMISC_outputLines.saveToFile('dumps/MISC.csv'); - ExportTabularLOC_outputLines.saveToFile('dumps/MISCLOC.csv'); - ExportTabularLOC_outputLines.free(); + ExportTabularLOC_outputLines.saveToFile('dumps/MISCLOC.csv'); + ExportTabularLOC_outputLines.free(); ExportTabularMISC_outputLines.free(); end; diff --git a/Edit scripts/ExportTabularWEAP.pas b/Edit scripts/ExportTabularWEAP.pas index 3976269..0ed09b0 100644 --- a/Edit scripts/ExportTabularWEAP.pas +++ b/Edit scripts/ExportTabularWEAP.pas @@ -29,10 +29,10 @@ function initialize: Integer; + ', "Equip slots"' // Sorted JSON array of equipment slots used by the weapr + ', "Keywords"' // Sorted JSON array of keywords. Each keyword is represented by its editor ID ); - - - ExportTabularLOC_outputLines := initializeLocationTabular(); - + + + ExportTabularLOC_outputLines := initializeLocationTabular(); + end; function canProcess(e: IInterface): Boolean; @@ -51,12 +51,12 @@ function process(weap: IInterface): Integer; data := eBySign(weap, 'DATA'); ExportTabularWEAP_outputLines.add( - escapeCsvString(getFileName(getFile(weap))) + ', ' + escapeCsvString(getFileName(getFile(weap))) + ', ' + escapeCsvString(stringFormID(weap)) + ', ' + escapeCsvString(evBySign(weap, 'EDID')) + ', ' + escapeCsvString(evBySign(weap, 'FULL')) + ', ' + escapeCsvString(evByName(data, 'Weight')) + ', ' - + escapeCsvString(evByName(data, 'Value')) + ', ' + + escapeCsvString(evByName(data, 'Value')) + ', ' + escapeCsvString(evByName(data, 'Health')) + ', ' + escapeCsvString(evBySign(weap, 'RNAM')) + ', ' + escapeCsvString(getFlatChildList(eBySign(weap, 'EILV'))) + ',' @@ -68,11 +68,11 @@ function process(weap: IInterface): Integer; + escapeCsvString(getFlatChildNameList(eByIndex(eBySign(weap, 'BOD2'), 0))) + ', ' + escapeCsvString(getFlatKeywordList(weap)) ); - - ExportTabularLOC_outputLines.AddStrings( - getLocationData(weap) - ); - + + ExportTabularLOC_outputLines.AddStrings( + getLocationData(weap) + ); + end; @@ -81,8 +81,8 @@ function finalize: Integer; begin createDir('dumps/'); ExportTabularWEAP_outputLines.saveToFile('dumps/WEAP.csv'); - ExportTabularLOC_outputLines.saveToFile('dumps/WEAPLOC.csv'); - ExportTabularLOC_outputLines.free(); + ExportTabularLOC_outputLines.saveToFile('dumps/WEAPLOC.csv'); + ExportTabularLOC_outputLines.free(); ExportTabularWEAP_outputLines.free(); end; From 81ff03c49328d32e5d1a86c03d27ad8440b31fb7 Mon Sep 17 00:00:00 2001 From: "Felix W. Dekker" Date: Sun, 27 Sep 2020 23:52:04 +0200 Subject: [PATCH 3/5] Rewrite LVLI serialisation Now serialised as JSON objects. Also fix some tiny documentation errors and such. --- Edit scripts/ExportCore.pas | 11 ++-- Edit scripts/ExportJson.pas | 99 +++++++++++++++++++++++------- Edit scripts/ExportTabularCore.pas | 11 ---- Edit scripts/ExportTabularLVLI.pas | 35 ++++------- 4 files changed, 96 insertions(+), 60 deletions(-) diff --git a/Edit scripts/ExportCore.pas b/Edit scripts/ExportCore.pas index 13ceb6b..a822eb6 100644 --- a/Edit scripts/ExportCore.pas +++ b/Edit scripts/ExportCore.pas @@ -9,7 +9,7 @@ * * Shorthands for commonly used functions. * - ***) + **) (** * Shorthand for [getEditValue]. @@ -141,7 +141,7 @@ function stringFormID(e: IInterface): String; * * xEdit utility functions * - ***) + **) (** * Returns `true` iff [e] is referenced by a record with signature [sig]. @@ -166,12 +166,13 @@ function isReferencedBy(e: IInterface; sig: String): Boolean; (*** + * * Error and warning management. - *) + * + **) var ExportCore_warnings: TStringList; var ExportCore_errors: TStringList; - (** * Initializes error and warning management if this has not happened yet. *) @@ -244,7 +245,7 @@ function errorStats(full: Boolean): String; * * Generic utility functions. * - ***) + **) (** * Repeats [text] [amount] times. diff --git a/Edit scripts/ExportJson.pas b/Edit scripts/ExportJson.pas index fb8fc1d..0447004 100644 --- a/Edit scripts/ExportJson.pas +++ b/Edit scripts/ExportJson.pas @@ -4,9 +4,28 @@ unit ExportJson; +(*** + * + * Core functions for JSON serialization. + * + **) + +(** + * Escapes all double quotes in [text] by putting a backslash in front of them. + * + * @param text the text to escape + * @return a quote-escaped version of [text] + *) +function escapeQuotes(text: String): String; +begin + result := stringReplace(text, '"', '\"', [rfReplaceAll]); +end; + (** * Serializes the list of values into a JSON array. * + * Each list entry is interpreted as a raw value and is not surrounded with quotes. + * * @param list the list of values to convert to a serialized JSON array * @return a serialized JSON array version of [list] *) @@ -18,14 +37,31 @@ function listToJsonArray(list: TStringList): String; exit; end; - result := '"' + list[0] + '"'; + result := list[0]; for i := 1 to list.count - 1 do begin - result := result + ',"' + list[i] + '"'; + result := result + ',' + list[i]; end; result := '[' + result + ']'; end; +(** + * Serializes the list of strings into a JSON array. + * + * Each list entry is interpreted as a string and is therefore surrounded with double quotes as part of serialization. + * + * @param list the list of strings to convert to a serialized JSON array + * @return a serialized JSON array version of [list] + *) +function stringListToJsonArray(list: TStringList): String; +var i: Integer; +begin + for i := 0 to list.count - 1 do begin + list[i] = '"' + escapeQuotes(list[i]) + '"'; + end; + result := listToJsonArray(list); +end; + (** * Serializes the lists of keys and values into a JSON object. * @@ -49,7 +85,7 @@ function listsToJsonObject(keys: TStringList; values: TStringList; sorted: Boole entries := TStringList.create(); for i := 0 to keys.count - 1 do begin - entries.add('"' + keys[i] + '": "' + values[i] + '"'); + entries.add('"' + escapeQuotes(keys[i]) + '": "' + escapeQuotes(values[i]) + '"'); end; if sorted then begin @@ -65,6 +101,13 @@ function listsToJsonObject(keys: TStringList; values: TStringList; sorted: Boole end; + +(*** + * + * Domain-specific serialization functions. + * + **) + (** * Returns the keywords of [e] as a serialized JSON array of editor IDs. * @@ -84,7 +127,7 @@ function getJsonKeywordArray(e: IInterface): String; end; resultList.sort(); - result := listToJsonArray(resultList); + result := stringListToJsonArray(resultList); resultList.free(); end; @@ -109,7 +152,7 @@ function getJsonFactionArray(e: IInterface): String; end; resultList.sort(); - result := listToJsonArray(resultList); + result := stringListToJsonArray(resultList); resultList.free(); end; @@ -137,7 +180,7 @@ function getJsonComponentArray(e: IInterface): String; end; resultList.sort(); - result := listToJsonArray(resultList); + result := stringListToJsonArray(resultList); resultList.free(); end; @@ -162,7 +205,7 @@ function getJsonPerkArray(e: IInterface): String; end; resultList.sort(); - result := listToJsonArray(resultList); + result := stringListToJsonArray(resultList); resultList.free(); end; @@ -226,11 +269,11 @@ function getJsonChildArray(list: IInterface): String; resultList := TStringList.create(); for i := 0 to eCount(list) - 1 do begin - resultList.add(escapeQuotes(evByIndex(list, i))); + resultList.add(evByIndex(list, i)); end; resultList.sort(); - result := listToJsonArray(resultList); + result := stringListToJsonArray(resultList); resultList.free(); end; @@ -249,10 +292,10 @@ function getJsonUnsortedChildArray(list: IInterface): String; resultList := TStringList.create(); for i := 0 to eCount(list) - 1 do begin - resultList.add(escapeQuotes(evByIndex(list, i))); + resultList.add(evByIndex(list, i)); end; - result := listToJsonArray(resultList); + result := stringListToJsonArray(resultList); resultList.free(); end; @@ -271,46 +314,58 @@ function getJsonChildNameArray(list: IInterface): String; resultList := TStringList.create(); for i := 0 to eCount(list) - 1 do begin - resultList.add(escapeQuotes(name(eByIndex(list, i)))); + resultList.add(name(eByIndex(list, i))); end; resultList.sort(); - result := listToJsonArray(resultList); + result := stringListToJsonArray(resultList); resultList.free(); end; (** * Returns the leveled list entries of [e] as a serialized JSON array. * - * Each leveled list entry is expressed using a colon-separated triple of the referenced item, the level, and the - * quantity. + * Each leveled list entry is expressed using a colon-separated triple of the referenced item, the level, and the count. * * @param e the element to return the leveled list entries of * @return the entries of [e] as a serialized JSON array *) function getJsonLeveledListArray(e: IInterface): String; var i: Integer; + entries: IInterface; entry: IInterface; + entryKeys: TStringList; + entryValues: TStringList; reference: String; level: String; quantity: String; resultList: TStringList; begin resultList := TStringList.create(); + entryKeys := TStringList.create(); + entryValues := TStringList.create(); + + entryKeys.add('Reference'); + entryKeys.add('Level'); + entryKeys.add('Count'); - entries := elementByName(e, 'Leveled List Entries'); + entries := eByName(e, 'Leveled List Entries'); for i := 0 to eCount(entries) - 1 do begin - entry := eBySign(eByIndex(entries, i), 'LVLO'); + entry := eByName(eBySign(eByIndex(entries, i), 'LVLO'), 'Base Data'); - reference := evByName(entry, 'Reference'); - level := evBySign(eByIndex(entries, i), 'LVLV'); - quantity := evBySign(eByIndex(entries, i), 'LVIV'); + entryValues.clear(); + entryValues.add(evByName(entry, 'Reference')); + entryValues.add(evByName(entry, 'Level')); + entryValues.add(evByName(entry, 'Count')); - resultList.add(reference + ':' + level + ':' + quantity); + resultList.add(listsToJsonObject(entryKeys, entryValues, false)); end; resultList.sort(); - result := listToJson(resultList); + result := listToJsonArray(resultList); + + entryValues.free(); + entryKeys.free(); resultList.free(); end; diff --git a/Edit scripts/ExportTabularCore.pas b/Edit scripts/ExportTabularCore.pas index 0e977d1..4fd53b9 100644 --- a/Edit scripts/ExportTabularCore.pas +++ b/Edit scripts/ExportTabularCore.pas @@ -17,16 +17,5 @@ function escapeCsvString(text: String): String; result := '"' + result + '"'; end; -(** - * Escapes all double quotes in [text] by putting a backslash in front of them. - * - * @param text the text to escape - * @return a quote-escaped version of [text] - *) -function escapeQuotes(text: String): String; -begin - result := stringReplace(text, '"', '\"', [rfReplaceAll]); -end; - end. diff --git a/Edit scripts/ExportTabularLVLI.pas b/Edit scripts/ExportTabularLVLI.pas index 7059853..9b0b02e 100644 --- a/Edit scripts/ExportTabularLVLI.pas +++ b/Edit scripts/ExportTabularLVLI.pas @@ -8,20 +8,20 @@ var ExportTabularLVLI_outputLines: TStringList; var ExportTabularLOC_outputLines: TStringList; -function initialize: Integer; + +function initialize(): Integer; begin ExportTabularLVLI_outputLines := TStringList.create(); ExportTabularLVLI_outputLines.add( - '"File"' // Name of the originating ESM - + ', "Form ID"' // Form ID - + ', "Editor ID"' // Editor ID - + ', "Name"' // Full name - + ', "Leveled List"' // Leveled list + '"File"' // Name of the originating ESM + + ', "Form ID"' // Form ID + + ', "Editor ID"' // Editor ID + + ', "Name"' // Full name + + ', "Leveled List"' // Leveled list ); - - + + ExportTabularLOC_outputLines := initializeLocationTabular(); - end; function canProcess(e: IInterface): Boolean; @@ -33,32 +33,23 @@ function process(lvli: IInterface): Integer; var data: IInterface; begin if not canProcess(lvli) then begin - addMessage('Warning: ' + name(lvli) + ' is not a LVLI. Entry was ignored.'); + addWarning(name(lvli) + ' is not a LVLI. Entry was ignored.'); exit; end; data := eBySign(lvli, 'DATA'); - //debugPrint(evBySign(lvli, 'LVLF')); - //debugPrint(evByName(lvli, 'Leveled List Entries')); ExportTabularLVLI_outputLines.add( escapeCsvString(getFileName(getFile(lvli))) + ', ' + escapeCsvString(stringFormID(lvli)) + ', ' + escapeCsvString(evBySign(lvli, 'EDID')) + ', ' + escapeCsvString(evBySign(lvli, 'FULL')) + ', ' - //https://github.com/fireundubh/xedit-scripts/blob/master/all/Relevel%20Leveled%20Lists.pas + escapeCsvString(getJsonLeveledListArray(lvli)) - - ); - - ExportTabularLOC_outputLines.AddStrings( - getLocationData(lvli) ); - -end; - + ExportTabularLOC_outputLines.addStrings(getLocationData(lvli)); +end; -function finalize: Integer; +function finalize(): Integer; begin createDir('dumps/'); ExportTabularLVLI_outputLines.saveToFile('dumps/LVLI.csv'); From 229f15a9134f9578b5c9bbbc3d188a03349bb28b Mon Sep 17 00:00:00 2001 From: "Felix W. Dekker" Date: Mon, 28 Sep 2020 00:09:49 +0200 Subject: [PATCH 4/5] Include more FLOR info, clean up WEAP --- Edit scripts/ExportAll.pas | 35 ++++++++++++++- Edit scripts/ExportJson.pas | 2 +- Edit scripts/ExportTabularARMO.pas | 50 +++++++++------------ Edit scripts/ExportTabularCLAS.pas | 12 ++--- Edit scripts/ExportTabularFLOR.pas | 66 +++++++++++++++++++++++++++ Edit scripts/ExportTabularFLORA.pas | 70 ----------------------------- Edit scripts/ExportTabularLVLI.pas | 2 +- Edit scripts/ExportTabularNPC_.pas | 2 +- Edit scripts/ExportTabularRACE.pas | 14 +++--- Edit scripts/ExportTabularWEAP.pas | 60 +++++++++++-------------- README.md | 3 ++ 11 files changed, 168 insertions(+), 148 deletions(-) create mode 100644 Edit scripts/ExportTabularFLOR.pas delete mode 100644 Edit scripts/ExportTabularFLORA.pas diff --git a/Edit scripts/ExportAll.pas b/Edit scripts/ExportAll.pas index 30d907c..5eb3d14 100644 --- a/Edit scripts/ExportAll.pas +++ b/Edit scripts/ExportAll.pas @@ -8,13 +8,16 @@ ExportTabularCOBJ, ExportTabularENTM, ExportTabularFACT, + ExportTabularFLOR, ExportTabularGLOB, ExportTabularGMST, ExportTabularIDs, + ExportTabularLVLI, ExportTabularMISC, ExportTabularNPC_, ExportTabularOTFT, ExportTabularRACE, + ExportTabularWEAP, ExportWikiBOOK, ExportWikiDIAL, ExportWikiNOTE, @@ -42,18 +45,21 @@ function _selectDumps(): TStringList; form.caption := 'Select dump scripts'; clb := TCheckListBox(form.findComponent('CheckListBox1')); - clb.items.add('IDs.csv'); clb.items.add('ARMO.csv'); clb.items.add('CLAS.csv'); clb.items.add('COBJ.csv'); clb.items.add('ENTM.csv'); clb.items.add('FACT.csv'); + clb.items.add('FLOR.csv'); clb.items.add('GLOB.csv'); clb.items.add('GMST.csv'); + clb.items.add('IDs.csv'); + clb.items.add('LVLI.csv'); clb.items.add('MISC.csv'); clb.items.add('NPC_.csv'); clb.items.add('OTFT.csv'); clb.items.add('RACE.csv'); + clb.items.add('WEAP.csv'); clb.items.add('BOOK.wiki'); clb.items.add('DIAL.wiki'); clb.items.add('NOTE.wiki'); @@ -111,6 +117,9 @@ function initialize(): Integer; if _hasSelectedDump('FACT.csv') then begin ExportTabularFACT.initialize(); end; + if _hasSelectedDump('FLOR.csv') then begin + ExportTabularFLOR.initialize(); + end; if _hasSelectedDump('GLOB.csv') then begin ExportTabularGLOB.initialize(); end; @@ -120,6 +129,9 @@ function initialize(): Integer; if _hasSelectedDump('IDs.csv') then begin ExportTabularIDs.initialize(); end; + if _hasSelectedDump('LVLI.csv') then begin + ExportTabularLVLI.initialize(); + end; if _hasSelectedDump('MISC.csv') then begin ExportTabularMISC.initialize(); end; @@ -132,6 +144,9 @@ function initialize(): Integer; if _hasSelectedDump('RACE.csv') then begin ExportTabularRACE.initialize(); end; + if _hasSelectedDump('WEAP.csv') then begin + ExportTabularWEAP.initialize(); + end; if _hasSelectedDump('BOOK.wiki') then begin ExportWikiBOOK.initialize(); end; @@ -163,6 +178,9 @@ function process(e: IInterface): Integer; if _hasSelectedDump('FACT.csv') and ExportTabularFACT.canProcess(e) then begin ExportTabularFACT.process(e); end; + if _hasSelectedDump('FLOR.csv') and ExportTabularFLOR.canProcess(e) then begin + ExportTabularFLOR.process(e); + end; if _hasSelectedDump('GLOB.csv') and ExportTabularGLOB.canProcess(e) then begin ExportTabularGLOB.process(e); end; @@ -172,6 +190,9 @@ function process(e: IInterface): Integer; if _hasSelectedDump('IDs.csv') and ExportTabularIDs.canProcess(e) then begin ExportTabularIDs.process(e); end; + if _hasSelectedDump('LVLI.csv') and ExportTabularLVLI.canProcess(e) then begin + ExportTabularLVLI.process(e); + end; if _hasSelectedDump('MISC.csv') and ExportTabularMISC.canProcess(e) then begin ExportTabularMISC.process(e); end; @@ -184,6 +205,9 @@ function process(e: IInterface): Integer; if _hasSelectedDump('RACE.csv') and ExportTabularRACE.canProcess(e) then begin ExportTabularRACE.process(e); end; + if _hasSelectedDump('WEAP.csv') and ExportTabularWEAP.canProcess(e) then begin + ExportTabularWEAP.process(e); + end; if _hasSelectedDump('BOOK.wiki') and ExportWikiBOOK.canProcess(e) then begin ExportWikiBOOK.process(e); end; @@ -216,6 +240,9 @@ function finalize(): Integer; if _hasSelectedDump('FACT.csv') then begin ExportTabularFACT.finalize(); end; + if _hasSelectedDump('FLOR.csv') then begin + ExportTabularFLOR.finalize(); + end; if _hasSelectedDump('GLOB.csv') then begin ExportTabularGLOB.finalize(); end; @@ -225,6 +252,9 @@ function finalize(): Integer; if _hasSelectedDump('IDs.csv') then begin ExportTabularIDs.finalize(); end; + if _hasSelectedDump('LVLI.csv') then begin + ExportTabularLVLI.finalize(); + end; if _hasSelectedDump('MISC.csv') then begin ExportTabularMISC.finalize(); end; @@ -237,6 +267,9 @@ function finalize(): Integer; if _hasSelectedDump('RACE.csv') then begin ExportTabularRACE.finalize(); end; + if _hasSelectedDump('WEAP.csv') then begin + ExportTabularWEAP.finalize(); + end; if _hasSelectedDump('BOOK.wiki') then begin ExportWikiBOOK.finalize(); end; diff --git a/Edit scripts/ExportJson.pas b/Edit scripts/ExportJson.pas index 0447004..edb4a48 100644 --- a/Edit scripts/ExportJson.pas +++ b/Edit scripts/ExportJson.pas @@ -57,7 +57,7 @@ function stringListToJsonArray(list: TStringList): String; var i: Integer; begin for i := 0 to list.count - 1 do begin - list[i] = '"' + escapeQuotes(list[i]) + '"'; + list[i] := '"' + escapeQuotes(list[i]) + '"'; end; result := listToJsonArray(list); end; diff --git a/Edit scripts/ExportTabularARMO.pas b/Edit scripts/ExportTabularARMO.pas index a51a833..df76c98 100644 --- a/Edit scripts/ExportTabularARMO.pas +++ b/Edit scripts/ExportTabularARMO.pas @@ -8,31 +8,30 @@ var ExportTabularARMO_outputLines: TStringList; var ExportTabularLOC_outputLines: TStringList; -function initialize: Integer; + +function initialize(): Integer; begin ExportTabularARMO_outputLines := TStringList.create(); ExportTabularARMO_outputLines.add( - '"File"' // Name of the originating ESM - + ', "Form ID"' // Form ID - + ', "Editor ID"' // Editor ID - + ', "Name"' // Full name - + ', "Weight"' // Item weight in pounds - + ', "Value"' // Item value in bottlecaps - + ', "Health"' // Item health in points - + ', "Race"' // The race that can wear this armor - + ', "Levels"' // Sorted JSON array of possible armor levels - + ', "DR curve"' // Damage Resistance curve - + ', "Durability min curve"' // Min durability curve - + ', "Durability max curve"' // Max durability curve - + ', "Condition dmg curve"' // Condition damage scale factor curve - + ', "Attach slots"' // Sorted JSON array of attachment slots available to the armor - + ', "Equip slots"' // Sorted JSON array of equipment slots used by the armor - + ', "Keywords"' // Sorted JSON array of keywords. Each keyword is represented by its editor ID + '"File"' // Name of the originating ESM + + ', "Form ID"' // Form ID + + ', "Editor ID"' // Editor ID + + ', "Name"' // Full name + + ', "Weight"' // Item weight in pounds + + ', "Value"' // Item value in bottlecaps + + ', "Health"' // Item health in points + + ', "Race"' // Race that can wear this armor + + ', "Levels"' // Sorted JSON array of possible armor levels + + ', "DR curve"' // Damage Resistance curve + + ', "Durability min curve"' // Min durability curve + + ', "Durability max curve"' // Max durability curve + + ', "Condition dmg curve"' // Condition damage scale factor curve + + ', "Attach slots"' // Sorted JSON array of attachment slots available to the armor + + ', "Equip slots"' // Sorted JSON array of equipment slots used by the armor + + ', "Keywords"' // Sorted JSON array of keywords. Each keyword is represented by its editor ID ); - - + ExportTabularLOC_outputLines := initializeLocationTabular(); - end; function canProcess(e: IInterface): Boolean; @@ -68,16 +67,11 @@ function process(armo: IInterface): Integer; + escapeCsvString(getJsonChildNameArray(eByIndex(eBySign(armo, 'BOD2'), 0))) + ', ' + escapeCsvString(getJsonKeywordArray(armo)) ); - - ExportTabularLOC_outputLines.AddStrings( - getLocationData(armo) - ); - -end; - + ExportTabularLOC_outputLines.AddStrings(getLocationData(armo)); +end; -function finalize: Integer; +function finalize(): Integer; begin createDir('dumps/'); ExportTabularARMO_outputLines.saveToFile('dumps/ARMO.csv'); diff --git a/Edit scripts/ExportTabularCLAS.pas b/Edit scripts/ExportTabularCLAS.pas index 907022d..31256ff 100644 --- a/Edit scripts/ExportTabularCLAS.pas +++ b/Edit scripts/ExportTabularCLAS.pas @@ -12,11 +12,11 @@ function initialize: Integer; begin ExportTabularCLAS_outputLines := TStringList.create(); ExportTabularCLAS_outputLines.add( - '"File"' // Name of the originating ESM - + ', "Form ID"' // Form ID - + ', "Editor ID"' // Editor ID - + ', "Name"' // Full name - + ', "Properties"' // Sorted JSON array of properties. Each property is formatted as `[key]=[value]` + '"File"' // Name of the originating ESM + + ', "Form ID"' // Form ID + + ', "Editor ID"' // Editor ID + + ', "Name"' // Full name + + ', "Properties"' // Sorted JSON object of properties ); end; @@ -46,7 +46,7 @@ function process(clas: IInterface): Integer; + escapeCsvString(stringFormID(clas)) + ', ' + escapeCsvString(evBySign(clas, 'EDID')) + ', ' + escapeCsvString(evBySign(clas, 'FULL')) + ', ' - + escapeCsvString(getJsonPropertyArray(clas)) + + escapeCsvString(getJsonPropertyObject(clas)) ); end; diff --git a/Edit scripts/ExportTabularFLOR.pas b/Edit scripts/ExportTabularFLOR.pas new file mode 100644 index 0000000..1e07ba5 --- /dev/null +++ b/Edit scripts/ExportTabularFLOR.pas @@ -0,0 +1,66 @@ +unit ExportTabularFLOR; + +uses ExportCore, + ExportTabularCore, + ExportJson; + + +var ExportTabularFLOR_outputLines: TStringList; +var ExportTabularLOC_outputLines: TStringList; + + +function initialize(): Integer; +begin + ExportTabularFLOR_outputLines := TStringList.create(); + ExportTabularFLOR_outputLines.add( + '"File"' // Name of the originating ESM + + ', "Form ID"' // Form ID + + ', "Editor ID"' // Editor ID + + ', "Name"' // Full name + + ', "Ingredient"' // Item obtained when harvested + + ', "Keywords"' // Sorted JSON array of keywords. Each keyword is represented by its editor ID + + ', "Properties"' // Sorted JSON object of properties + ); + + ExportTabularLOC_outputLines := initializeLocationTabular(); +end; + +function canProcess(e: IInterface): Boolean; +begin + result := signature(e) = 'FLOR'; +end; + +function process(flora: IInterface): Integer; +var data: IInterface; +begin + if not canProcess(flora) then begin + addWarning(name(flora) + ' is not a FLOR. Entry was ignored.'); + exit; + end; + + data := eBySign(flora, 'DATA'); + + ExportTabularFLOR_outputLines.add( + escapeCsvString(getFileName(getFile(flora))) + ', ' + + escapeCsvString(stringFormID(flora)) + ', ' + + escapeCsvString(evBySign(flora, 'EDID')) + ', ' + + escapeCsvString(evBySign(flora, 'FULL')) + ', ' + + escapeCsvString(evByName(flora, 'PFIG')) + ', ' + + escapeCsvString(getJsonKeywordArray(flora)) + ', ' + + escapeCsvString(getJsonPropertyObject(flora)) + ); + + ExportTabularLOC_outputLines.addStrings(getLocationData(flora)); +end; + +function finalize(): Integer; +begin + createDir('dumps/'); + ExportTabularFLOR_outputLines.saveToFile('dumps/FLOR.csv'); + ExportTabularLOC_outputLines.saveToFile('dumps/FLOR_LOC.csv'); + ExportTabularLOC_outputLines.free(); + ExportTabularFLOR_outputLines.free(); +end; + + +end. diff --git a/Edit scripts/ExportTabularFLORA.pas b/Edit scripts/ExportTabularFLORA.pas deleted file mode 100644 index 1a1c7b3..0000000 --- a/Edit scripts/ExportTabularFLORA.pas +++ /dev/null @@ -1,70 +0,0 @@ -unit ExportTabularFLORA; - -uses ExportCore, - ExportTabularCore, - ExportJson; - - -var ExportTabularFLORA_outputLines: TStringList; -var ExportTabularLOC_outputLines: TStringList; - -function initialize: Integer; -begin - ExportTabularFLORA_outputLines := TStringList.create(); - ExportTabularFLORA_outputLines.add( - '"File"' // Name of the originating ESM - + ', "Form ID"' // Form ID - + ', "Editor ID"' // Editor ID - + ', "Name"' // Full name - + ', "Ingredient"' // Item weight in pounds - + ', "Keywords"' // Sorted JSON array of keywords. Each keyword is represented by its editor ID - ); - - - ExportTabularLOC_outputLines := initializeLocationTabular(); - -end; - -function canProcess(e: IInterface): Boolean; -begin - result := signature(e) = 'FLOR'; -end; - -function process(flora: IInterface): Integer; -var data: IInterface; -begin - if not canProcess(flora) then begin - addMessage('Warning: ' + name(flora) + ' is not a FLORA. Entry was ignored.'); - exit; - end; - - data := eBySign(flora, 'DATA'); - - ExportTabularFLORA_outputLines.add( - escapeCsvString(getFileName(getFile(flora))) + ', ' - + escapeCsvString(stringFormID(flora)) + ', ' - + escapeCsvString(evBySign(flora, 'EDID')) + ', ' - + escapeCsvString(evBySign(flora, 'FULL')) + ', ' - + escapeCsvString(evByName(flora, 'PFIG')) + ', ' - + escapeCsvString(getFlatKeywordList(flora)) - ); - - ExportTabularLOC_outputLines.AddStrings( - getLocationData(flora) - ); - -end; - - - -function finalize: Integer; -begin - createDir('dumps/'); - ExportTabularFLORA_outputLines.saveToFile('dumps/FLORA.csv'); - ExportTabularLOC_outputLines.saveToFile('dumps/FLORALOC.csv'); - ExportTabularLOC_outputLines.free(); - ExportTabularFLORA_outputLines.free(); -end; - - -end. diff --git a/Edit scripts/ExportTabularLVLI.pas b/Edit scripts/ExportTabularLVLI.pas index 9b0b02e..dffb7fd 100644 --- a/Edit scripts/ExportTabularLVLI.pas +++ b/Edit scripts/ExportTabularLVLI.pas @@ -53,7 +53,7 @@ function finalize(): Integer; begin createDir('dumps/'); ExportTabularLVLI_outputLines.saveToFile('dumps/LVLI.csv'); - ExportTabularLOC_outputLines.saveToFile('dumps/LVLILOC.csv'); + ExportTabularLOC_outputLines.saveToFile('dumps/LVLI_LOC.csv'); ExportTabularLOC_outputLines.free(); ExportTabularLVLI_outputLines.free(); end; diff --git a/Edit scripts/ExportTabularNPC_.pas b/Edit scripts/ExportTabularNPC_.pas index d7290e0..9c78fe6 100644 --- a/Edit scripts/ExportTabularNPC_.pas +++ b/Edit scripts/ExportTabularNPC_.pas @@ -24,7 +24,7 @@ function initialize: Integer; + ', "Class"' // Class, formatted as ` "" [:
]` + ', "Keywords"' // Sorted JSON array of keywords. Each keyword is represented by its editor ID + ', "Perks"' // Sorted JSON array of perks. Each perk is formatted as `=[value]` - + ', "Properties"' // Sorted JSON array of properties. Each property is formatted as `=[value]` + + ', "Properties"' // Sorted JSON object of properties + ', "Aggression"' // AI aggression level as a string + ', "Confidence"' // AI confidence level as a string + ', "Assistance"' // AI assistance level as a string diff --git a/Edit scripts/ExportTabularRACE.pas b/Edit scripts/ExportTabularRACE.pas index 25f3495..18a2ac2 100644 --- a/Edit scripts/ExportTabularRACE.pas +++ b/Edit scripts/ExportTabularRACE.pas @@ -12,12 +12,12 @@ function initialize: Integer; begin ExportTabularRACE_outputLines := TStringList.create(); ExportTabularRACE_outputLines.add( - '"File"' // Name of the originating ESM - + ', "Form ID"' // Form ID - + ', "Editor ID"' // Editor ID - + ', "Name"' // Full name - + ', "Keywords"' // Sorted JSON array of keywords. Each keyword is represented by its editor ID - + ', "Properties"' // Sorted JSON array of properties. Each property is formatted as `[editor id]=[value]` + '"File"' // Name of the originating ESM + + ', "Form ID"' // Form ID + + ', "Editor ID"' // Editor ID + + ', "Name"' // Full name + + ', "Keywords"' // Sorted JSON array of keywords. Each keyword is represented by its editor ID + + ', "Properties"' // Sorted JSON object of properties ); end; @@ -48,7 +48,7 @@ function process(race: IInterface): Integer; + escapeCsvString(evBySign(race, 'EDID')) + ', ' + escapeCsvString(evBySign(race, 'FULL')) + ', ' + escapeCsvString(getJsonKeywordArray(race)) + ', ' - + escapeCsvString(getJsonPropertyArray(race)) + + escapeCsvString(getJsonPropertyObject(race)) ); end; diff --git a/Edit scripts/ExportTabularWEAP.pas b/Edit scripts/ExportTabularWEAP.pas index aa174fa..a6f9db5 100644 --- a/Edit scripts/ExportTabularWEAP.pas +++ b/Edit scripts/ExportTabularWEAP.pas @@ -8,31 +8,30 @@ var ExportTabularWEAP_outputLines: TStringList; var ExportTabularLOC_outputLines: TStringList; -function initialize: Integer; + +function initialize(): Integer; begin ExportTabularWEAP_outputLines := TStringList.create(); ExportTabularWEAP_outputLines.add( - '"File"' // Name of the originating ESM - + ', "Form ID"' // Form ID - + ', "Editor ID"' // Editor ID - + ', "Name"' // Full name - + ', "Weight"' // Item weight in pounds - + ', "Value"' // Item value in bottlecaps - + ', "Health"' // Item health in points - + ', "Race"' // The race that can wear this weapr - + ', "Levels"' // Sorted JSON array of possible weapr levels - + ', "DR curve"' // Damage Resistance curve - + ', "Durability min curve"' // Min durability curve - + ', "Durability max curve"' // Max durability curve - + ', "Condition dmg curve"' // Condition damage scale factor curve - + ', "Attach slots"' // Sorted JSON array of attachment slots available to the weapr - + ', "Equip slots"' // Sorted JSON array of equipment slots used by the weapr - + ', "Keywords"' // Sorted JSON array of keywords. Each keyword is represented by its editor ID + '"File"' // Name of the originating ESM + + ', "Form ID"' // Form ID + + ', "Editor ID"' // Editor ID + + ', "Name"' // Full name + + ', "Weight"' // Item weight in pounds + + ', "Value"' // Item value in bottlecaps + + ', "Health"' // Item health in points + + ', "Race"' // Race that can equip this weapon + + ', "Levels"' // Sorted JSON array of possible weapon levels + + ', "DR curve"' // Damage Resistance curve + + ', "Durability min curve"' // Min durability curve + + ', "Durability max curve"' // Max durability curve + + ', "Condition dmg curve"' // Condition damage scale factor curve + + ', "Attach slots"' // Sorted JSON array of attachment slots available to the weapon + + ', "Equip slots"' // Sorted JSON array of equipment slots used by the weapon + + ', "Keywords"' // Sorted JSON array of keywords. Each keyword is represented by its editor ID ); - - + ExportTabularLOC_outputLines := initializeLocationTabular(); - end; function canProcess(e: IInterface): Boolean; @@ -44,7 +43,7 @@ function process(weap: IInterface): Integer; var data: IInterface; begin if not canProcess(weap) then begin - addMessage('Warning: ' + name(weap) + ' is not a WEAP. Entry was ignored.'); + addWarning(name(weap) + ' is not a WEAP. Entry was ignored.'); exit; end; @@ -59,25 +58,20 @@ function process(weap: IInterface): Integer; + escapeCsvString(evByName(data, 'Value')) + ', ' + escapeCsvString(evByName(data, 'Health')) + ', ' + escapeCsvString(evBySign(weap, 'RNAM')) + ', ' - + escapeCsvString(getFlatChildList(eBySign(weap, 'EILV'))) + ',' + + escapeCsvString(getJsonChildArray(eBySign(weap, 'EILV'))) + ',' + escapeCsvString(evBySign(weap, 'CVT0')) + ',' + escapeCsvString(evBySign(weap, 'CVT1')) + ',' + escapeCsvString(evBySign(weap, 'CVT3')) + ',' + escapeCsvString(evBySign(weap, 'CVT2')) + ',' - + escapeCsvString(getFlatChildList(eBySign(weap, 'APPR'))) + ',' - + escapeCsvString(getFlatChildNameList(eByIndex(eBySign(weap, 'BOD2'), 0))) + ', ' - + escapeCsvString(getFlatKeywordList(weap)) - ); - - ExportTabularLOC_outputLines.AddStrings( - getLocationData(weap) + + escapeCsvString(getJsonChildArray(eBySign(weap, 'APPR'))) + ',' + + escapeCsvString(getJsonChildNameArray(eByIndex(eBySign(weap, 'BOD2'), 0))) + ', ' + + escapeCsvString(getJsonKeywordArray(weap)) ); - -end; - + ExportTabularLOC_outputLines.AddStrings(getLocationData(weap)); +end; -function finalize: Integer; +function finalize(): Integer; begin createDir('dumps/'); ExportTabularWEAP_outputLines.saveToFile('dumps/WEAP.csv'); diff --git a/README.md b/README.md index 1e08977..b4ce873 100644 --- a/README.md +++ b/README.md @@ -23,12 +23,15 @@ For more information on how to browse them, check [the wiki page](https://github | [`ExportTabularCOBJ.pas`](Edit%20scripts/ExportTabularCOBJ.pas) | `COBJ.csv` | Craftable object recipes and components | | [`ExportTabularENTM.pas`](Edit%20scripts/ExportTabularENTM.pas) | `ENTM.csv` | Atomic Shop unlockables | | [`ExportTabularFACT.pas`](Edit%20scripts/ExportTabularFACT.pas) | `FACT.csv` | Factions and vendors | +| [`ExportTabularFLOR.pas`](Edit%20scripts/ExportTabularFLOR.pas) | `FLOR.csv` | Harvestable plants | | [`ExportTabularGLOB.pas`](Edit%20scripts/ExportTabularGLOB.pas) | `GLOB.csv` | Global variables | | [`ExportTabularGMST.pas`](Edit%20scripts/ExportTabularGMST.pas) | `GMST.csv` | Game settings | +| [`ExportTabularLVLI.pas`](Edit%20scripts/ExportTabularLVLI.pas) | `LVLI.csv` | Leveled lists | | [`ExportTabularMISC.pas`](Edit%20scripts/ExportTabularMISC.pas) | `MISC.csv` | Inventory item weights, values, and scrap yields | | [`ExportTabularNPC_.pas`](Edit%20scripts/ExportTabularNPC_.pas) | `NPC_.csv` | NPC factions, keywords, stats, etc. | | [`ExportTabularOTFT.pas`](Edit%20scripts/ExportTabularOTFT.pas) | `OTFT.csv` | Outfits | | [`ExportTabularRACE.pas`](Edit%20scripts/ExportTabularRACE.pas) | `RACE.csv` | Race keywords and properties | +| [`ExportTabularWEAP.pas`](Edit%20scripts/ExportTabularWEAP.pas) | `WEAP.csv` | Weapons |

From d346315f967585363d23cac805af1cc386da693c Mon Sep 17 00:00:00 2001 From: "Felix W. Dekker" Date: Mon, 28 Sep 2020 00:59:11 +0200 Subject: [PATCH 5/5] Overhaul location dump code --- Edit scripts/ExportAll.pas | 5 +- Edit scripts/ExportCore.pas | 93 ------------------------------ Edit scripts/ExportTabularARMO.pas | 15 +++-- Edit scripts/ExportTabularFACT.pas | 12 ++-- Edit scripts/ExportTabularFLOR.pas | 37 ++++++------ Edit scripts/ExportTabularLOC.pas | 75 ++++++++++++++++++++++++ Edit scripts/ExportTabularLVLI.pas | 16 ++--- Edit scripts/ExportTabularMISC.pas | 43 +++++++------- Edit scripts/ExportTabularWEAP.pas | 16 +++-- README.md | 7 +++ 10 files changed, 160 insertions(+), 159 deletions(-) create mode 100644 Edit scripts/ExportTabularLOC.pas diff --git a/Edit scripts/ExportAll.pas b/Edit scripts/ExportAll.pas index 5eb3d14..e7314e5 100644 --- a/Edit scripts/ExportAll.pas +++ b/Edit scripts/ExportAll.pas @@ -65,13 +65,12 @@ function _selectDumps(): TStringList; clb.items.add('NOTE.wiki'); clb.items.add('TERM.wiki'); - for i := 0 to pred(clb.items.count) do begin - clb.checked[i] := true; - end; + // Show form if form.showModal() <> mrOk then begin exit; end; + // Process input for i := 0 to pred(clb.items.count) do begin if clb.checked[i] then begin result.add(clb.items[i]); diff --git a/Edit scripts/ExportCore.pas b/Edit scripts/ExportCore.pas index a822eb6..7596da2 100644 --- a/Edit scripts/ExportCore.pas +++ b/Edit scripts/ExportCore.pas @@ -349,98 +349,5 @@ function parseFloatToInt(float: String): String; result := intToStr(round(strToFloat(float))); end; -function getReferenceByIndexAndSig(e: IInterface; i: Integer; sig: String): IwbElement; -var ref: IwbElement; -begin - ref := referencedByIndex(e, i); - if signature(ref) = sig then begin - result := ref; - exit; - end; -end; - -function getLocationData(e: IInterface): TStringList; -var ExportTabularLOC_outputLines: TStringList; -var ref: IwbElement; -var i: Integer; - -var data: IInterface; -var cell: IInterface; -var worldspace: IInterface; -begin - ExportTabularLOC_outputLines := TStringList.create(); - - for i := 0 to referencedByCount(e) - 1 do begin - - ref := getReferenceByIndexAndSig(e,i,'REFR'); - - if isRefLocation(ref) then begin - // we only want the ones in the Appalachia worldspace - data := ElementBySignature(ref, 'DATA'); - - ExportTabularLOC_outputLines.add( - escapeCsvString(getFileName(getFile(ref))) + ', ' - + escapeCsvString(stringFormID(ref)) + ', ' - + escapeCsvString(evBySign(e, 'EDID')) + ', ' - + escapeCsvString(evBySign(e, 'FULL')) + ', ' - + escapeCsvString(evBySign(ref, 'XLYR')) + ', ' - + escapeCsvString(gev(ElementByName(ref, 'Cell'))) + ', ' - + escapeCsvString(vec3ToString(ElementByName(data,'Position'))) + ', ' - + escapeCsvString(vec3ToString(ElementByName(data,'Rotation'))) - ); - end; - end; - - result := ExportTabularLOC_outputLines; -end; - -function initializeLocationTabular(): TStringList; -var ExportTabularLOC_outputLines: TStringList; -begin - ExportTabularLOC_outputLines := TStringList.create(); - ExportTabularLOC_outputLines.add( - '"File"' // Name of the originating ESM - + ', "Form ID"' // Form ID - + ', "Editor ID"' // Editor ID of item - + ', "Name"' // Full name of item - + ', "Layer"' // Layer the reference is linked to - + ', "Cell"' // World Cell - + ', "Position"' // Vector3 Position - + ', "Rotation"' // Vector3 Rotation - ); - result := ExportTabularLOC_outputLines; -end; - -function vec3ToString(e: IInterface): String; -begin - result := gev(ElementByName(e,'X')) + ':' + gev(ElementByName(e,'Y')) + ':' + gev(ElementByName(e,'Z')); -end; - -function debugPrint(e: IInterface): Boolean; -var i: Integer; -var ei: IwbElement; -begin - for i := 0 to ElementCount(e) - 1 do begin - ei := ElementByIndex(e,i); - addMessage('Found: ' + name(ei) + ' sig: ' + Signature(ei) + ' name: ' + gev(ei)); - - end; - result := True; -end; - -function isRefLocation(e: IInterface): Boolean; -var data: IInterface; -begin - result := false; - - data := eBySign(e, 'DATA'); - if (signature(e) = 'REFR') AND ElementExists(data,'Position') then begin - result := True; - exit; - end; - -end; - - end. diff --git a/Edit scripts/ExportTabularARMO.pas b/Edit scripts/ExportTabularARMO.pas index df76c98..93bf4cf 100644 --- a/Edit scripts/ExportTabularARMO.pas +++ b/Edit scripts/ExportTabularARMO.pas @@ -2,11 +2,12 @@ uses ExportCore, ExportTabularCore, - ExportJson; + ExportJson, + ExportTabularLOC; var ExportTabularARMO_outputLines: TStringList; -var ExportTabularLOC_outputLines: TStringList; +var ExportTabularARMO_LOC_outputLines: TStringList; function initialize(): Integer; @@ -31,7 +32,7 @@ function initialize(): Integer; + ', "Keywords"' // Sorted JSON array of keywords. Each keyword is represented by its editor ID ); - ExportTabularLOC_outputLines := initializeLocationTabular(); + ExportTabularARMO_LOC_outputLines := initLocList(); end; function canProcess(e: IInterface): Boolean; @@ -68,16 +69,18 @@ function process(armo: IInterface): Integer; + escapeCsvString(getJsonKeywordArray(armo)) ); - ExportTabularLOC_outputLines.AddStrings(getLocationData(armo)); + appendLocationData(ExportTabularARMO_LOC_outputLines, armo); end; function finalize(): Integer; begin createDir('dumps/'); + ExportTabularARMO_outputLines.saveToFile('dumps/ARMO.csv'); - ExportTabularLOC_outputLines.saveToFile('dumps/ARMOLOC.csv'); - ExportTabularLOC_outputLines.free(); ExportTabularARMO_outputLines.free(); + + ExportTabularARMO_LOC_outputLines.saveToFile('dumps/ARMO_LOC.csv'); + ExportTabularARMO_LOC_outputLines.free(); end; diff --git a/Edit scripts/ExportTabularFACT.pas b/Edit scripts/ExportTabularFACT.pas index 051ed84..3dd6de7 100644 --- a/Edit scripts/ExportTabularFACT.pas +++ b/Edit scripts/ExportTabularFACT.pas @@ -62,7 +62,7 @@ function process(fact: IInterface): Integer; + escapeCsvString(stringFormID(fact)) + ', ' + escapeCsvString(evBySign(fact, 'EDID')) + ', ' + escapeCsvString(evBySign(fact, 'FULL')) + ', ' - + escapeCsvString(getFlatRelationList(fact)) + ', '; + + escapeCsvString(getJsonRelationArray(fact)) + ', '; if assigned(venc) then begin outputString := outputString @@ -73,7 +73,7 @@ function process(fact: IInterface): Integer; + escapeCsvString(evByPath(venv, 'Buys Stolen Items')) + ', ' + escapeCsvString(evByPath(venv, 'Buys NonStolen Items')) + ', ' + escapeCsvString(evByPath(venv, 'Buy/Sell Everything Not In List?')) + ', ' - + escapeCsvString(getFlatContainerItemList(linkBySign(linkBySign(fact, 'VENC'), 'NAME'))); + + escapeCsvString(getJsonContainerItemArray(linkBySign(linkBySign(fact, 'VENC'), 'NAME'))); end else begin outputString := outputString + '"False", ' @@ -103,7 +103,7 @@ function finalize: Integer; * @param fact the faction to return relations of * @return a JSON array string of all relations that [fact] has to other factions *) -function getFlatRelationList(fact: IInterface): String; +function getJsonRelationArray(fact: IInterface): String; var i: Integer; relations: IInterface; relation: IInterface; @@ -124,7 +124,7 @@ function getFlatRelationList(fact: IInterface): String; end; resultList.sort(); - result := listToJson(resultList); + result := stringListToJsonArray(resultList); resultList.free(); end; @@ -134,7 +134,7 @@ function getFlatRelationList(fact: IInterface): String; * @param cont the container to return all items from * @return a JSON array string of all items in [cont] *) -function getFlatContainerItemList(cont: IInterface): String; +function getJsonContainerItemArray(cont: IInterface): String; var i: Integer; entries: IInterface; entry: IInterface; @@ -158,7 +158,7 @@ function getFlatContainerItemList(cont: IInterface): String; end; itemHistory.sort(); - result := listToJson(itemHistory); + result := stringListToJsonArray(itemHistory); lvliHistory.free(); itemHistory.free(); diff --git a/Edit scripts/ExportTabularFLOR.pas b/Edit scripts/ExportTabularFLOR.pas index 1e07ba5..38d80c3 100644 --- a/Edit scripts/ExportTabularFLOR.pas +++ b/Edit scripts/ExportTabularFLOR.pas @@ -2,11 +2,12 @@ uses ExportCore, ExportTabularCore, - ExportJson; + ExportJson, + ExportTabularLOC; var ExportTabularFLOR_outputLines: TStringList; -var ExportTabularLOC_outputLines: TStringList; +var ExportTabularFLOR_LOC_outputLines: TStringList; function initialize(): Integer; @@ -22,7 +23,7 @@ function initialize(): Integer; + ', "Properties"' // Sorted JSON object of properties ); - ExportTabularLOC_outputLines := initializeLocationTabular(); + ExportTabularFLOR_LOC_outputLines := initLocList(); end; function canProcess(e: IInterface): Boolean; @@ -30,36 +31,38 @@ function canProcess(e: IInterface): Boolean; result := signature(e) = 'FLOR'; end; -function process(flora: IInterface): Integer; +function process(flor: IInterface): Integer; var data: IInterface; begin - if not canProcess(flora) then begin - addWarning(name(flora) + ' is not a FLOR. Entry was ignored.'); + if not canProcess(flor) then begin + addWarning(name(flor) + ' is not a FLOR. Entry was ignored.'); exit; end; - data := eBySign(flora, 'DATA'); + data := eBySign(flor, 'DATA'); ExportTabularFLOR_outputLines.add( - escapeCsvString(getFileName(getFile(flora))) + ', ' - + escapeCsvString(stringFormID(flora)) + ', ' - + escapeCsvString(evBySign(flora, 'EDID')) + ', ' - + escapeCsvString(evBySign(flora, 'FULL')) + ', ' - + escapeCsvString(evByName(flora, 'PFIG')) + ', ' - + escapeCsvString(getJsonKeywordArray(flora)) + ', ' - + escapeCsvString(getJsonPropertyObject(flora)) + escapeCsvString(getFileName(getFile(flor))) + ', ' + + escapeCsvString(stringFormID(flor)) + ', ' + + escapeCsvString(evBySign(flor, 'EDID')) + ', ' + + escapeCsvString(evBySign(flor, 'FULL')) + ', ' + + escapeCsvString(evByName(flor, 'PFIG')) + ', ' + + escapeCsvString(getJsonKeywordArray(flor)) + ', ' + + escapeCsvString(getJsonPropertyObject(flor)) ); - ExportTabularLOC_outputLines.addStrings(getLocationData(flora)); + appendLocationData(ExportTabularFLOR_LOC_outputLines, flor); end; function finalize(): Integer; begin createDir('dumps/'); + ExportTabularFLOR_outputLines.saveToFile('dumps/FLOR.csv'); - ExportTabularLOC_outputLines.saveToFile('dumps/FLOR_LOC.csv'); - ExportTabularLOC_outputLines.free(); ExportTabularFLOR_outputLines.free(); + + ExportTabularFLOR_LOC_outputLines.saveToFile('dumps/FLOR_LOC.csv'); + ExportTabularFLOR_LOC_outputLines.free(); end; diff --git a/Edit scripts/ExportTabularLOC.pas b/Edit scripts/ExportTabularLOC.pas new file mode 100644 index 0000000..4e21fcd --- /dev/null +++ b/Edit scripts/ExportTabularLOC.pas @@ -0,0 +1,75 @@ +(** + * Framework of functions for exporting location data of records. + * + * This file does not actually produce dumps, but is used by several other files to help create location dumps. + *) +unit ExportTabularLOC; + + +(** + * Initializes a line buffer for locations data. + * + * @return a line buffer for locations + *) +function initLocList(): TStringList; +begin + result := TStringList.create(); + result.add( + '"File"' // Name of the originating ESM of the reference + + ', "Ref Form ID"' // Form ID of reference + + ', "Form ID"' // Form ID of item + + ', "Editor ID"' // Editor ID of item + + ', "Name"' // Full name of item + + ', "Layer"' // Layer the reference is linked to + + ', "Cell"' // World cell + + ', "Position"' // Vec3 position + + ', "Rotation"' // Vec3 rotation + ); +end; + +(** + * Appends to [locations] an entry for each location reference to [e]. + * + * @param locations the list to append location reference records to + * @param e the record to find the location reference data of + *) +procedure appendLocationData(var locations: TStringList; e: IInterface); +var ref: IwbElement; + data: IInterface; + i: Integer; +begin + for i := 0 to referencedByCount(e) - 1 do begin + ref := referencedByIndex(e, i); + data := eBySign(ref, 'DATA'); + + if (signature(ref) <> 'REFR') or (not elementExists(data, 'Position')) then begin + continue; + end; + + locations.add( + escapeCsvString(getFileName(getFile(ref))) + ', ' + + escapeCsvString(stringFormID(ref)) + ', ' + + escapeCsvString(stringFormID(e)) + ', ' + + escapeCsvString(evBySign(e, 'EDID')) + ', ' + + escapeCsvString(evBySign(e, 'FULL')) + ', ' + + escapeCsvString(evBySign(ref, 'XLYR')) + ', ' + + escapeCsvString(gev(ElementByName(ref, 'Cell'))) + ', ' + + escapeCsvString(vec3ToString(ElementByName(data,'Position'))) + ', ' + + escapeCsvString(vec3ToString(ElementByName(data,'Rotation'))) + ); + end; +end; + +(** + * Converts a vec3 to a string. + * + * @param vec3 the 3D vector to convert to a string + * @return the X, Y, and Z of the vector, separated by colons + *) +function vec3ToString(vec3: IInterface): String; +begin + result := evByName(vec3, 'X') + ':' + evByName(vec3, 'Y') + ':' + evByName(vec3, 'Z'); +end; + + +end. diff --git a/Edit scripts/ExportTabularLVLI.pas b/Edit scripts/ExportTabularLVLI.pas index dffb7fd..5dbf299 100644 --- a/Edit scripts/ExportTabularLVLI.pas +++ b/Edit scripts/ExportTabularLVLI.pas @@ -2,11 +2,12 @@ uses ExportCore, ExportTabularCore, - ExportJson; + ExportJson, + ExportTabularLOC; var ExportTabularLVLI_outputLines: TStringList; -var ExportTabularLOC_outputLines: TStringList; +var ExportTabularLVLI_LOC_outputLines: TStringList; function initialize(): Integer; @@ -20,8 +21,7 @@ function initialize(): Integer; + ', "Leveled List"' // Leveled list ); - - ExportTabularLOC_outputLines := initializeLocationTabular(); + ExportTabularLVLI_LOC_outputLines := initLocList(); end; function canProcess(e: IInterface): Boolean; @@ -46,16 +46,18 @@ function process(lvli: IInterface): Integer; + escapeCsvString(getJsonLeveledListArray(lvli)) ); - ExportTabularLOC_outputLines.addStrings(getLocationData(lvli)); + appendLocationData(ExportTabularLVLI_LOC_outputLines, lvli); end; function finalize(): Integer; begin createDir('dumps/'); + ExportTabularLVLI_outputLines.saveToFile('dumps/LVLI.csv'); - ExportTabularLOC_outputLines.saveToFile('dumps/LVLI_LOC.csv'); - ExportTabularLOC_outputLines.free(); ExportTabularLVLI_outputLines.free(); + + ExportTabularLVLI_LOC_outputLines.saveToFile('dumps/LVLI_LOC.csv'); + ExportTabularLVLI_LOC_outputLines.free(); end; diff --git a/Edit scripts/ExportTabularMISC.pas b/Edit scripts/ExportTabularMISC.pas index 5bfa770..6cac4dc 100644 --- a/Edit scripts/ExportTabularMISC.pas +++ b/Edit scripts/ExportTabularMISC.pas @@ -2,26 +2,28 @@ uses ExportCore, ExportTabularCore, - ExportJson; + ExportJson, + ExportTabularLOC; var ExportTabularMISC_outputLines: TStringList; -var ExportTabularLOC_outputLines: TStringList; +var ExportTabularMISC_LOC_outputLines: TStringList; -function initialize: Integer; + +function initialize(): Integer; begin ExportTabularMISC_outputLines := TStringList.create(); ExportTabularMISC_outputLines.add( - '"File"' // Name of the originating ESM - + ', "Form ID"' // Form ID - + ', "Editor ID"' // Editor ID - + ', "Name"' // Full name - + ', "Weight"' // Item weight in pounds - + ', "Value"' // Item value in bottlecaps - + ', "Components"' // Sorted JSON array of the components needed to craft. Each component is formatted as - // `[component editor id] ([amount])` + '"File"' // Name of the originating ESM + + ', "Form ID"' // Form ID + + ', "Editor ID"' // Editor ID + + ', "Name"' // Full name + + ', "Weight"' // Item weight in pounds + + ', "Value"' // Item value in bottlecaps + + ', "Components"' // Sorted JSON array of the components needed to craft. Each component is formatted as + // `[component editor id] ([amount])` ); - ExportTabularLOC_outputLines := initializeLocationTabular(); + ExportTabularMISC_LOC_outputLines := initLocList(); end; function canProcess(e: IInterface): Boolean; @@ -45,20 +47,19 @@ function process(misc: IInterface): Integer; + escapeCsvString(evByPath(eBySign(misc, 'DATA'), 'Value')) + ', ' + escapeCsvString(getJsonComponentArray(misc)) ); - - ExportTabularLOC_outputLines.AddStrings( - getLocationData(misc) - ); - + + appendLocationData(ExportTabularMISC_LOC_outputLines, misc); end; -function finalize: Integer; +function finalize(): Integer; begin createDir('dumps/'); + ExportTabularMISC_outputLines.saveToFile('dumps/MISC.csv'); - ExportTabularLOC_outputLines.saveToFile('dumps/MISCLOC.csv'); - ExportTabularLOC_outputLines.free(); ExportTabularMISC_outputLines.free(); + + ExportTabularMISC_LOC_outputLines.saveToFile('dumps/MISC_LOC.csv'); + ExportTabularMISC_LOC_outputLines.free(); end; @@ -89,7 +90,7 @@ function getJsonComponentArray(e: IInterface): String; end; resultList.sort(); - result := listToJson(resultList); + result := stringListToJsonArray(resultList); resultList.free(); end; diff --git a/Edit scripts/ExportTabularWEAP.pas b/Edit scripts/ExportTabularWEAP.pas index a6f9db5..f1fa11e 100644 --- a/Edit scripts/ExportTabularWEAP.pas +++ b/Edit scripts/ExportTabularWEAP.pas @@ -2,11 +2,12 @@ uses ExportCore, ExportTabularCore, - ExportJson; + ExportJson, + ExportTabularLOC; var ExportTabularWEAP_outputLines: TStringList; -var ExportTabularLOC_outputLines: TStringList; +var ExportTabularWEAP_LOC_outputLines: TStringList; function initialize(): Integer; @@ -31,7 +32,7 @@ function initialize(): Integer; + ', "Keywords"' // Sorted JSON array of keywords. Each keyword is represented by its editor ID ); - ExportTabularLOC_outputLines := initializeLocationTabular(); + ExportTabularWEAP_LOC_outputLines := initLocList(); end; function canProcess(e: IInterface): Boolean; @@ -41,6 +42,7 @@ function canProcess(e: IInterface): Boolean; function process(weap: IInterface): Integer; var data: IInterface; + locations: TStringList; begin if not canProcess(weap) then begin addWarning(name(weap) + ' is not a WEAP. Entry was ignored.'); @@ -68,16 +70,18 @@ function process(weap: IInterface): Integer; + escapeCsvString(getJsonKeywordArray(weap)) ); - ExportTabularLOC_outputLines.AddStrings(getLocationData(weap)); + appendLocationData(ExportTabularWEAP_LOC_outputLines, weap); end; function finalize(): Integer; begin createDir('dumps/'); + ExportTabularWEAP_outputLines.saveToFile('dumps/WEAP.csv'); - ExportTabularLOC_outputLines.saveToFile('dumps/WEAPLOC.csv'); - ExportTabularLOC_outputLines.free(); ExportTabularWEAP_outputLines.free(); + + ExportTabularWEAP_LOC_outputLines.saveToFile('dumps/WEAP_LOC.csv'); + ExportTabularWEAP_LOC_outputLines.free(); end; diff --git a/README.md b/README.md index b4ce873..4968015 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,9 @@ Tabular dumps are a simplified sort of dump that contains only the most importan These records should be very easy to understand by anyone. For more information on how to browse them, check [the wiki page](https://github.com/FWDekker/fo76-dumps/wiki/Browsing-CSV-files). +Some dumps also have associated `_LOC` dumps, which contain information on the in-game locations of the records of that type. +To manually interpret location data, take a look at my [maps with grids](https://fallout.fandom.com/wiki/User_blog:FDekker/Maps_with_grids) resources. +
Click here for a list of tabular dumps

@@ -65,5 +68,9 @@ For more information on the optimal procedure, see [the wiki page on generating * Feature requests can be made on the [Issues](https://github.com/FWDekker/fo76-dumps/issues) page. * Questions can be asked on [my Fallout Wiki talk page](https://fallout.fandom.com/wiki/User_talk:FDekker) or by emailing me. +## Credits +* [AYF](https://fallout.fandom.com/wiki/User:AllYourFavorites), for regularly reminding me to create new dumps! +* [Wully616](https://github.com/Wully616), for [his contributions](https://github.com/FWDekker/fo76-dumps/pull/20) to dumping location data. + ## Copyright The contents of all data dumps in this repository are owned by Bethesda Softworks LLC.