Introduction to Scripts
Learn what scripts are and how they work
What are Scripts?
Scripts are JavaScript modules that generate and manipulate Minecraft structures.
They provide a powerful, programmatic way to create complex builds, process data, and automate construction tasks.
What Can You Build?
Procedural structures (castles, houses, bridges)
Data-driven builds from CSV/JSON files
Terrain generation and modification
Pattern-based decorations
Complex geometric shapes
Key Features
Modern ES6+ JavaScript syntax
Type-safe schematic operations
Built-in utilities (Logger, Calculator)
File upload support (CSV, JSON, images)
Real-time 3D preview
Basic Script Structure
Every script follows the same basic structure with two required exports:
Basic Script Template
export const io = {
inputs: {
// Define your input parameters here
},
outputs: {
// Define what your script returns
}
};
export default async function(inputs, context) {
// Your script logic goes here
const { Logger, Calculator, Schematic } = context;
return {
// Return values matching your outputs schema
};
}
Required Exports
io
- Defines inputs and outputsdefault function
- Main script logicPro Tip
Use destructuring to access context utilities and input parameters for cleaner, more readable code.
Simple Example: Building a Wall
Here's a complete example that builds a simple wall:
wall-builder.js
export const io = {
inputs: {
width: {
type: 'int',
default: 10,
min: 1,
max: 100,
description: 'Width of the wall'
},
// ... more inputs
},
outputs: {
schematic: { type: 'object' },
summary: { type: 'object' }
}
};
export default async function({ width, height, material }, { Logger, Schematic }) {
Logger.info(`Building wall: ${width}x${height}`);
const schem = new Schematic();
let blocksPlaced = 0;
// Build the wall
for (let x = 0; x < width; x++) {
for (let y = 0; y < height; y++) {
schem.set_block(x, y, 0, material);
blocksPlaced++;
}
}
return { schematic: schem, summary: { blocksPlaced } };
}
Next Steps
Now that you understand the basics, explore the other sections to learn about:
Input/Output schema definitions
Advanced schematic operations
Context utilities and helpers
Complex patterns and techniques
↵
select
↑↓
navigate
esc
close
5 results
1 plugins loaded