EternalWraith / PalEdit

A simple tool for Editing and Generating Pals within PalWorld Saves
MIT License
480 stars 68 forks source link

Can't Load File : KeyError: 'root' #5

Closed GuedesTom closed 8 months ago

GuedesTom commented 8 months ago

Hi! I deserialized my .sav file, i can open the .json, but when i try to load into PalEdit i have this error :

Python 3.10.10 "C:\Users\user\Downloads\PalEdit-main\PalEdit-main\" Opening file C:/Users/user/Downloads/palworld-save-tools-windows-v0.9.0/Level.sav.json Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 1921, in __call__ return self.func(*args) File "C:\Users\user\Downloads\PalEdit-main\PalEdit-main\PalEdit.py", line 123, in loadfile paldata = data['root']['properties']['worldSaveData']['Struct']['value']['Struct']['CharacterSaveParameterMap']['Map']['value'] KeyError: 'root' Opening file C:/Users/user/Downloads/palworld-save-tools-windows-v0.9.0/Level.sav.json Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 1921, in __call__ return self.func(*args) File "C:\Users\user\Downloads\PalEdit-main\PalEdit-main\PalEdit.py", line 123, in loadfile paldata = data['root']['properties']['worldSaveData']['Struct']['value']['Struct']['CharacterSaveParameterMap']['Map']['value'] KeyError: 'root'

I use :

PS C:\Users\user> python -V Python 3.10.10

Any idea of why i get this?

Thank's!

Anixs commented 8 months ago

Also same issue

Python 3.12.1 "C:\Users\Anthony\Downloads\PalEdit-main\" Opening file C:/Users/Anthony/AppData/Local/Pal/Saved/SaveGames/76561198014699454/A566FC714E4D312EACBABFAD470CDF00/Level.sav.json Exception in Tkinter callback Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.496.0_x64qbz5n2kfra8p0\Lib\tkinter\init.py", line 1962, in call__ return self.func(*args) ^^^^^^^^^^^^^^^^ File "C:\Users\Anthony\Downloads\PalEdit-main\PalEdit.py", line 123, in loadfile paldata = data['root']['properties']['worldSaveData']['Struct']['value']['Struct']['CharacterSaveParameterMap']['Map']['value']


KeyError: 'root'
Luc3998 commented 8 months ago

also same issue i think it has something to do with the update yesterday

CodeAnthem commented 8 months ago

same issue `Exception in Tkinter callback Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.496.0_x64qbz5n2kfra8p0\Lib\tkinter\init.py", line 1962, in call__ return self.func(*args) ^^^^^^^^^^^^^^^^ File "C:\PalWorld-Mod\PalEdit-main\PalEdit.py", line 123, in loadfile paldata = data['root']['properties']['worldSaveData']['Struct']['value']['Struct']['CharacterSaveParameterMap']['Map']['value']


KeyError: 'root'
`
toikocook commented 8 months ago

use Palworld-save-tools version 0.7.1 https://github.com/cheahjs/palworld-save-tools/releases/download/v0.7.1/palworld-save-tools-windows-v0.7.1.zip

gardybelle commented 8 months ago

Same Issue, 0.7.1 didnt change anything

Prequarantine commented 8 months ago

Yes, palworld-save-tools updated in a way that no longer depends on uesave.exe. Therefore, this tool cannot use the newer version's output. I can confirm 0.8.X worked. The new save tools is much faster, uses less RAM, and results in a smaller filesize, so it is perhaps worth looking into whether or not the newer process can be supported instead of supporting something that could become deprecated as the game continues to receive updates.

bronze commented 8 months ago

Same here

Opening file D:/PalEdit/palworld-save-tools-windows-v0.10.0/Level.sav.json
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\bronze\AppData\Local\Programs\Python\Python312\Lib\tkinter\__init__.py", line 1962, in __call__
    return self.func(*args)
           ^^^^^^^^^^^^^^^^
  File "D:\PalEdit\PalEdit-main\PalEdit.py", line 123, in loadfile
    paldata = data['root']['properties']['worldSaveData']['Struct']['value']['Struct']['CharacterSaveParameterMap']['Map']['value']
              ~~~~^^^^^^^^
KeyError: 'root'

using palworld-save-tools-windows-v0.10.0.zip

Alexander3a commented 8 months ago

try this patch but backup first didnt have the time test it so be carefull

index d3d9494..272c702 100644
--- a/PalEdit.py
+++ b/PalEdit.py
@@ -120,7 +120,7 @@ def loadfile():
         print(paldata)
         print(len(paldata))
     else:
-        paldata = data['root']['properties']['worldSaveData']['Struct']['value']['Struct']['CharacterSaveParameterMap']['Map']['value']
+        paldata = data['properties']['worldSaveData']['value']['CharacterSaveParameterMap']['value']

         f = open("current.pson", "w", encoding="utf8")
         json.dump(paldata, f, indent=4)
@@ -186,7 +186,10 @@ def savejson(filename):
     if 'root' in data:
         svdata['root']['properties']['worldSaveData']['Struct']['value']['Struct']['CharacterSaveParameterMap']['Map']['value'] = data['root']['properties']['worldSaveData']['Struct']['value']['Struct']['CharacterSaveParameterMap']['Map']['value']
     else:
-        svdata['root']['properties']['worldSaveData']['Struct']['value']['Struct']['CharacterSaveParameterMap']['Map']['value'] = data
+        if 'properties' in data:
+            svdata['properties']['worldSaveData']['value']['CharacterSaveParameterMap']['value'] = data['properties']['worldSaveData']['value']['CharacterSaveParameterMap']['value']
+        else:
+            svdata['root']['properties']['worldSaveData']['Struct']['value']['Struct']['CharacterSaveParameterMap']['Map']['value'] = data

     f = open(filename, "w", encoding="utf8")
     json.dump(svdata, f)
diff --git a/PalInfo.py b/PalInfo.py
index 35c3a84..06b2ae0 100644
--- a/PalInfo.py
+++ b/PalInfo.py
@@ -370,7 +370,7 @@ class PalEntity:

     def __init__(self, data):
         self._data = data
-        self._obj = data['value']['Struct']['Struct']['RawData']['Parsed']['object']['SaveParameter']['value']
+        self._obj = data['value']['RawData']['value']['object']['SaveParameter']['value']

         if "IsPlayer" in self._obj:
             raise Exception("This is a player character")
EternalWraith commented 8 months ago

Just rolled out an update, this issue has now been fixed.