Vice City: Multiplayer

Server Development => Community Plugins => Topic started by: ysc3839 on Aug 26, 2017, 10:38 AM

Title: Python plugin
Post by: ysc3839 on Aug 26, 2017, 10:38 AM
I decided to write this because IRC bot written in Squirrel is buggy. And I don't like reinventing the wheel. So I choose Python since it has many useful libraries.

An IRC bot sample: https://gist.github.com/ysc3839/76418598bb6dd907c227bc7487fe269d
Unlike other plugins, this plugin exposes original functions to Python. Peoples can warp the functions as they like.

Project repository:
https://github.com/ysc3839/vcmp-python-plugin

Test code:
https://github.com/ysc3839/vcmp-python-test

1.0 released: https://github.com/ysc3839/vcmp-python-plugin/releases/tag/v1.0

Note: You may need to rename this plugin because the server can't take long filename.
Title: Re: [WIP] Python plugin
Post by: . on Aug 26, 2017, 11:06 AM
Heh, wanted to do this myself a few days ago when I looked at the state of that binding library. But then I realized I hate Python's syntax :D
Title: Re: [WIP] Python plugin
Post by: Mahmoud Tornado on Aug 27, 2017, 07:28 PM
Quote from: . on Aug 26, 2017, 11:06 AMHeh, wanted to do this myself a few days ago when I looked at the state of that binding library. But then I realized I hate Python's syntax :D
Nice Name
Title: Re: Python plugin
Post by: ysc3839 on Aug 08, 2018, 09:48 PM
Version 1.0 released. Only 64 bit builds now.
https://github.com/ysc3839/vcmp-python-plugin/releases/tag/v1.0

Test code:
https://github.com/ysc3839/vcmp-python-test
Title: Re: Python plugin
Post by: ℛḝξ☂ on Aug 09, 2018, 02:49 PM
Good luck with this project!
Title: Re: Python plugin
Post by: ysc3839 on Aug 09, 2018, 06:13 PM
Note: You may need to rename this plugin because the server can't take long filename.

31 characters length.
Plugin error >> dlopen() 'plugins/vcmp-python-plugin-cpy36-linux6.so' failed: plugins/vcmp-python-plugin-cpy36-linux6.so: cannot open shared object file: No such file or directory
Failed to load plugin: vcmp-python-plugin-cpy36-linux6
Title: Re: Python plugin
Post by: ysc3839 on Aug 14, 2018, 04:19 PM
1.0.2 released: download (https://github.com/ysc3839/vcmp-python-plugin/releases/tag/v1.0.2)

This version compatible with 04rel004.
If you call new functions it will raise "NotImplementedError: server does not implement this function".
And new callbacks do not exist.

Changed output name to vcmp-python-plugin-cpyxx-(rel/dbg)(32/64).
Title: Re: Python plugin
Post by: ysc3839 on Aug 15, 2018, 08:13 PM
Added automated builds.
Linux (https://ci.appveyor.com/project/ysc3839/vcmp-python-plugin/build/1/job/2cj10pf564d08igr/artifacts) Windows (https://ci.appveyor.com/project/ysc3839/vcmp-python-plugin/build/1/job/a10pm3fb5epe5sye/artifacts)
No 32 bit builds for Linux.
Title: Re: Python plugin
Post by: ysc3839 on Aug 16, 2018, 09:41 PM
Version 1.0.4:
Download: Linux (https://ci.appveyor.com/project/ysc3839/vcmp-python-plugin/build/3/job/q2irkc0ojyu9kocc/artifacts) Windows (https://ci.appveyor.com/project/ysc3839/vcmp-python-plugin/build/3/job/oj7i7g4dl48sghgt/artifacts)
Title: Re: Python plugin
Post by: ysc3839 on Mar 04, 2019, 06:57 PM
Add python type hints stub files (.pyi).
https://github.com/ysc3839/vcmp-python-plugin/commit/4ae6ea2c5e6c9e29621f1de0927b9ff7bf820047

IDEs or editors can read type informations from these files and will not show an "unable to import" error.
If you are using vscode, you need to disable "python.jediEnabled" because jedi ignores .pyi files, or rename .pyi to .py.
Title: Re: Python plugin
Post by: ysc3839 on Mar 13, 2019, 03:23 PM
Version 1.0.5:
Download: https://github.com/ysc3839/vcmp-python-plugin/releases/tag/v1.0.5
Title: Re: Python plugin
Post by: D4rkR420R on Mar 13, 2019, 04:23 PM
Quick question, @ysc3839 . Would it be possible for a Squirrel script and a Python script to communicate back to each other? Let's say I want to do an operation on Python by accessing one of the libraries from my Squirrel script. Would this be okay?
Title: Re: Python plugin
Post by: ysc3839 on Mar 13, 2019, 04:44 PM
@DarkRaZoR^ #11 Yes it's possible.
VCMP has built-in functions for plugin communication. However the squirrel plugin doesn't implement such function.
So available options are:
I think the last one is easiest. There's a socket plugin for squirrel.
Title: Re: Python plugin
Post by: D4rkR420R on Mar 13, 2019, 07:30 PM
Quote from: ysc3839 on Mar 13, 2019, 04:44 PM@DarkRaZoR^ #11 Yes it's possible.
VCMP has built-in functions for plugin communication. However the squirrel plugin doesn't implement such function.
So available options are:
  • Modify squirrel plugin to implement this function.
  • Make another plugin as squirrel extension to implement this function.
  • Use another communication mechanism. For example: network.
I think the last one is easiest. There's a socket plugin for squirrel.

How would I send information from the Squirrel script to the Python script, with the usage of sockets? I have never messed with Unix sockets before. :o Is there a socket library for Python?
Title: Re: Python plugin
Post by: dracc on Mar 13, 2019, 08:24 PM
Quote from: DarkRaZoR^ on Mar 13, 2019, 07:30 PM
Quote from: ysc3839 on Mar 13, 2019, 04:44 PM@DarkRaZoR^ #11 Yes it's possible.
VCMP has built-in functions for plugin communication. However the squirrel plugin doesn't implement such function.
So available options are:
  • Modify squirrel plugin to implement this function.
  • Make another plugin as squirrel extension to implement this function.
  • Use another communication mechanism. For example: network.
I think the last one is easiest. There's a socket plugin for squirrel.

How would I send information from the Squirrel script to the Python script, with the usage of sockets? I have never messed with Unix sockets before. :o Is there a socket library for Python?

Yes. The "socket" package. Further discussion of this should probably take place elsewhere as this subforum is not meant for programming help.