Skip to content
TwijnPublic

About

Various libraries and programs for CC: Tweaked that don't quite need their own repository (yet)

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

421 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CC-Misc Utilities

Yes, a lot of the docs here are AI generated. Sorry.

A professional collection of utility modules for ComputerCraft that makes building complex programs easier, cleaner, and more maintainable.

Documentation License: MIT CC: Tweaked


Quick Start

Install any library with a single command:

wget run https://raw.githubusercontent.com/Twijn/cc-misc/main/util/installer.lua

This launches an interactive installer where you can:

  • ✨ Browse all available libraries
  • πŸ“– View detailed information (press RIGHT arrow)
  • πŸ”— Automatically resolve dependencies
  • πŸ“¦ Install to your computer

Or install specific libraries directly:

wget run https://raw.githubusercontent.com/Twijn/cc-misc/main/util/installer.lua formui persist log

Core Libraries

🎨 FormUI - Interactive Form Builder

Stop wrestling with terminal I/O - create beautiful UIs in seconds

local FormUI = require("formui")
local form = FormUI.new("Server Config")

local nameField = form:text("Server Name", "MyServer")
local portField = form:number("Port", 8080)
local enabledField = form:checkbox("Enabled", true)
local modemField = form:peripheral("Modem", "modem")

form:addSubmitCancel()
local result = form:run()

Features: Text/number/select fields, checkboxes, multi-select, lists, validation, peripheral detection, keyboard navigation


πŸ’Ύ Persist - Data Persistence

Save and load data with zero boilerplate

local persist = require("persist")
local config = persist("config.json")

config.setDefault("port", 8080)
config.set("name", "MyServer")
print(config.get("port")) -- 8080

Features: JSON/Lua serialization, auto-save, deep copy, automatic file creation


πŸ“ Log - Logging System

Professional logging with color-coded output and daily rotation

local log = require("log")

log.info("Server started")
log.warn("High memory usage")
log.error("Connection failed")

Features: Color-coded console output, daily log files, timestamped entries


⏱️ TimeUtil - Interval Management

Run tasks on schedules that persist across reboots

local timeutil = require("timeutil")

timeutil.every(function()
  print("Running backup...")
end, 600, "backup_last_run")

timeutil.run()

Features: Absolute and runtime-based intervals, persistent state, pretty formatting


πŸ”§ Tables - Table Utilities

Common table operations you always end up reimplementing

local tables = require("tables")

tables.includes(myTable, value)
tables.recursiveCopy(myTable)
tables.recursiveEquals(table1, table2)

βš™οΈ Settings (s) - Interactive Settings

User-friendly configuration with validation and peripheral detection

local s = require("s")

local modem = s.peripheral("modem", "modem", true)
local port = s.number("port", 1, 65535, 8080)
local name = s.string("server_name", "MyServer")

πŸ–₯️ CMD - Command Interface

Build REPL-style command processors with history and autocompletion

local cmd = require("cmd")

local commands = {
  hello = {
    description = "Say hello",
    execute = function(args, context)
      context.succ("Hello, " .. (args[1] or "World") .. "!")
    end
  }
}

cmd("MyApp", "1.0.0", commands)

πŸ’° ShopK - Kromer API Client

WebSocket client for Kromer cryptocurrency integration

local shopk = require("shopk")
local client = shopk({ privatekey = "your_key" })

client.on("transaction", function(tx)
  print("Received:", tx.value)
end)

client.run()

πŸ”„ Updater - Package Management

Keep your libraries up to date programmatically

local updater = require("updater")

-- Check for updates
local updates = updater.checkUpdates()

-- Update all packages
updater.updateAll()

🎯 Why CC-Misc?

Problem: Building CC programs is tedious

  • Writing terminal UIs is painful
  • Data persistence requires boilerplate
  • No standard library for common tasks
  • Managing dependencies manually
  • Updating code across multiple computers

Solution: Professional utilities

  • βœ… One-line installation - wget and go
  • βœ… Dependency resolution - Installer handles it automatically
  • βœ… Beautiful UIs - FormUI makes it easy
  • βœ… Professional docs - Full API reference with examples
  • βœ… Version management - Update with a single command
  • βœ… Battle-tested - Used in production servers

πŸ“– Documentation

Full documentation with API references, examples, and guides:

πŸ”— ccmisc.twijn.dev

Each library includes:

  • Detailed API documentation
  • Function signatures with types
  • Usage examples
  • Version information
  • Dependency information

πŸ› οΈ Installation Methods

Method 1: Interactive Installer (Recommended)

wget run https://raw.githubusercontent.com/Twijn/cc-misc/main/util/installer.lua

Method 2: Pre-select Libraries

wget run https://raw.githubusercontent.com/Twijn/cc-misc/main/util/installer.lua formui persist log

Method 3: Direct Download

wget https://raw.githubusercontent.com/Twijn/cc-misc/main/util/formui.lua formui.lua

Method 4: Programmatic Installation

local updater = require("updater")
updater.install("formui")

πŸ”„ Updating

Update All Libraries

local updater = require("updater")
updater.updateAll()

Update Specific Library

local updater = require("updater")
updater.update("formui")

Check for Updates

local updater = require("updater")
local updates = updater.checkUpdates()
for _, update in ipairs(updates) do
  print(update.name .. ": " .. update.current .. " -> " .. update.latest)
end

πŸŽ“ Examples

Example 1: Server Configuration Tool

Combine formui, persist, and log for a complete configuration system:

local FormUI = require("formui")
local persist = require("persist")
local log = require("log")

-- Load existing config
local config = persist("server_config.json")

-- Create configuration form
local form = FormUI.new("Server Configuration")

local nameField = form:text("Server Name", config.get("name") or "MyServer")
local portField = form:number("Port", config.get("port") or 8080)
local enabledField = form:checkbox("Auto-start", config.get("autostart") or true)

form:addSubmitCancel()

-- Run form and save results
local result = form:run()
if result then
  config.set("name", nameField())
  config.set("port", portField())
  config.set("autostart", enabledField())
  
  log.info("Configuration saved: " .. nameField() .. " on port " .. portField())
  print("Configuration saved!")
else
  log.warn("Configuration cancelled")
end

Example 2: Scheduled Task Manager

Use timeutil and log for automated tasks:

local timeutil = require("timeutil")
local log = require("log")

-- Backup every 10 minutes
timeutil.every(function()
  log.info("Running backup...")
  -- Your backup code here
  log.info("Backup complete")
end, 600, "backup_timer")

-- Status report every hour
timeutil.every(function()
  log.info("System status: OK")
end, 3600, "status_timer")

log.info("Task manager started")
timeutil.run()

Example 3: Interactive Admin Panel

Build a command-line admin interface:

local cmd = require("cmd")
local log = require("log")

local commands = {
  status = {
    description = "Show server status",
    execute = function(args, context)
      context.succ("Server running on port 8080")
    end
  },
  restart = {
    description = "Restart the server",
    execute = function(args, context)
      log.warn("Server restart requested")
      context.mess("Restarting...")
      os.reboot()
    end
  }
}

cmd("Admin Panel", "1.0.0", commands)

πŸ—οΈ Project Structure

cc-misc/
β”œβ”€β”€ util/                    # Core utility libraries
β”‚   β”œβ”€β”€ formui.lua          # Form builder
β”‚   β”œβ”€β”€ persist.lua         # Data persistence
β”‚   β”œβ”€β”€ log.lua             # Logging system
β”‚   β”œβ”€β”€ timeutil.lua        # Interval management
β”‚   β”œβ”€β”€ tables.lua          # Table utilities
β”‚   β”œβ”€β”€ s.lua               # Settings management
β”‚   β”œβ”€β”€ cmd.lua             # Command interface
β”‚   β”œβ”€β”€ shopk.lua           # Kromer API client
β”‚   β”œβ”€β”€ installer.lua       # Interactive installer
β”‚   └── updater.lua         # Update manager
β”œβ”€β”€ farm/                   # Example: Farming automation
└── docs/                   # Generated documentation

🀝 Contributing

Contributions are welcome! Please feel free to:

  • πŸ› Report bugs
  • πŸ’‘ Suggest new features
  • πŸ“ Improve documentation
  • πŸ”§ Submit pull requests

πŸ“œ License

MIT License - see LICENSE for details

Copyright (c) 2025 Tyler Twining


πŸ”— Links


🌟 Star this project if you find it useful!

Made with ❀️ for the ComputerCraft community

About

Various libraries and programs for CC: Tweaked that don't quite need their own repository (yet)

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages