ModEngine is a simple and powerful library that enables Lua scripting support in any Java application. It’s perfect for adding modding support to your games or tools — letting users write custom behavior in Lua, safely and easily.
- ✅ Lightweight and dependency-free (based on LuaJ – pure Java)
- 🧠 Register your own Java functions and objects to be called from Lua
- 📜 Run Lua scripts from files or inline strings
- 📂 Load mod scripts from a folder
dependencies {
implementation("com.yourgroup:luamodengine:1.0.0") // Replace with real coordinates
}
<dependency>
<groupId>com.yourgroup</groupId>
<artifactId>luamodengine</artifactId>
<version>1.0.0</version>
</dependency>
Requires Java 8+ and no native libraries.
🚀 Getting Started Initialize the engine:
ModdingEngine engine = new ModdingEngine();
Register a custom Java function:
engine.registerFunction("sayHello", new OneArgFunction() {
@Override
public LuaValue call(LuaValue name) {
System.out.println("Hello, " + name.tojstring() + "!");
return LuaValue.NIL;
}
});
Run inline Lua code:
engine.runScript("sayHello('world')");
Or load a Lua script file:
engine.runScript(new File("mods/my_script.lua"));
📁 Mod Folder Support You can automatically load all .lua scripts in a folder:
engine.loadAllMods(new File("mods/"));
🧪 Example Lua Script
local id = spawn("dragon")
print("Spawned entity with ID: " .. id)
🛡️ Security Consideration This engine does not sandbox Lua by default. Be cautious when executing third-party scripts and consider running them in a restricted environment or process.
🤝 Contributing Contributions, bug reports and feature requests are welcome!
Fork this repo
Create a branch
Submit a PR
📄 License MIT – free for personal and commercial use.
🧠 Inspired by LuaJ
Classic modding frameworks for Minecraft and other games
💬 Contact Feel free to reach out via GitHub Issues or open a discussion for feature ideas.