Jump to content

Skeletton of Python modules for IDE.


Recommended Posts

M2 Download Center

Download Here ( Internal )

Download Here ( 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:

205724result-example.png

 

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).
  • Tools to make skeletons.

 

 

 

 

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

 

  1. Open your pack folder with PyCharm, you will have something like this :
    201037Capture-d-ecran-2021-01-20-163730.
  2. 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:
    201231Image1.png
  3. Configure now a new virtual environment with Python3x as base intrepreter and create it. You will have something like that:
    201358Capture-d-ecran-2021-01-20-165314.

 

 

 

 

And with Visual Studo Code:

Spoiler

 

You must have Python extension. You can get it in the MarketPlace, and create your venv with command.

  1. Open your pack folder with Visual Studio Code and save it as a Workspace.
    211238image-2021-01-21-001218.png
  2. In this Workspace, on Visual Studio Code Press : Ctrl + Alt + P.
  3. Select Python: Select Interpreter:
    211554Capture-d-ecran-2021-01-21-001535.
  4. Specify that it's for the Entire WorkSpace:
    211659image-2021-01-21-001657.png
  5. Select after Enter interpreter path...:
    212011image-2021-01-21-002010.png
  6. 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 :

201556Capture-d-ecran-2021-01-20-214039.

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:

202028unknown.png

 

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 ❤️ 

 

 

Github

 

Takuma.

  • Metin2 Dev 6
  • Love 10
Link to post
  • Moderator

spacer.png

 

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'.

  • Love 4
Link to post
16 minutes ago, VegaS™ said:

spacer.png

 

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! :)

  • Metin2 Dev 1

We are the tortured.
We're not your friends.
As long as we're not visible.
We are unfixable.

Link to post
  • Moderator
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

 

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 by VegaS™
  • Love 3
Link to post
  • Engineer

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.

  • Love 3
Link to post
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 by Takuma
  • Love 1
Link to post
14 hours ago, VegaS™ said:

spacer.png

 

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.

Link to post

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.

 

 

  • Love 1
Link to post
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 post
  • Moderator
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 by VegaS™
removed code tag
  • Love 3
  • Confused 1
Link to post
  • Honorable Member

Thank you, it's working great ❤️

 

You can add these two modules(EterPythonLib)

Spoiler

yrtqWv0.png

yCJ2bQw.png

Aoy6hJ8.png

wudbZZk.png

 

Edited by Mali61
  • Love 2

I'll be offline for a few months🌛

Link to post
2 hours ago, Mali61 said:

Thank you, it's working great ❤️

 

You can add these two modules(EterPythonLib)

  Hide contents

yrtqWv0.png

yCJ2bQw.png

Aoy6hJ8.png

wudbZZk.png

 

 

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.

  • Love 1
Link to post
  • Moderator
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.

 

 

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Activity

    1. 3

      Loading index and waypoint files like GF

    2. 222

      WorldEditor ReMIX

    3. 3

      Loading index and waypoint files like GF

    4. 3

      HWID ban

    5. 0

      Auth problem

    6. 2

      Starting a metin2 server on a VPS ?

    7. 3

      Client afk in background - Effects started to fun faster

  • Recently Browsing

    No registered users viewing this page.

Shoutbox

Shoutbox

Chatroom Rules

 

Join our Discord

A request for help = Shoutbox Ban

Be respectful & Respect the rules

 

×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.