Tiffany wrote: ↑Sun Aug 06, 2023 6:05 pm
EvenLess wrote: ↑Sun Aug 06, 2023 5:37 pm
A way to find the items from the in-game name is to unpack the localization file and use the that to search for the in-game name, then using the ID, searching the RootTemplates for the one that contains the reference to that ID.
If you want to expand your powershell script at some point it might be an interesting idea to use the generated bg3_items.txt to search the localization files for those IDs and append the supplied names with the actual names.
...
I'm actually already looking into something along those lines, but it's slow going, as I'm trying to decipher the different things as I'm going along. F.ex. I'm trying to find some reference to the item type and sub types, for categorizing. And the DisplayName is sometimes not on the actual item template, but are found by going through one or more parent templates.
This is what I've got so far.
Bear in mind that this is only very basic for testing getting the details for a single item. Then when I've gotten that down, the plan is to use that to just go through every RootTemplate item, as some items are only found here, and not in the .txt files.
All the .lsf-files needed to be converted first to a format that I can work with (I chose .lsj as that is JSON format, which is easy to import into a PowerShell object).
Code: Select all
$LocalizationPath = 'C:\Games\BG3-Tools\UnpackedData\English\Localization\English\english.xml'
$LocalizationData = [xml](Get-Content -Encoding Default -Path $LocalizationPath)
$LocalizationData.contentList.content
<#
$RootTemplates = @(
'C:\Games\BG3-Tools\UnpackedData\Shared\Public\Shared\RootTemplates'
,'C:\Games\BG3-Tools\UnpackedData\Shared\Public\SharedDev\RootTemplates'
,'C:\Games\BG3-Tools\UnpackedData\Gustav\Public\Gustav\RootTemplates'
,'C:\Games\BG3-Tools\UnpackedData\Gustav\Public\GustavDev\RootTemplates'
)
#>
#$Template = "C:\Games\BG3-Tools\UnpackedData\Shared\Public\Shared\RootTemplates\0c0c1031-4a04-4e8f-ba8a-8aafa2a396e8.lsj"
#$Template = "C:\Games\BG3-Tools\UnpackedData\Shared\Public\Shared\RootTemplates\f6cbfbb3-7eab-4f78-afde-073756c4e26d.lsj"
#$Data = Get-Content -Encoding Default -Path $Template | ConvertFrom-Json
#$Data.save.regions.Templates.GameObjects[0]
function Get-TemplateData {
param(
$Id
)
Write-Verbose -Message "Get-TemplateData -Id '$($Id)'" -Verbose
$ParentTemplate = "C:\Games\BG3-Tools\UnpackedData\Shared\Public\Shared\RootTemplates\$($Id).lsj"
$Data = Get-Content -Encoding Default -Path $ParentTemplate | ConvertFrom-Json
return $Data.save.regions.Templates.GameObjects[0]
}
$RegexUUID = [regex]'^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$'
$TemplateId = 'f6cbfbb3-7eab-4f78-afde-073756c4e26d'
do {
$Data = Get-TemplateData -Id $TemplateId
$Data
if ($Data.psobject.Properties.Name -contains 'ParentTemplateId' -and $Data.ParentTemplateId.value -match $RegexUUID) {
$TemplateId = $Data.ParentTemplateId.value
}
} while ($Data.psobject.Properties.Name -contains 'ParentTemplateId' -and $Data.ParentTemplateId.value -match $RegexUUID)
break
if ($Data.save.regions.Templates.GameObjects[0].psobject.Properties.Name -contains 'ParentTemplateId') {
$ParentTemplateId = $Data.save.regions.Templates.GameObjects[0].ParentTemplateId.value
$ParentTemplate = "C:\Games\BG3-Tools\UnpackedData\Shared\Public\Shared\RootTemplates\$($ParentTemplateId).lsj"
$ParentData = Get-Content -Encoding Default -Path $ParentTemplate | ConvertFrom-Json
}
if ($Data.save.regions.Templates.GameObjects[0].psobject.Properties.Name -notcontains 'DisplayName') {
$ParentTemplateId = $Data.save.regions.Templates.GameObjects[0].ParentTemplateId.value
$ParentTemplate = "C:\Games\BG3-Tools\UnpackedData\Shared\Public\Shared\RootTemplates\$($ParentTemplateId).lsj"
$ParentData = Get-Content -Encoding Default -Path $ParentTemplate | ConvertFrom-Json
$DisplayName = ($LocalizationData.contentList.content | Where-Object {
$_.contentuid -eq $ParentData.save.regions.Templates.GameObjects[0].DisplayName.handle
}).'#text'
}
Tiffany wrote: ↑Sun Aug 06, 2023 6:05 pm
...
Also you definitely missed
my message earlier asking why you have this:
When Zanzer's code doesn't have the assert(true) in that part in the example script.
That's weird. I remember answering, but I can't find the post. I'm guessing it was "blocked" or something. I remember writing the PHP start/close tags as an example, which I could imagine would block the post.
The code is a direct copy/paste from Zanzer's code. If you download one of his earlier tables, you will see that it's there. From what I can figure out, the
{$lua}
and
{$asm}
are telling CE that the following is LUA code or Assembler code. At least that's what I suspect by seeing the syntax highlighting being broken in the CE script editor, when removing those tags.
As for the
assert(true)
, I don't know what it does, really. What I did find out, when testing the difference, is that when
assert(true)
is there, the X when activating a cheat doesn't "stick", and with assert(true) gone, the X sticks. For the item spawner I actually prefer
assert(true)
to be there, otherwise you have to deactivate and activate again to spawn one more item. But I honestly, I don't know what it does for real.
<edit>
Zanzer wrote that he removed the
assert(true)
due to user confusion.</edit>