Programs, APIs and Utilities
Welcome to my thread. This thread contains programs, APIs, games, and more, that I have made for ComputerCraft.
To keep up-to-date with progress of most of the following programs go to my GitHub account also take a look at my pastebin account for lots of other scripts I make but don't always post.
I hereby give permission for use of these programs or APIs in your programs. I do however ask that you give me credit and leave any appropriate licenses intact!
Games
CCTicTacToe (a.k.a Noughts & Crosses) — And can Now be found as a dungeon disk!
Description
Tic-tac-toe (or Noughts and crosses, Xs and Os) is a game for two players (in this case player and AI), X and O, who take turns marking the spaces in a 3×3 grid. The player who succeeds in placing three respective marks in a horizontal, vertical, or diagonal row wins the game.Features
- Support for Advanced, Normal and pre1.4 computers
- Click support for advanced computers
- Close button for advanced computers
- Simple to use
- Random GUI Colours!
- An AI that makes moves just like you're playing a real person
- An easter egg (ability to colour your player name)
Screenshot(s)
Typer
Description
This game is a speed test game. Your aim: type out the words you see on the screen as quick and as accurately as possible before the time runs out. With a large dictionary of words you will rarely get the same word twice. The words will get longer the longer you last (up to 6 letters). Good luck!Credit: GravityScore (suggestion link)
Resources: Scrabble help websites to gather a dictionary of words.
Features
- Support for Advanced, Normal and pre1.4 computers
- A dictionary of over 31,600 words
Screenshot
More soon…
APIs
ccConfig — A configuration utility for programs
Description
Have you ever wanted to allow users to easily modify functionality of your program, like keybindings or display messages (or more)? We this is a utility that creates and saves a configuration file for you and your users.Developer Documentation (outdated but still useful)
ccKeyboard — An on-monitor keyboard
Description
ccKeyboard is designed to display a keyboard on a monitors screen. It can queue characters, numbers and symbols.Credit: Engineer — for help with the text-scaling on the varying size monitors
Developer Documentation
Screenshot(s)
Maximum size keyboard
Medium size keyboard
Smallest Possible Size keyboard
Letters Lower
Letters Upper
Numbers & Symbols
More Symbols
StringX — Adding a bunch of useful string functions from Java, C# and Obj-C
Description
This library has been inspired by me trying to do some common high-level language string functions that don't exist in Lua. So I decided to go through Java, C# and Objective-C string classes and implement most of the functions in Lua.Some functions that are implemented are already in Lua, but I did them anyway. If there are any you wish to be added, if you find any bugs, or any incorrect implementations please feel free to reply.
Developer Documentation
Loading Screen — An API to show a programs realtime loading progress
Description
The loading screen API provides an easy way to show your users in realtime where your program is up to while loading.This API features the ability to render your logo in the middle of the screen and even use it as the progress bar!
After searching through the forums I was disappointed at the lack of a loading screen API that was 'realtime' and not just a 'fake' sleep based screen.
So I decided to make one … Here it is …
Each progress bar is now an object. This means you can have multiple progress bars on the one screen*!
Thats right, you can have, for example, an 'overall' progress and 'current operation' progress AND more!
* Up to 999
Developer Documentation
Screenshots
Standard Load Bar
Logo as load bar
Logo as load bar and overlay
In ascii mode on a non-advanced / CC 1.3 computer
Multiple progress bars
Bar only mode (same for ascii too, only its in ascii)
Screensaver API — An API which renders attractive screensavers to the computer
Description
A simple screensaver API that has many custom render modes including a Fish Tank!Don't like my screensavers? Think that you can do a better one? Well just make a renderer and updater function in your program and then register it with the API and your done! You can now use your custom one!
I'd love to see what you can come up with! So if you think yours is awesome why don't you take a screenshot and post it here, and if I agree I'll add it into the public release (crediting you and your fantastic work!)
Developer Documentation (Lite)
Computer Program
ccPresenter — A tool to share your screen with another computer
Description
CCPresenter comes with two programs, a master and a slave. Run the slave on the computer you wish to mimic, run the master on the one you will be typing input into.Inspired by, and continuation of the Sphexish's program
Usage
Master- no arguments — starts the service (starts transmitting)
- -stop — stops the service (nothing will be transmitted anymore)
- no arguments — starts listening
Known Bugs
- Not so much a bug but a limitation — cannot have more than one master, the slave will get confused and try to display both.
Bug Testers
RyarshJShnupbups100
Features Coming Soon
- Be able to have multiple masters sending out to clients.
Download
Advanced Door Lock Program — A program to lock down your house
Description
Have you ever wanted to have a password on your door? Well this program is just for you!This is a password door lock that uses a custom written read function to read input from the user, it allows creation of multiple password acceptance and a password to terminate the program.
These are setup on first program run.
The passwords are stored in a separate file as a hashed string for extra security. If a person can read that and immediately know the password they are a genius and need to speak with me immediately.
This program uses the SHA256 API by GravityScore which can be found here (to clarify this no longer required to download and include, this link is here as credit only).
Disks with startup files are renamed and ejected when the program is running!
Now you might say, hey TheOriginalBIT, it doesn't look very nice, to which I say, "If you can make me a better GUI that supports all versions of ComputerCraft (normal and advanced comptuers) I will gladly use it and credit you. However, I am not very graphically minded and made it functional not pretty"
Screenshots
Usage
Place the file as the startup file to have it run on computer turn on.There are also optional runtime arguments:
- -setup - will go through the initial setup again
Features
- Uses SHA256 hashing for storage of passwords
- Uses ccConfig
- Uses custom read function to stop termination!
- Allows multiple users!
- Allows termination with password
- Renames and ejects, disk containing startup file (configurable)
Turtle Programs
Tree Logger — A simple turtle program to chop down trees for you
Description
This is a fairly simple program, place saplings and it will wait for it to grow and mine it up.Optionally you can give the turtle bonemeal, or a redstone line to something like a RedPower2 deployer, to grow the tree instantly.
For OS compatibility the turtle will not refuel or resupply itself so check up on it every now and again.
Requires a Turtle that is able to chop wood
Best setup (orange RedPower2, blue EnderChests)
Features
- Some adjustable values for customisation (in code)
- Multi TurtleOS compatible
- Collects the wood so your don't need to
Better Miner Program — Just like TurtleOS's excavate only better on fuel usage!
Description
This is an addition upon TurtleOS's standard excavate program. It is designed to have 2 ender chests in the first 2 slots. The first being a resource deposit and the second being a fuel collection source.It is designed to minimise the fuel usage. To do this you should put it under the top layer that will be excavated as it will dig in front, above and then below thus reducing the amount of times it is required to move and thus reducing fuel consumption by ~ 1/3.
When the inventory is low it will place the ender chest and deposit (it is suggested that some kind of sorting or removal system is setup at the other end so the chest isn't full). When the fuel is low it will place the ender chest and top up.
Please note: There were a few certain conditions pointed out to me that cause crashes or problems, as such this program in experiencing a re-code from the ground up
Features
- Uses minimal fuel as possible by mining 3 layers at once
- Uses ender chest in slot 1 to deposit materials
- Uses ender chest in slot 2 to get fuel
- Rarely travels to the surface / start location
- Hits any mobs in the way (careful it will hit you too!)
Code Snippets
Custom Read — Bettering the ComputerCraft read function without breaking scripts
Description
This is an override of the default ComputerCraft read function.Major differences to the default;
1. First argument: The mask that you can provide to obscure the input can now be more than 1 character. For example
read( "ab" )
with the user input of `hello` would output2. Third argument: There is now the ability to specify a character reading limit.ababa
3. Fourth argument: You can now specify if you want the read function to be not terminatable (i.e. it uses os.pullEventRaw instead of os.pullEvent)
4. Unlike the default ComputerCraft function when the terminal is scrolled the read function will also scroll with it. BEWARE: It can and will scroll beyond the top of the screen if you make it do so.
5. Much more efficient and better logic
NOTE: None of the above changes should break existing scripts, so feel free to add this globally in your graphical shells.
If you do find any circumstances where it does break, please report them.
Peripheral Search
Description
I made this snippet for a current project I'm working on, and its just too useful not to release separately… It is a standard function that allows you to search for a particular peripheral attached to the computer locally or via network cables, however it has a callback feature to it as well. Callback you say? What would you need that for? Well, lets assume you want a wireless modem, a standard peripheral search would return you any modem it finds, whether it is wireless or not. By supplying you with the option of a callback, the search will actually give this function a wrapped version of the peripheral it is testing, this will allow you to perform additional tests, such as testing if the modem is wireless, and then return whether you want the peripheral or not.Another addition to this function is the ability for you to specify whether you wish to retrieve back just the side/name of the peripheral, or whether you want the wrapped peripheral.
And of course the last feature is the ability for you to provide a custom error message, for example if you tell it you want a wireless modem you must specify "modem" which when not located would output "Cannot find a modem attached to this computer", giving this custom error message ability means that the error that shows to the user could say "no wireless modem found", giving you better control over the output of this function
Function Info
findPeripheral(_type, errMsg, callback, wrapped)
_type is the peripheral type you're searching for, for example "modem" for wireless/wired modems, "monitor" for normal/advanced monitors, "drive" or disk drives, etc.errMsg is the custom error message to show, for example "cannot locate a wireless modem" instead of just "cannot find a modem attached to this computer"
callback (optional) is the function to be called when a matching peripheral is found, checking with you if it is indeed what you want (you must return true/false!)
wrapped (optional) is the boolean that specifies if you wish the value returned to be a wrapped peripheral, if this is omitted the return will be the side/name of the peripheral
Usage Example
Simple
local wirelessModem = findPeripheral("modem", "No wireless modem found attached to the computer", function(periph)
return periph.isWireless()
end)
More complex
local advancedMonitor = findPeripheral("monitor", "No advanced monitor found attached to the computer", function(periph)
if not periph.isColor then
error("Running incorrect version of ComputerCraft, please update to a version with advanced monitors and try again", 0)
end
return periph.isColor()
end)
Dynamic Function Invocation on Lua Objects
Description
While dealing with an object-oriented system I wanted the ability for people to invoke the functions on my objects in all the valid ways in Lua
--# first is the standard OO method with colon notation
object:foo("bar")
--# second is the standard OO method with dot notation
object.foo(object, "bar")
--# third is the method to call a function in an API, and it is the conventional OO method found in languages such as Java and C#
object.foo()
However with OO in Lua, only these are possible
--# first is the standard OO method with colon notation
object:foo("bar")
--# second is the standard OO method with dot notation
object.foo(object, "bar")
I started by making a helper function which simply "cleaned" the arguments supplied to a function. I was then talking to Symmetryc about the solution that I had and he was able to come up with the method you see in this code. I've taken it and added further checks and stability to it and then decided to release it here so you can all benefit from its "magic".
The code snippet provided here adds this third method of invocation, allowing you (or any other developer) to call your objects any way you wish, very handy for APIs!