Brickcraft Mod Loader โ€“ Developer Documentation

๐Ÿ“ Folder Structure

Game/
โ””โ”€โ”€ assets/
    โ”œโ”€โ”€ lua/
    โ”‚   โ”œโ”€โ”€ main.lua
    โ”‚   โ””โ”€โ”€ modloader.lua
    โ””โ”€โ”€ mods/
        โ”œโ”€โ”€ mod0.lua
        โ””โ”€โ”€ mod1.lua

โš™๏ธ How It Works

Loads mod0.lua, mod1.lua, etc. from the mods/ folder at the end of main.lua.

local ModLoader = require "modloader"
ModLoader.load_mods()

๐Ÿงฑ Creating a Mod

๐ŸŒฒ Example: mod0.lua

print("[mod0] Tree Mod Loaded")

AddCommand("tree", "Spawns a tree", 0, ServerCommand.SecurityLevel0)

function tree(connector)
   for i = 1, 5 do
      ServerInstance:ImportTestLXFML()
   end
   connector:Print("Spawned a tree!")
end

๐Ÿ”ง Useful Modding Functions

๐Ÿš€ Advanced Example: Jetpack Mod

This is an unused item script in the games code.

class 'JetPack' (Item)
function JetPack:__init()
  Item.__init(self)
end

function JetPack:Update(dt, player)
  local vec = Vector3(0, dt * 10, 0)
  player:PushPlayer(vec)
end

tItem = JetPack()

AddCommand("addjetpack", "Give jetpacks", 0, ServerCommand.SecurityLevel0)
function addjetpack(connector)
  for player in EntityManager.Players do
    player:SetItem(tItem)
  end
  connector:Print("Jetpacks equipped!")
end

๐Ÿ› ๏ธ Installing / Uninstalling Mods

Use the Mod Loader Manager app to install or uninstall the loader.

๐Ÿ”’ Command Security Levels

Its not very clear what these effect, but they do exist.

LevelConstant
All PlayersServerCommand.SecurityLevel0
AdminsServerCommand.SecurityLevel1
Super AdminsServerCommand.SecurityLevel2

๐Ÿ’ก Tips

๐Ÿงช Built-in Commands

CommandDescription
/listcommandsLists all commands
/msgSends message to all
/spawnentitySpawns physics object
/importlxfmlImports base64 LXFML
/undoimportUndo last import