LuaDatapack

Quick rating

LuaDatapack

No reviews yet

A simple mod that allows lua to be included in datapacks

API/Library
Mod Loaders
Fabric
Minecraft

Community voices

Reviews

Versions
Loading versions…
Match includes

Click once to include, again to exclude, again to clear

Rating Any
Any 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0
Min
Max
Play Status
Reviews
Time Played
hrs+
Verified developers only
Has developer response
List view
Grid view
Compact view
Sort by
Date
Rating
Helpful
Unhelpful
Edited
Sort ascending
Delete this review?

This removes your review from the project. You can write a new review after.

Review submitted for moderation

Your review has been sent to moderators, who will check that it meets our guidelines before it appears publicly.

No reviews yet. Be the first to review this project!

Get it on

Available Platforms

Compatibility

Supported Environments

Where It Runs
Server Only

Runs entirely on the server. Also works in singleplayer.

About

Project Details

Type
Mod
License
MIT License
Authors

For authors

Embed Badge

If you're the author of this project, you can embed a live badge anywhere that supports HTML or Markdown. It updates automatically whenever ratings change.

Custom banner text
ModDex rating badge preview

Use HTML for any page that supports it, or Markdown for README files and Markdown-based descriptions.

Identifiers

Platform IDs

Modrinth ID

Resources

External Links

About

Description

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

Screenshots

Gallery

This project has no gallery images yet.

Versions

Files

Relations

Project Relations

More like this

Similar Mods

Suggestions use data such as tags, dependencies, dependents, descriptions, titles, and more to rank how much they overlap with this mod.

On ModDex

Community snapshot

0
Ratings
0
Followers
0
In stacks

By the numbers

Statistics

~1,000
Downloads
Last Updated
CurseForge
Created
Last synced
When ModDex last fetched this project from CurseForge or Modrinth. Every project is re-checked on a schedule, and any project that ships a new file is synced automatically within hours of the release.
New file updates sync automatically
How syncing works