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.