Documentation Index
Fetch the complete documentation index at: https://mintlify.com/PrinceOfCookies/CookieOS/llms.txt
Use this file to discover all available pages before exploring further.
cosUtils is the standard library at the heart of CookieOS, an OS overlay for CC:Tweaked (ComputerCraft) in Minecraft. It bundles UI rendering helpers, filesystem utilities, LZW compression, RC4 encryption, MD5 hashing, peripheral detection, system logging, and a Gemini AI integration into a single globally-available table. Every CookieOS program has access to it without any import step — it is registered as a global during boot and is ready the moment your script starts executing.
How to use it
cosUtils is injected into the global environment at boot time, so there is no require() call needed in your scripts:
Loading mechanism
The library is loaded by the CookieOS startup sequence viastartup/loading.lua, which adds the apis/ directory to the Lua package path and assigns the returned table to _G.cosUtils:
cosv holds the current version string and is used by UI functions such as cosUtils.waterMark() and cosUtils.drawMenu().
API surface overview
UI Helpers
Screen reset, box drawing, centered text, menus, loading bars, BSOD display, and on-screen keyboard.
Filesystem
File counting, directory size, formatted sizes, file search, filtered directory listings, and
fs.attributes2.Cryptography
MD5 hashing, RC4 stream encryption, LZW compression, hex encoding, and the Package/UnPackage pipeline.
System & Utilities
Time formatting, OS logging, modem and monitor detection, the Gemini AI integration, and miscellaneous helpers.
String extensions
In addition to the functions on thecosUtils table, the library extends Lua’s built-in string module with extra utility methods. These are patched onto the global string table at load time, so they are available everywhere in CookieOS after boot — including in programs that never reference cosUtils directly.
| Method | Signature | Description |
|---|---|---|
string.split | (input, delimiter) | Splits a string by delimiter, returns table |
string.trim | (input) | Removes leading/trailing whitespace |
string.startswith | (input, start) | Returns true if input starts with start |
string.endswith | (input, ending) | Returns true if input ends with ending |
string.join | (delimiter, list) | Joins a table of strings with delimiter |
string.replace | (input, old, new) | Replaces all occurrences of old with new |
string.toUpper | (input) | Returns uppercase string |
string.toLower | (input) | Returns lowercase string |
string.reverse | (input) | Returns reversed string |
string.contains | (input, substring) | Returns true if substring is found |
string.isEmpty | (input) | Returns true if string is empty or whitespace-only |
Library size
getSizeOfCosUtils() returns the number of functions currently registered in the cosUtils table. You can use this to verify that the library loaded correctly: