collection of custom scripts written in Lua for ComputerCraft turtles
- Lua 90.7%
- Shell 9.3%
Refactored bundling script to ensure the archive directory is created before archiving bundles, preventing potential errors during archival. Updated dependency processing to remove return statements from dependencies, ensuring bundled scripts behave correctly when merged into a single file, and fixed require call replacements to correctly reference dependencies without unintended variable expansions. Removed obsolete bundled script files to maintain repository cleanliness. feat(lib): enhance pickup and movement libraries with deep collection and step callbacks Added a deepCollection function to pickup library enabling thorough item collection by rotating and sucking in all directions, improving collection coverage for complex scenarios. Updated movement.go to accept an optional callback invoked after each movement step, allowing customized actions during navigation, which enables integrated functionalities like automatic item collection during movement. test: improve test setup for movement and pickup libraries Enhanced test setup to explicitly reset movement states and pickup configurations before each test, ensuring clean and consistent test environments to prevent state leakage between tests and improve reliability of integration and unit tests. chore: add debug utility module for enhanced debugging output Introduced a dbg module providing controlled debug print functions that are enabled or disabled globally, helping developers trace internal state and computation values without cluttering normal output, thereby simplifying debugging and development workflows. feat: add treefarm_menril automation script with bundled dependencies Implemented a comprehensive tree farming automation script for menril trees that monitors growth, harvests trees in 3D, collects drops, and replants saplings, running continuous farming cycles with error handling and debug logging to facilitate automated resource gathering in-game. build: add mv.lua module to simplify movement require calls Added mv.lua as a simple wrapper module for requiring the movement library, enhancing code readability and requiring convenience in scripts. |
||
|---|---|---|
| bundles | ||
| lib | ||
| spec | ||
| test | ||
| .busted | ||
| .gitignore | ||
| .luacheckrc | ||
| bundle.sh | ||
| certus3.lua | ||
| certusquartz.lua | ||
| mv.lua | ||
| quarry.lua | ||
| README.md | ||
| sugarcane.lua | ||
| treefarm_2x2_simple.lua | ||
| treefarm_menril.lua | ||
ComputerCraft Automation Scripts
A collection of Lua scripts for ComputerCraft turtle automation, including mining, farming, and resource collection.
Quick Start
For ComputerCraft Deployment:
# Prepare files for ComputerCraft
./deploy.sh
# Then drag and drop files from deploy/ directory to ComputerCraft
# Or use pastebin method (see deployment section below)
For Development/Testing:
# Run tests (requires luarocks and busted)
export PATH="$HOME/.luarocks/bin:$PATH"
export LUA_PATH="$HOME/.luarocks/share/lua/5.4/?.lua;$HOME/.luarocks/share/lua/5.4/?/init.lua;;"
export LUA_CPATH="$HOME/.luarocks/lib/lua/5.4/?.so;;"
busted
Scripts
Core Libraries
- movement.lua - Position tracking and pathfinding
- pickup.lua - Item collection patterns (spiral, grid, circle, line)
Automation Scripts
- quarry.lua - Configurable mining with trash filtering
- treefarm_2x2_simple.lua - 2x2 tree farm automation
- sugarCane.lua - Sugar cane farming with paper crafting
- certus3.lua - Advanced Certus Quartz mining
- certusQuartz.lua - Simple Certus Quartz mining
Deployment to ComputerCraft
Method 1: Drag and Drop (Recommended)
- Run
./deploy.shto prepare files - Open the
deploy/directory - Drag and drop files to ComputerCraft computer
Method 2: Pastebin/Wget
- Upload files from
deploy/to pastebin - In ComputerCraft:
wget <pastebin-url> movement.lua wget <pastebin-url> pickup.lua wget <pastebin-url> your_script.lua
Method 3: Direct Copy
Copy file contents from deploy/ directory and paste into ComputerCraft editor.
Usage Examples
Basic Mining
-- In ComputerCraft
quarry
-- Follow prompts for dimensions and trash items
Tree Farming
-- In ComputerCraft
treefarm_2x2_simple
-- Ensure saplings in slot 1, optional bonemeal in slot 2
-- Place chest below turtle
Using Pickup Library
local pickup = require("pickup")
-- Spiral collection pattern
pickup.spiral(3, 0, 0) -- radius 3 around position 0,0
-- Grid collection pattern
pickup.grid(5, 5, 0, 0) -- 5x5 grid starting at 0,0
-- Custom collection function
pickup.setCollectionFunction(function()
turtle.suck()
turtle.suckUp()
-- custom logic here
end)
Development
Project Structure
lib/ # Core libraries (for development)
├── movement.lua # Movement and pathfinding
└── pickup.lua # Item collection patterns
spec/ # Tests (busted framework)
├── movement_spec.lua # Movement tests
├── pickup_spec.lua # Pickup pattern tests
└── integration_spec.lua # Integration tests
test/ # Test infrastructure
├── mocks/ # Mock turtle/os APIs
└── helpers/ # Test utilities
deploy/ # ComputerCraft-ready files
├── movement.lua # Flattened for CC compatibility
├── pickup.lua # Flattened for CC compatibility
└── *.lua # All scripts ready for deployment
Testing
The project includes comprehensive tests that run without ComputerCraft:
# Install dependencies (one time)
luarocks install --local busted
luarocks install --local luacheck
# Run tests
busted
# Run linting
luacheck lib/ spec/
Adding New Scripts
- Create script in root directory
- Use
require("lib.movement")andrequire("lib.pickup")for development - Run
./deploy.shto prepare ComputerCraft-compatible versions - Test in ComputerCraft
Features
Movement Library
- Position tracking (X, Y, Z coordinates)
- Direction management (FW, RI, LE, BK)
- Smart pathfinding with obstacle clearing
- Bug fixes applied (original line 202 issue)
Pickup Library
- Multiple collection patterns:
- Spiral: Expanding spiral from center point
- Grid: Systematic row-by-row coverage
- Circle: Circular collection pattern
- Line: Linear collection in any direction
- Compact: Dense square coverage
- Configurable collection functions
- Optional return-to-home behavior
- Pattern visualization for testing
Error Handling
- Comprehensive mock system for testing
- Error recovery patterns (see certus3.lua)
- Fuel management considerations
- Obstacle detection and clearing
Contributing
- Make changes in
lib/directory for libraries - Add tests in
spec/directory - Run
bustedto verify tests pass - Run
./deploy.shto update deployment files - Test in ComputerCraft
Known Issues
- Original movement.lua had bug at line 202 (fixed in lib version)
- Some scripts lack comprehensive error handling
- No fuel management in most scripts
- Pattern visualization only works in test environment