LuaDatapack

LuaDatapack

A simple mod that allows lua to be included in datapacks

by
1.4K Downloads
fabriclibraryutility
Rent Server with this Mod

About this Mod

Logo

Releases
Downloads

LuaDatapack

Allows lua scripts to be ran in Minecraft.

Note: LuaDatapack is in beta, so the api is subject to change.

I currently don't plan on working on this project much more. Instead I've been making a dedicated programming language that compiles to Minecraft commands called Amethyst. It's more useful than this because it doesn't require a dedicated mod.

Usage

Create a new datapack with the lua subfolder. For example: data/foo/lua/bar.lua.

Features

  • Uses Cobalt under the hood, which gives fast execution times
  • Scripts can be included from datapacks using require and use Minecraft's namespaced id system
  • TypeScriptToLua support
  • Supports a few common utility libraries

Commands

/lua

Usage: /lua <name> [<args>]

Example, to run data/foo/lua/bar.lua: /lua foo:bar

Arguments can be accessed via an array called args in the lua script.

Api

The api reference can be found here.

Standard library

A few utility libraries are included by default.

Library Path
json.lua std:json
class.lua std:class
Standard lua library std:math
Standard lua library std:string
Standard lua library std:bit32
Standard lua library std:utf8
Commands library std:commands
Storage library std:storage
Configuration utilities library std:config

Note: If you prefer a different OOP library, you can simply add one to your datapack.

Project system

There is a simple project system which allows for customization of which scripts can be executed and imported by external projects (scripts not in the same namespace).

To customize your project, add a _project.lua file to your namespace. For example if the namespace was foo then you would make a foo:_project.lua:

return {
    scripts = {"foo:bar"},
    exports = {"foo:baz"},
    depends = {"hello"},

    load = {"foo:load"},
    tick = {"foo:tick"}
}

In the above example foo:bar is a script to be ran via /lua, foo:baz is a script that any file can require, and it requires the hello project to function. Scripts can import any script in the same namespace, even if it is not included in the exports array. If a project does not include a _project.lua, then the default std:_default_datapack is used instead:

local config = require("std:config")

return {
    scripts = config.without_underscore(),
    exports = {}
}

Note: not all fields need to be explicitly defined.

If a project fails to load, all scripts in it are unable to load.

Contributing

Building this repo is the same as any other Fabric mod. There may be issues with libraries (Cobalt, Apache commons-io, etc) not loading when starting the game, but running the game though the VSCode debugger works for some reason.

Things to do

  • Optimize lua api
  • Add more api features
  • Use commands less internally

Planned features

Links

Source: https://github.com/kinderhead/LuaDatapack

Modrinth: https://modrinth.com/mod/luadatapack

Api reference: https://kinderhead.github.io/LuaDatapack

Available Versions

0.11.0-betabeta
MC 1.20, 1.20.1fabric
June 15, 2023
0.10.2-betabeta
MC 1.19.4fabric
June 5, 2023
0.10.1-betabeta
MC 1.19.4fabric
June 1, 2023
0.10.0-betabeta
MC 1.19.4fabric
June 1, 2023
0.9.0-betabeta
MC 1.19.4fabric
May 30, 2023

How to Install LuaDatapack on Your Server

1

Order Server

Order a Minecraft Java server with at least 3 GB RAM (4 GB recommended).

2

Set fabric Loader

In the panel under "Egg", select the fabric loader and matching Minecraft version (1.20.1).

3

Install Mod

Open the mod browser in the dashboard and search for "LuaDatapack". Click "Install" – done! Alternatively, upload the .jar via SFTP to the /mods folder.

Compatibility

Mod Loaders

fabric

Minecraft Versions

1.20.1, 1.20, 1.19.4 (+1 more)

Server-side

Required

Recommended RAM

4 GB(min. 3 GB)

Frequently Asked Questions

LuaDatapack server crashes on startup – what to do?

Most common cause: wrong fabric version or insufficient RAM. Check the server log (latest.log) for "OutOfMemoryError" or "Mixin" errors. With Mado Hosting: ensure at least 3 GB RAM is allocated and the loader matches the mod version (1.20.1). You can switch loaders with one click in the panel.

Is LuaDatapack compatible with fabric?

LuaDatapack officially supports fabric for Minecraft 1.20.1, 1.20, 1.19.4. The Mado dashboard automatically detects incompatible loader combinations.

Server lagging with LuaDatapack – how to optimize performance?

Recommended RAM: 4 GB (per 8 players). Use /spark profiler to check if LuaDatapack consumes the most tick time. Common fixes: reduce server view-distance to 8-10, install "performant" or "starlight" as supplementary mods on Forge. With Mado Hosting, your server runs on NVMe SSDs with dedicated CPU cores for minimal latency.

Rent Modded Server

Install LuaDatapack with just one click on your server.

Recommended RAM
4 GBab €8/mo
Min. 3 GB | +1 GB pro 8 Spieler
Create Server Now
1-Click Mod Install
NVMe SSD Storage
DDoS Protection included

Details

License
MIT License
Server-side
Required

Supported Versions

1.20.11.201.19.41.19