Lua Scripts
Lua Scripts
Lua Scripts is an open source Bukkit server plugin that allows you to run .lua files via LuaJava. It creates an API that allows developers to interact with the Bukkit server API from within Lua.
INACTIVITY
You may have noticed that I've set the project's state to inactive. This isn't because the project is incompatible with later versions of Bukkit, but because I've had to stop development for a bit due to school pressure building up (big exams this year). The code is 100% open-source, and so anyone willing to take up the reigns can make a fork on GitHub and start hacking away :)
I might pick this up again if I can, but I'm not sure.
Installation
- Navigate to the Files section of the project.
- Download the version of Lua Scripts that you want (generally the latest one).
- Regardless of what your server is running, open the zip file and extract the plugins folder to your server's main directory.
- Optional Step If you are already experienced with the Lua Scripts API then delete the example.lua file from the plugins/lua-scripts directory.
Required
Lua Scripts relies on a native library too, LuaJava. What this means is that Lua Scripts will not function unless you compile the LuaJava library and place the .dll/.so in the server's main directory. Luckily, it's not a too complicated process and you only have to do it once. In addition to this you could probably find precompiled binaries somewhere on the internet, I know that the LuaJava page on keplerproject.org actually has prebuilt Win32 ones.
Once compilation is complete, regardless of the extension of the file (.dll/.so etc) to rename it to luajava-1.1 (keeping the extension). If you don't do this, Lua Scripts will not be able to find the native libraries.
Lua Scripts is now set up, and will run any .lua script placed in the plugins/lua-scripts directory.
Updating
- Navigate to the Files section of the project.
- Download the version of Lua Scripts you wish to upgrade to.
- You can downgrade to a different version, but remember to remove new features from your script.
- Open the zip file and extract the plugins folder to your server's main directory.
- You may want to follow the optional step in installation, so that example.lua is not executed.
Repository
Lua Scripts is an open source project, and as such you can download the whole source from our GitHub repo.
Lua Developers
If you are interested in creating Lua scripts to use in conjunction with this plugin, the best place to start would be on this page, you should then look through what other pages there are to find out more.
Documentation is a work in progress, so don't expect much.
Java Developers
For any Java Developers interested in working on this project with me, the best thing to do would be to create a fork of the GitHub repo and start hacking away at it. You could also try getting in contact with me via email ([email protected]).
@ray73864
I have a lot of exams going on this year, and I seldom find any time for myself let alone time to develop this. The GitHub repository still exists, and it's not exactly complex either :)
Why is this now marked as 'Inactive'?
@psychoelectro
No sorry, I probably didn't explain it very clearly. When for example, you get a player from an Event object that has been passed to a callback, that "player" is actually a Lua table with all the functions that the equivalent Java object would have. In that sense, most of the bukkit documentation is applicable to this. The first script page is just to show you an example of how to use events, whereas the events just lists the events available.
So yeah, with whatever objects you are passed you should be able to do the equivalent of what you could do in Java with them, but in Lua.
If that wasn't clear enough - and I apologise if it wasn't - you could maybe tell me what you are trying to accomplish and I'll give you an example.
Cheers :)
Are sending messages to players, broadcasting and kicking players the only thing a script can do? I tried finding a documentation everywhere but only found the events and the "First Script" documentation.
Thank you in advance.
@ray73864
I see, I'm going to have to have a proper look at Vault then and see what I can come up with. I'll report back here once I've worked something out.
About the dll, this is indeed an annoying issue & the only work-arounds I can think of are to either compile a 64-bit version of LuaJava or use a 32-bit JVM.
However, I am currently also looking into moving away from LuaJava and onto something like LuaJ which is entirely Java-centric, which I think would make more sense and be much better in the long run.
hrmm, i can't test this on my own computer, because the only precompiled luajava-1.1 dll file is for win32 not 64bit windows.
When i try to run the win32 version it throws lots of lovely messages up on the console.
@Derel1ct
Vault does indeed have publicly exposed methods, it is an API that other plugins can use to talk to the many different types of econ and permissions plugins that are out there.
How would i do the casting?
We also use TagAPI and SyncAPI which all expose methods publicly for other plugins to utilise.
@ray73864
My apologies, I misinterpreted what you said. In these plugins, do you know if the main class that extends JavaPlugin has any publicly exposed methods that would allow you to do this? Because I think you can get a handle on the JavaPlugin and then cast it to it's object (VaultPlugin or whatever that may be).
If not, then I don't see any way of interacting with that mod from the Lua script. I guess if the plugin author decided to make Lua Scripts an optional dependency, and then expose certain methods to Lua that would allow what you want it could work.
except they won't have the permission 'moderator', they will be in a group 'moderator' which requires access to a permissions plugin or vault, since SuperPerms doesn't support groups.
@ray73864
Interacting directly with other plugins' in-house methods is not really doable, the most you can do with the current Lua Scripts API is get a handle on the JavaPlugin. I suppose you could cast it, and from there any methods exposed publicly you have access to.
Other than that though, your code is possible and is shown below (roughly).
Can you reference installed plugins with this? like, i have vault installed, can i use the functionality of vault in my lua script?
Was thinking, if i could, then i could do something like (and this is pseudocode since i don't actually know any lua yet):
onPlayerJoin if player is in the permissions group "moderator" then broadcast this connection message "Moderator %player% has connected. They are here to help you!"
@Gamecube762
Thanks, it means a lot to me :) I haven't pushed a new version yet because I'm currently bogged down in school work (GCSEs this year :(), but it should pick up soon :)
@Derel1ct
Thank you, i was looking for the .dll for hours just so i can have this plugin on my server, i see why you dint link to one, but telling us a way on how to get it would still save time, Still a great plugin, ill be using it alot!
@Gamecube762
I don't think I'm directly allowed to link one due to the nature of DLLs.. but I'm sure if you look on the LuaJava release page (http://files.luaforge.net/releases/luajava/luajava) there's a Win32 binary :)
The plugin sounds cool and would be realy useful, but the main problem i have with it right now is finding that 'luajava-1.1.dll'. It would be nice if you had a link to one so the plugin can be used.
For anyone who's interested, if you look under the pages section I created a "Your first script" page - it's definitely worth a read, in my opinion :)
@BradleyDS2
I quite like that idea actually, it could create some interesting traps or contraptions :) For a day or so I'm going to stall development and work on getting some decent documentation up and running, as I find that the example provided is quite lacking.
Idea alert: Try and make it so that you can set a lua file to run on right click of a set block, eg if I am looking at a cobblestone and type something like /lua set testscript then it sets testscript.lua to run when you right click that block.
Basically like computercraft with no mods and no interface :)
Niiice! I asked if someone would make this on IRC a week ago and nobody responded, but turns out someone was making it before I said that! Nice work!