Wiki 9Minecraft Wiki 9Minecraft
Nodeworks Wiki › Guides › Write a Lua Script to Automate Item Sorting

Write a Lua Script to Automate Item Sorting

Open the Scripting Terminal

Place a Scripting Terminal connected to your network and right-click it. This opens an in-game Lua editor with autocomplete, syntax highlighting, and hover documentation to guide you.

Access Network Functions

Your script can query connected storage, check item quantities, and trigger crafting or movement routines. Use the built-in documentation to see available functions—hover over keywords to learn what each command does.

Write a Simple Sorting Routine

Start with a basic script that checks if a specific item exists in your network, then moves it to a designated storage block. For example, you might sort all ores into one chest and ingots into another.

Test and Debug

Run your script and watch the Diagnostic Tool to see what's happening. If items aren't moving as expected, check the error log in the Scripting Terminal. Adjust your conditions and try again.

Tip: Start with simple scripts before building complex multi-step routines. Test each function individually to ensure it works before combining them.