crimsoncantab / aok-hotkeys

Hotkey Editor for Age of Empires II
Other
25 stars 9 forks source link

How to parse a decompressed hotkey file? #74

Closed gregstein closed 2 years ago

gregstein commented 2 years ago

Hello,

So I decompressed a hotkey file py hkizip.py d < player1.hki > player.txt

But my attempts to parse it into a json file have failed with this command py hkparse.py < player.txt > player.json

I get TypeError: a bytes-like object is required, not 'str' I'm certainly doing something wrong. Could you help me with this one please?

Thanks for the amazing library and the continuous support!!!!

crimsoncantab commented 2 years ago

Hey @gregstein. Which version of python are you using? Unfortunately I think this code was written for python2, so it will likely break if you're using python3: https://stackoverflow.com/questions/33054527/typeerror-a-bytes-like-object-is-required-not-str-when-writing-to-a-file-in.

Do you have a stacktrace with the line of code where the error occurs?

gregstein commented 2 years ago

Hello @crimsoncantab! I hope you're doing well. And thank you for the fast response <3

You're right! I'm using 3.6.8 but I do not mind using py2. Here is the stacktrace you asked for: stack

I will try with py2 first and see how that works. Thank you!

gregstein commented 2 years ago

Oh wow! Thank you so much! on py2 the command worked out of the box. You are truly amazing!

gregstein commented 2 years ago

One final question! Can I extract hk_mapping values from hkstrings.py?

crimsoncantab commented 2 years ago

Are you wanting to make a json export of hk_mapping? I updated the code on a branch (see above, 7159c1d) so that running hkstrings.py will print hk_mapping to json.

NOTE that it's not on the master branch for now, so you'd have to check out hk_mapping-export

gregstein commented 2 years ago

uhhh! YOU'RE AWESOME! Thank you so much crimson! That's what I needed

crimsoncantab commented 2 years ago

Sure thing! Glad I could easily help you. At some point the app needs to be converted to python3, but I haven't found the time to do that. Would be a larger rework to still be deployable to GCP.

gregstein commented 2 years ago

I agree with you. And honestly no need to. Thank you again crimson <3

Have a great rest of your day.