Closed nineteendo closed 2 years ago
Maybe you can enter the folder path directly.
Doesn't work. (Also with / at the end)
RTON decoding and encoding just supports single file. If you want to decode or encode all RTON in a folder, you need to use Lua Script function. There's the code to decode all RTON in a folder
local filepath = "/Users/..."; -- Enter your folder path local files = rainy.getfiles(filepath); for i=1,#files do local a = string.lower(rainy.getfileextension(files[i])); local b = rainy.getfilenamewithoutextension(files[i]); if a == ".rton" then rainy.decoderton(files[i], rainy.formatpath(rainy.getfilepath(files[i]) .. "\" .. b .. ".json"), 0); if delete then rainy.deletefile(files[i]); end end end
Line 7 is incomplete. Executing error: ')' expected (to close '(' at line 7) near '.'
Change "\" to "\\"
But I can't see how long that took. It's very quick though.
Use this code:
local time_begin = os.time(); local filepath = "D:\rsb资源\phone_v4_android"; -- Enter your folder path local files = rainy.getfiles(filepath); for i=1,#files do local a = string.lower(rainy.getfileextension(files[i])); local b = rainy.getfilenamewithoutextension(files[i]); if a == ".rton" then rainy.decoderton(files[i], rainy.formatpath(rainy.getfilepath(files[i]) .. "/" .. b .. ".json"), 0); if delete then rainy.deletefile(files[i]); end end end local time_end = os.time(); print("It takes " .. time_end - time_begin .. " seconds to decode.")
How is your tool 5 times faster in doing that? Multithreading? Does that have something to do with using a different output folder? Your tool: It takes 1.568983793258667 seconds to decode. My tool: finished unpacking in 0:00:08.367731 Code: https://github.com/Nineteendo/PVZ2tools/blob/master/OBBEdit/libraries/pyvz2rton.py
I'm not sure. I don't use multithreading when decoding RTON. I only use multithreading to ensure UI response. Do you transcode ASCII/UTF8 string to unicode string and then write it into json? My tool does not transcode ASCII/UTF8 string to unicode string. This step takes up a lot of time.
So first of all I'm using Python (which is not very fast)
And this is likely very slow:
json.dumps(self.parse_text(fp), ensure_ascii = self.ensureAscii).encode()
With this extra functions:
def parse_number(self, fp):
num = fp.read(1)[0]
result = num & 0x7f
i = 128
while num > 127:
num = fp.read(1)[0]
result += i * (num & 0x7f)
i *= 128
return result
def parse_text(self, fp):
# types 81, 90
byte = fp.read(self.parse_number(fp))
try:
return byte.decode()
except Exception:
return byte.decode('latin-1')
Would you please add folder support to the next update? And do you have Discord? (https://discord.gg/CVZdcGKVSw) I would like to discuss PyVZ2.
Maybe I'll add it in the next update. I have some difficulties in registering Discord. It indicates that I need to verify my mobile phone, but no text message is sent. Maybe my region doesn't support using it.
Strange, because my server shouldn't require it. I could maybe try turning off all restrictions?
Now I've successfully enterred this channel. Thanks.
I have send you a direct message. And you can follow the development of my tool in #pyvz2-github
Have you implemented it?
Have you implemented it?
I'm doing it. And it will be added in the next version.
So I was trying to compare the speed of PopStudio with PyVZ2 which I just updated to v1.2.0 (https://github.com/Nineteendo/PVZ2tools). But I noticed I can't select folders. Could you please support that such that I can compare?