PythonLoader 0.3.2
This plugin allows developers to code bukkit plugins in the python programming language. The plugins in python can either use a thin wrapper to the standard Bukkit API, or the newer decorator API. For more detailed instructions for installing this plugin and how to code plugins, take a look into the Readme on Github.
Features:
- Load bukkit plugins written in python.
Installation: Put PythonLoader.jar into plugins directory and jython.jar into lib directory (within bukkit folder not plugins folder).
Downloads:
- PythonLoader 0.3.2
- Jython (By downloading and using Jython you accept the Jython License)
- Source Code
Documentation
The Readme on github contains an introduction to creating plugins in python
Also make sure to check out @zaph34r's tutorial series
I have to give special credits to lahwran who created the whole decorator API and corrected many of my mistakes. :)
Facts
- Date created
- Aug 27, 2011
- Category
- Last update
- Apr 05, 2012
- Development stage
- Release
- License
- GNU General Public License version 3 (GPLv3)
- Curse link
- Python Plugin Loader
- Downloads
- 435
- Recent files
- R: PyPluginLoader-0.3.2.jar for CB 1.2.5-R1.0 Apr 05, 2012
- B: PyPluginLoader-0.3.1-Beta.jar for CB 1.1-R6 Mar 07, 2012
- B: PyPluginLoader-0.3-Beta.jar for CB 1.1-R1 Jan 29, 2012
- A: PyPluginLoader-0.3-Alpha.jar for CB 1.1-R1 Jan 28, 2012
- R: PyPluginLoader-0.2.jar for CB 1.0.1-R1 Oct 25, 2011
- Reply
- #34
zaph34r May 09, 2012 at 20:34 UTC - 1 like@Cwbh10: Go
Just create a .zip archive containing the .py and the .yml at root level (using 7zip or winzip or winrar, or whatever else),and rename it from .zip to .pyp or .py.zip :)
- Reply
- #33
Cwbh10 May 09, 2012 at 20:23 UTC - 0 likes@zaph34r: Go
Thanks a lot Zaph34r! That really help clear things up now, and I should be able to generate more accurate results xD!
So, will there be a place where we can post out plugins for others to see?
P.S. How do I create a zip the contains the yml and py that pyplugin loader will see, I've tried but it doesn't seem to see it. (Sorry for all the questions :P )
My Server: Mc.Cmonkeycraft.info :3
- Reply
- #32
zaph34r May 09, 2012 at 19:47 UTC - 1 like@Cwbh10: Go Ok so heres how the
globalkeyword works (according to my knowledge, which might be wrong :D ):print aora.foo()), you need to do nothing special, apart from not having a local variable of the same name shadowing it.a=0in global scope, and want to change that variable witha = 1, you need to explicitely declare the variable as a global variable withglobal a, because otherwise python would create a local variableaand assign the value1to it (which is the default). This local variable would shadow the globalauntil you leave the scope (the local variableawould cease to exist after that, and the global one would be unchanged) So basically,global atells python "do not create a new local variable a when i assign to that name later on in the current scope". So if you don't plan to assign anything new to the variable, you don't needglobal, that is why it works in your event handler if you just checkif immediate:You should also generally do all
globaldeclarations at the beginning of the scope in which you want to use them, and not somewhere in the middle, and not use any local variables of the same name before usingglobal, otherwise you get a syntax warning from the interpreter.There is also not a lot of stuff pre-imported, off the top of my hat, you can access:
Everything else you have to import, which is why the first few lines of any plugin i do are
since i use those all the time :)
There may be more pre-imported things in the future, i just today changed how the modification i did works, and that would allow for pre-loading certain boilerplate code automatically without lots of effort. I will look into that :)
- Reply
- #31
Cwbh10 May 09, 2012 at 19:12 UTC - 0 likes@zaph34r: Go
Oh, So I have to immediately define it as a global before each use? But wouldn't that break my function in the Event handler wouldn't it? Though it did work once I added the global in the command handler.
I've been able to get it to declare outside the onEnable but I still have to call it as a global in the command handler but not the event handler.... (Confused face)
I'm just slightly confused how globals are being handled throughout the program. No you're not bragging I just think your pretty boss xD
Thnxs for the help btw
P.S. Is there a list of pre-imported globals that Python does for me; I saw I had to import org.bukkit to access the colors which I thought was already done for me...
- Reply
- #30
zaph34r May 09, 2012 at 18:52 UTC - 0 likes@Cwbh10: Go
I certainly do hope i didn't come across as boasting :D The modified loader (that should be pulled into the main repository soon i think) does add a few things for convenience. There's a writeup of what it does here. The rationale behind the changes/additions was to make decorators work with instance methods, and the use of additional decorators was to change as little about the original python loader as possible, to avoid incompatibilities.
Regarding your problem with the globals:
This works for me, and is probably how you need to do it. I think
global immediateis used to access a global variable, not to define it. You just useimmediate = something, the keywordglobalis used to distinguish between accessing the global variable in the local scope and creation of a new local variable (and possibly shadowing a global one). You only need it when assigning to the global variable, since assignment would create a new local variable otherwise. When just accessing it (as i do here withprint immediatebeforeglobal immediate) it just looks for the name scope by scope until it either finds it,or doesn't find anything even in global scope, in which case it would throw a NameError.Regarding chat colors: use the bukkit.ChatColor enumeration, but remember that you cannot concatenate it with strings (since the ChatColor type doesn't have concatenation with strings defined), you need to format it in, like
- Reply
- #29
Cwbh10 May 09, 2012 at 18:03 UTC - 0 likes@masteroftime: Go I deleted the old code from the other plugin, but just ran into the same issue again. I've tried the global declaration in and out of the onEnable... It just limits what I can do ya know? Anyways, please try to attack me about my code's neatness xD
I get the error: " File "<iostream>", line 74, in immediates UnboundLocalError: local variable 'immediate' referenced before assignment"
But I don't see what it says it's local... I've also tried calling the global inside the same function, but in the previous function the global worked in a few functions before ceasing to work in later ones..
P.S. How do I get color in the chat for my plugin? I've looked around (e.g. http://jd.bukkit.org/doxygen/df/d1d/ChatColorTest_8java_source.html) but I still can't find a way to get it into my plugins...
- Reply
- #28
masteroftime May 08, 2012 at 16:34 UTC - 0 likes@Cwbh10: Go
Could you maybe post code which produces the error here or as a ticket?
- Reply
- #27
Cwbh10 May 07, 2012 at 15:21 UTC - 0 likesOkay, while I've been loving the PythonPlugin Loader, it hasn't been without it's faults.
I'm having a rather major issue in that the fact that I want to have global variables across my script, and for some reason after I declare the variable outside any function and set the variable in the onEnable() it isn't recognized in later functions. I also have tried putting the "global var" inside the onEnable() and it only seems to recognize the global for another 3 functions out of the 3+. I've spent many hours on this so if anyone could help that would be great! Besides that, PythonPlugin Loader as been a great tool!
Ps. @zaph34r what is this modified pythonplugin loader you boast about in your tutorial? What are the changes in using it. I've notice you write differently than I do in your examples... any reason for the choice?
- Reply
- #26
zaph34r May 03, 2012 at 14:04 UTC - 2 likesI have started a collection of Tutorials for Python Plugin Development, that might help some people getting started. They contain practical example plugins and a step-by-step walkthrough on how to create them and what each part does.
Feel free to direct any requests for additional tutorial topics or specific things that you would like to have explained in more detail to me and i will see what i can do :)
- Reply
- #25
Sithdown Apr 30, 2012 at 03:12 UTC - 0 likesTHANKS.
<3 Python.