Takuma 186 Posted January 20, 2021 Share Posted January 20, 2021 (edited) M2 Download Center This is the hidden content, please Sign In or Sign Up ( Internal ) This is the hidden content, please Sign In or Sign Up ( GitHub ) Hi ! First: sorry. My code is not clean, I am not a developer or anything, I am just a math student. I am just trying to do my best. And my skills in English are… non-existent. So, be nice please. Using very often PyCharm, I wanted to be able to use it on Metin2, but PyCharm (or another IDE) hit me hard with baseball bat because he could not find the modules. So, I have made this tool to create module’s python skeleton and use autocompletion with IDE. The biggest flaw is that you must have Python3 installed on your machine to use typing. Example of result with PyCharm: And you can't find an exemple of output here. To follow this tutorial, you must have: Python3 (i'm using Python3.8) PyCharm or other IDE, but in this tutorial, I will use PyCharm (from JetBrains). This is the hidden content, please Sign In or Sign Up . I – Generate your module skeleton. You can find just upper, a link to download my script. It is easy to use. You can find all the manipulations in README.md file, but I will explain it here too: Move all your client’s .cpp file (with module) in src folder. Just use now main.py with Python3 (I developed it with Python3.8) You will see many files in bin folder. II – Make a virtual environment of Python3 for IDEs We will have to create a virtual environment for our IDEs to do not dirty our real Python installation. To do that, you can use the command : python3 -m venv /path/to/new/virtual/environment Find all information on the doc : https://docs.python.org/3/library/venv.html I will show you how to do that with PyCharm: Spoiler Open your pack folder with PyCharm, you will have something like this : Now, we have to create a new virtual environment of Python. For this, click on the button at the bottom right of PyCharm to select an interpreter, and choose Add interpreter: Configure now a new virtual environment with Python3x as base intrepreter and create it. You will have something like that: And with Visual Studo Code: Spoiler You must have Python extension. You can get it in the MarketPlace, and create your venv with command. Open your pack folder with Visual Studio Code and save it as a Workspace. In this Workspace, on Visual Studio Code Press : Ctrl + Alt + P. Select Python: Select Interpreter: Specify that it's for the Entire WorkSpace: Select after Enter interpreter path...: After, Find... and go search python.exe in venv folder (venv/Script/python.exe). And it's done. Congratulation. III - Add our skeletons to virtualenv For that, you just must move all your .py file in bin folder to venv/Lib/site-packages. Example : This manipulation is a little dirty ... But I couldn't find anything better so as not to have too much change to make. If you have a better one, I take... Don't forget to configure your IDE to use new virtualenv. IV - Known issues: Script cannot predict value of the constants; It does not yed manage structures of this type: V - Debug: Script now support Tuple in functions' returns; Add the method GetWindow for arguments. With using Python3 IDE, he will consider print without parentheses and except bloc as error... Thanks to @Gurgarath for his help This is the hidden content, please Sign In or Sign Up Takuma. Edited December 12, 2021 by Gurgarath 52 2 1 4 3 29 Link to comment Share on other sites More sharing options...
Forum Moderator VegaS™ 10341 Posted January 20, 2021 Forum Moderator Share Posted January 20, 2021 (edited) At least there's someone in metin2 that using Python 3+ for tools (since already we've 3.9 and they're still using 2.7), great. The problem is that 99% of them will not understand the code from your tool, but it's fine, let's just run it and see the magic. Thanks for the release, it's really useful for 'developers'. Edited August 25, 2022 by Metin2 Dev Core X - External 2 Internal 5 Check my GitHub Profile Click to find all the threads started by me [TOOL] Text file loader + JSON Link to comment Share on other sites More sharing options...
Vanilla 1458 Posted January 20, 2021 Share Posted January 20, 2021 (edited) 16 minutes ago, VegaS™ said: At least there's someone in metin2 that using Python 3+ for tools (since already we've 3.9 and they're still using 2.7), great. The problem is that 99% of them will not understand the code from your tool, but it's fine, let's just run it and see the magic. Thanks for the release, it's really useful for 'developers'. Well if it's bothering you, why not sharing a guide and helping the people to move to py 3? It's not like it's that difficult to upgrade to py3 tho. But I guess you can't complain if people don't want to touch a running system especially without the knowledge of what they're supposed to do or how to debug after converting the py2 files to 3. Especially since developers tend to just sell their precompiled stuff which runs on - tada - py2. I can imagine the autistic screeching after finding out that after porting py2 to 3 results in some systems done by greedy devs not working properly. But yes I agree, it's best to use py3 in any case possible! Edited August 25, 2022 by Metin2 Dev Core X - External 2 Internal 1 We are the tortured. We're not your friends. As long as we're not visible. We are unfixable. Link to comment Share on other sites More sharing options...
Forum Moderator VegaS™ 10341 Posted January 20, 2021 Forum Moderator Share Posted January 20, 2021 (edited) 1 hour ago, Vanilla said: Well if it's bothering you, why not sharing a guide and helping the people to move to py 3? Sorry, you understood it wrong, maybe my bad. I talked about general stuff, tools, not crap metin2 or about porting it to py3, doesn't have any relevance with what I said. Was all about that in the last years I didn't saw any public tool coded in py3 well, just py2 and that's really sad when you look at py3 release date: 03-Dec-2008. There're no excuses for 'developers/programmers' that don't use the latest versions of python in other apps/tools just because metin2 doesn't have it, which means they didn't care about improving their skills in that language, simple. Those tools don't have anything related to metin2 code, that's why I told those things. It's like still using full C++98 after 20 years in your tools when you've no limits and C++2x is here. @TakumaA good feature would be a detailed documentation for functions, like this: https://martysama0134.github.io/m2-docs/luafunc.html If you need any help with the documentation or anything else, don't hesitate to contact me as well, I would like to contribute in my free time. Edited August 25, 2022 by Metin2 Dev Core X - External 2 Internal 3 Check my GitHub Profile Click to find all the threads started by me [TOOL] Text file loader + JSON Link to comment Share on other sites More sharing options...
Forum Moderator Gurgarath 2524 Posted January 20, 2021 Forum Moderator Share Posted January 20, 2021 Good job for this release. It's highly needed for everyone who wants to take the advantage of whatever is in their source without having to open the module and check how it works and if it's there. It just makes it simpler for everyone who wants to start coding something without knowing exactly the usage or just for people who wants to gain time. 4 Gurgarath coming soon Link to comment Share on other sites More sharing options...
Takuma 186 Posted January 20, 2021 Author Share Posted January 20, 2021 (edited) 1 hour ago, VegaS™ said: Sorry, you understood it wrong, maybe my bad. I talked about general stuff, tools, not crap metin2 or about porting it to py3, doesn't have any relevance with what I said. Was all about that in the last years I didn't saw any public tool coded in py3 well, just py2 and that's really sad when you look at py3 release date: 03-Dec-2008. Those tools don't have anything related to metin2 code, that's why I told those things. It's like still using full C++98 after 20 years in your tools when you've no limits and C++2x is here. @TakumaA good feature would be a detailed documentation for functions, like this: I've already thought about converting the docstrings, but I don't know the sources well enough to comment everything... But when I have some time I will do the docstrings converter. Thanks for the idea ! I will add the method to use venv with Visual Studio Code too. Added. Edited August 25, 2022 by Metin2 Dev Core X - External 2 Internal 1 Link to comment Share on other sites More sharing options...
edwardcrkz 20 Posted January 21, 2021 Share Posted January 21, 2021 (edited) 14 hours ago, VegaS™ said: At least there's someone in metin2 that using Python 3+ for tools (since already we've 3.9 and they're still using 2.7), great. The problem is that 99% of them will not understand the code from your tool, but it's fine, let's just run it and see the magic. Thanks for the release, it's really useful for 'developers'. I agree with you python 3-3+ better than python 2.7. Dear takuma in my opinion u should consider converting Docstrings.This is so important thing. Edited August 25, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
Takuma 186 Posted January 21, 2021 Author Share Posted January 21, 2021 Hi ! Use Python3 with the client can be very interesting.. For use UTF-8 everywhere for example (Unicode...). i tried to do this before, but my client crashed when I created empty tuple... xd if someone want share a client with Python3.. I take it ! I just specify that i updated the code for two errors that were reported to me : Tuple in return; GetWindow() method. 1 Link to comment Share on other sites More sharing options...
Vanilla 1458 Posted January 21, 2021 Share Posted January 21, 2021 11 minutes ago, Takuma said: Hi ! Use Python3 with the client can be very interesting.. For use UTF-8 everywhere for example (Unicode...). i tried to do this before, but my client crashed when I created empty tuple... xd if someone want share a client with Python3.. I take it ! I just specify that i updated the code for two errors that were reported to me : Tuple in return; GetWindow() method. mostly it's converting everything to utf-8 and then run 2to3 tool to convert the scripts. You'll have to make some changes to the scripts tho, since the tool obviously can't be perfect. And then it's changing the the python initialization and modules declaration. You'd better use Unicode in client source, so if I were you I'd start with using utf-8 on client and all files (text files, py scripts etc.) and then swap the project to unicode. You have to change a bit on the client there but in the end it's definitely worth it! After that you can do the actual upgrade to py3. Side note: I also recommend using utf-8 in database tables, server source and files We are the tortured. We're not your friends. As long as we're not visible. We are unfixable. Link to comment Share on other sites More sharing options...
Forum Moderator VegaS™ 10341 Posted January 22, 2021 Forum Moderator Share Posted January 22, 2021 (edited) Quote With using Python3 IDE, he will consider print without parentheses and except bloc as error... That moment when you hate regex.. I'll add it tomorrow night on GitHub + other features. Edited January 22, 2021 by VegaS™ removed code tag 1 3 Check my GitHub Profile Click to find all the threads started by me [TOOL] Text file loader + JSON Link to comment Share on other sites More sharing options...
Honorable Member Mali 42407 Posted January 22, 2021 Honorable Member Share Posted January 22, 2021 (edited) Thank you, it's working great You can add these two modules(EterPythonLib) Spoiler Edited August 25, 2022 by Metin2 Dev Core X - External 2 Internal 2 Link to comment Share on other sites More sharing options...
Premium WeedHex 636 Posted January 22, 2021 Premium Share Posted January 22, 2021 (edited) No need to break if return << Nice share guys! Edited January 22, 2021 by WeedHex 1 Link to comment Share on other sites More sharing options...
Takuma 186 Posted January 22, 2021 Author Share Posted January 22, 2021 (edited) 2 hours ago, Mali61 said: Thank you, it's working great You can add these two modules(EterPythonLib) Hide contents Hi ! Thanks for your feedback ! I added the two functions. I did as they took an int as parameter. I will think about how to properly model these objects in Python automatically. Edited August 25, 2022 by Metin2 Dev Core X - External 2 Internal 1 Link to comment Share on other sites More sharing options...
Fuzzer 130 Posted January 29, 2021 Share Posted January 29, 2021 Thanks! Before i work with py in vs.. its better than n++ but solution with Visual Code is perfect Thanks 1 Link to comment Share on other sites More sharing options...
Forum Moderator VegaS™ 10341 Posted January 30, 2021 Forum Moderator Share Posted January 30, 2021 On 1/22/2021 at 4:19 AM, VegaS™ said: I'll add it tomorrow night on GitHub + other features. On 1/22/2021 at 7:16 PM, Takuma said: To continue, you can use VegaS's script to convert your python2 code to python3. This will adapt your code to be usable both in python2 and python 3. Check my GitHub Profile Click to find all the threads started by me [TOOL] Text file loader + JSON Link to comment Share on other sites More sharing options...
Premium msnas 1430 Posted November 13, 2021 Premium Share Posted November 13, 2021 (edited) After trying it out on atom and pycharm, I decided to use it on VS Code. However, there's a problem with the sintax from the pylance (built-in with the python extension): This is because the functions are set as NoReturn and pylance doesn't like that, that's why the code seems unreachable. In order to fix this, you need to change the type NoReturn to None: You can do it by changing all the files after the manipulation or change the This is the hidden content, please Sign In or Sign Up . Thank you for the release, everything is working as expected! Edited August 17, 2022 by Metin2 Dev Core X - External 2 Internal 3 2 Link to comment Share on other sites More sharing options...
Takuma 186 Posted January 1, 2022 Author Share Posted January 1, 2022 (edited) On 11/13/2021 at 2:39 PM, msnas said: After trying it out on atom and pycharm, I decided to use it on VS Code. However, there's a problem with the sintax from the pylance (built-in with the python extension): This is because the functions are set as NoReturn and pylance doesn't like that, that's why the code seems unreachable. In order to fix this, you need to change the type NoReturn to None: You can do it by changing all the files after the manipulation or change the Hidden Content Give reaction to this post to see the hidden content. . Thank you for the release, everything is working as expected! Thanks for the feedback. I update the repo, sorry for be late ! I also add you to Thanks part in README.MD, I can put your GitHub profile if you want. I was wrong on the NoReturn, it is actually intended for a code that exits the program (Source). Takuma. Edited August 17, 2022 by Metin2 Dev Core X - External 2 Internal 2 Link to comment Share on other sites More sharing options...
Honorable Member Mali 42407 Posted March 15, 2022 Honorable Member Share Posted March 15, 2022 Tool for converting official builtins: This is the hidden content, please Sign In or Sign Up example safebox.py: Spoiler __author__ = "blackdragonx61/Mali" __unpacker__ = "xP3NG3Rx" __skeleton__ = "Takuma" SAFEBOX_PAGE_SIZE = 45 SAFEBOX_SLOT_X_COUNT = 5 SAFEBOX_SLOT_Y_COUNT = 9 __name__ = 'safebox' def GetItemApplyRandom() -> None: pass def GetItemAttribute() -> None: pass def GetItemChangeLookVnum() -> None: pass def GetItemCount() -> None: pass def GetItemFlags() -> None: pass def GetItemID() -> None: pass def GetItemMetinSocket() -> None: pass def GetItemRareAttribute() -> None: pass def GetItemRefineElement() -> None: pass def GetItemSetValue() -> None: pass def GetMallItemApplyRandom() -> None: pass def GetMallItemAttribute() -> None: pass def GetMallItemChangeLookVnum() -> None: pass def GetMallItemCount() -> None: pass def GetMallItemID() -> None: pass def GetMallItemMetinSocket() -> None: pass def GetMallItemRareAttribute() -> None: pass def GetMallItemRefineElement() -> None: pass def GetMallItemSetValue() -> None: pass def GetMallSize() -> None: pass def GetMoney() -> None: pass def IsSealedMallItem() -> None: pass Sorry for the function return type and parameters. There is not enough information to convert them. Spoiler Put the tool in official unpacked builtins and use it: 7 2 2 Link to comment Share on other sites More sharing options...
Takuma 186 Posted May 23, 2022 Author Share Posted May 23, 2022 (edited) Hi devs ! So, I just pushed a commit. It's a an uptdate : I refactored all the code (not in only one file); Tools can know support many modules in same file; Some parameters, such as the use of the snake_case for the arguments, can be configured in the CONSTANTS.py file No modification to use the script. Do as before. (Sorry for my bad english) Takuma. Edited May 23, 2022 by Takuma 2 1 3 Link to comment Share on other sites More sharing options...
Takuma 186 Posted May 29, 2022 Author Share Posted May 29, 2022 I cannot edit my subject, so... I'll write the changes here. Now you no longer need to use bin and src folders mandatorily. This is the hidden content, please Sign In or Sign Up Please, read README.md file to know how to use the script. A example of use could be : Quote python main.py -s src -o bin to use src and bin folders as before. Thank to NewWars 4 1 2 Link to comment Share on other sites More sharing options...
Premium msnas 1430 Posted December 23, 2022 Premium Share Posted December 23, 2022 (edited) I found something interesting. The tool is only checking if Pi_InitModule starts as a PyObject's variable. However, there are some files that aren't being initialized in that way - 14 to be exact: The solution would be to remove/comment this line: And voilá, files like PythonDebugModule.cpp are being called correctly: Edited December 23, 2022 by Metin2 Dev Core X - External 2 Internal 1 1 Link to comment Share on other sites More sharing options...
Takuma 186 Posted December 23, 2022 Author Share Posted December 23, 2022 (edited) 3 hours ago, msnas said: I found something interesting. The tool is only checking if Pi_InitModule starts as a PyObject's variable. However, there are some files that aren't being initialized in that way - 14 to be exact: The solution would be to remove/comment this line: And voilá, files like PythonDebugModule.cpp are being called correctly: Hi. I'm a little bit busy now. Could you maybe make a pull request on github ? I'll check this. Thanks you ! Edited December 23, 2022 by Metin2 Dev Core X - External 2 Internal 1 Link to comment Share on other sites More sharing options...
Recommended Posts