HomeJavaModsLuaDatapack
LuaDatapack
ModsJava

LuaDatapack

by kinderhead · on Modrinth

Which Minecraft do you have?

Every version of the game needs its own build. Pick yours, then download — the wrong build installs fine and then does nothing in the game. This mod is built for Fabric only.

⬇ Download for 1.20–1.20.1⬇ Download for 1.19.4⬇ Download for 1.19
I don't know my version or loader
Open the Minecraft launcher and look at the profile you play on — it names both, like fabric-loader-1.21.4. The version also shows in the bottom-right corner of the game's main menu.
No loader in the profile name? Then it's plain Minecraft, and these mods won't run — you need Fabric or NeoForge installed first.

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

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

Planned features

Links

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

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

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

Quick facts

Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.

Verified by MCModsHub

These come from our own check of the pack file, not from the source page.

Explore more