dflua
raw JSON → 1.0.2 verified Fri May 01 auth: no javascript
A Lua-to-DiamondFire transpiler, version 1.0.2. Converts Lua code into DiamondFire code blocks for use within the Minecraft server plugin DiamondFire. No release cadence documented. Key differentiator: enables DiamondFire developers to write code in a higher-level language (Lua) instead of graphical blocks. Minimal documentation and low adoption.
Common errors
error Error: Cannot find module 'dflua' ↓
cause Package not installed or not in node_modules.
fix
Run
npm install dflua to install the package. error TypeError: dflua.transpile is not a function ↓
cause Import style mismatch: using default import when only named exports exist.
fix
Use
import { transpile } from 'dflua' instead of import dflua from 'dflua'. error SyntaxError: Unexpected token 'export' ↓
cause Running ESM code in a CommonJS environment (e.g., older Node without 'type':'module').
fix
Add
"type": "module" to package.json or use .mjs extension. Warnings
breaking Output format changed from JSON to string in v1.0.0 ↓
fix Update code that expects JSON output to parse the string or handle string format.
deprecated Option 'target' is deprecated; use 'output' instead. ↓
fix Replace `target: 'codeblocks'` with `output: 'codeblocks'`.
gotcha Only supports a subset of Lua 5.1; tables and metatables are not implemented. ↓
fix Avoid using advanced Lua features until they are supported.
Install
npm install dflua yarn add dflua pnpm add dflua Imports
- transpile wrong
const dflua = require('dflua'); dflua.transpile()correctimport { transpile } from 'dflua' - compileFile wrong
import dflua from 'dflua'; dflua.compileFile()correctimport { compileFile } from 'dflua' - DfluaError wrong
import { DfluaError } from 'dflua/errors'correctimport { DfluaError } from 'dflua'
Quickstart
import { transpile } from 'dflua';
const luaCode = `
function greet(name)
print('Hello, ' .. name)
end
greet('World')
`;
try {
const diamondFireCode = transpile(luaCode, { target: 'codeblocks' });
console.log(diamondFireCode);
} catch (err) {
console.error('Transpilation failed:', err.message);
}