MCLuaBukkit
Ever wanted to make a Bukkit plugin, but didn't know how? Want to edit code in-game and test it right away? MCLuaBukkit allows use of the Bukkit API with Lua, a simple, yet powerful, scripting language.
Quick Start
Example Code
Overview
MCLuaBukkit provides a Lua VM with mappings to the Bukkit API, and a few ways to load code into the VM. It allows developers to create Bukkit plugins in Lua. This means plugins with less mistakes, more security, and smaller size. Here's an example of an MCLuaBukkit plugin:
events.onPlayerInteract:add(function(p) x,y,z = p:getTargetBlock(100) p:getLocation():lightning(x,y,z) end)
This simple plugin strikes lightning where players click. It could easily be made to work only for certain players. MCLuaBukkit provides 3 ways for server operators to load Lua plugins:
- By Files Files ending in ".lua" inside MCLuaBukkit's data folder will be loaded as Lua plugins.
- By Chat The /lua command will run Lua code in-game.
- By Book And Quill The /luaload command will run Lua code contained inside a book and quill.
Lua APIs Added
- Server API
- Event API
- Player API
- World API
- Config API
- Inventory API
Commands
- /lua <code> Runs specified code.
- /luaload Runs code from a book and quill in the player's hand.
Permissions
- mcluabukkit.lua Allows execution of Lua code in-game.

-
View User Profile
-
Send Message
Posted May 26, 2013Actually, test.txt inside the plugins folder gets loaded and works nicely (lightnings and explosions on click! Yay!)
About the config API thanks, I didn't see that part of the documentation, that's exactly what I need! ^^
-
View User Profile
-
Send Message
Posted May 26, 2013@Nixola97
Sorry, but MCLuaBukkit 0.63 actually hasn't been approved yet. Forgot to mention that... You'll have to wait for that to happen, and then you can use LuaJava. As for each script being assigned a folder, that has already been partially implemented. Using the config API, you can access YAML files in a script config folder. The full access from the IO Library would be nice, I'll have to consider that in the next release. Also, I noticed in your plugin folder layout example that you named the script "login.txt". Lua files have to end with ".lua" to be loaded by MCLuaBukkit.
-
View User Profile
-
Send Message
Posted May 26, 2013Hi, how can I read and write files using Java SE API with your mod?
Also, why don't you give each plugin a folder it can access using Lua's IO library? E.g:
--plugins
----MCLuaBukkit
------login.txt
------login
--------database //file that can be read and written to by the script login.txt
-
View User Profile
-
Send Message
Posted May 25, 2013Just uploaded 0.63, which allows you to enable the LuaJava API! This means you can directly call the Java SE API and Java Bukkit API from Lua. An example of doing this is on the Example Code page.
-
View User Profile
-
Send Message
Posted May 19, 2013@Ashall6549
Yes. We plan to eventually implement almost all of the Bukkit API events.
-
View User Profile
-
Send Message
Posted May 19, 2013@ndinventor
Awesome! Thanks! Edit: Are you guys planning any form of a 'GUI' set of hooks/events?
-
View User Profile
-
Send Message
Posted May 19, 2013@Ashall6549
To some extent, we already have support for block editing (setting the ID and data byte). When item and block metadata gets implemented, you should be able to do anything the Bukkit API can with Lua. As for commands, that has been a planned feature for a while now. I can work on both of these after I finish fixing some of the existing features.
-
View User Profile
-
Send Message
Posted May 19, 2013Sorry to ask, but I need to know. Are you guys planning any support for editing blocks and creating commands?
-
View User Profile
-
Send Message
Posted May 18, 2013@OrfulBiggun
Thank you for the encouragement. Also, sorry for not responding sooner. I will try to upload the next update sometime in the next few days. In response to your first question, I will gladly give more example code, and maybe even example plugins. As for enabling LuaJava, I will add an option for that in the next update.
-
View User Profile
-
Send Message
Posted May 17, 2013@OrfulBiggun
The certain player code would look like this:
-
View User Profile
-
Send Message
Posted May 14, 2013ndinventor - this plugin is the most exciting bukkit-related deal I've seen in quite some time. I started teaching myself java just so that I could write plugins, and didn't get very far (mostly due to time constraints, although java ain't exactly connect the dots or paint by numbers :-)) ... but if THIS could get off the ground? Wow. Just wow.
If you'd be so kind as to do two things ... one, could you please give us some more examples? Just a few ... like above, for the lightning plugin, you say "could easily be made to work only for certain players" ... would you mind showing us how easy that is? :-) Cuz I had no trouble getting the lightning to work, even changed it around so that the bolt strikes for every player movement, etc., but nothing I did for the specific player worked at all.
By the way I'm not asking you to explain the code in that lightning plugin! Any little bit will help ...
Second ... I see down there you talking about enabling LuaJava API, so that we could have, for instance, FILE capabilities. Is that something you'd like to do, maybe soon?
Reason I'm asking about these things is I'd love to use this plugin for a whole host of things on a UHC server. Just for instance, I'd love to be able to write the x,y,z coordinates of every player (along with the player name) out to a file ... say, every 10 minutes or so. Having a log of coords, by player, would help us after the match with doing all kinds of neat things.
Right now I'm trying to do this by just writing the coords and player name to the console every ten minutes (I can pull all of that out of the log later). I think this will be possible, just not having much luck with it ...
Anyway yeah, great (seriously) stuff here, really good stuff ... please keep working; I'm testing it as we speak (as well as I'm able). :-) Thanks for your time!
-
View User Profile
-
Send Message
Posted May 12, 2013@ZxiAMN3X
Actually thought of that. I'll probably add that soon.
-
View User Profile
-
Send Message
Posted May 11, 2013I suggest a reload command for the servers with a lot of plugins.
-
View User Profile
-
Send Message
Posted May 9, 2013@NodexServers
I guess the best option might be to make it possible to enable the LuaJava API. This will allow Lua plugins to use the Java SE API, which provides sockets, files, etc. You should be able to load some kind of MySQL library with that. Lua plugins are very limited with IO right now to ensure that they are safe, and will not be able to mess anything up (besides the Minecraft server itself).
-
View User Profile
-
Send Message
Posted May 9, 2013@ndinventor
A way to communicate to the outside world beyond fs level would be most appreciated. If you can manage to shove some type of mysql, socket, memcached or anything .... it would be most appreciated.
The act of commuinicating to outside systems and api's is very limited at the moment.
-
View User Profile
-
Send Message
Posted May 6, 2013@NodexServers
The module system is disabled for security reasons. I'll try and figure out a way to safely allow functionality similar to the module system.
-
View User Profile
-
Send Message
Posted May 5, 2013How would I go about getting other modules loaded? I receive an error when I try to load modules that I have installed.
-
View User Profile
-
Send Message
Posted Apr 28, 2013@SuperWeegee1
Oh I see... I should of read the documentation more carefully :P
-
View User Profile
-
Send Message
Posted Apr 28, 2013@lieudusty
There is a schedule function that will run a function after a certain amount of ticks.
Runs the function "derp" after 40 ticks (2 seconds)
-
View User Profile
-
Send Message
Posted Apr 28, 2013Awesome plugin! I've always wanted to code a plugin but I don't know Java.
EDIT: I tried out the plugin its great but was it intended for there to be no sleep function?