The system utilities inDocumentation 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 provide the glue between CookieOS programs and the underlying CC:Tweaked environment. They handle time and date formatting in both 12-hour and 24-hour styles, timestamped logging to the OS log file, safe detection of monitor and modem peripherals, elapsed-time conversion, library introspection, and a fully integrated Gemini AI chat endpoint with a built-in modded-Minecraft persona.
cosUtils.getTime(timeFormat, hourMinOnly)
Returns the current date and time as a formatted string, or as individual components for clock display. The format is derived from thetimeFormat argument or — when omitted — from the timeFormat CC:Tweaked setting (defined with a default of "12"). Invalid values fall back to 12-hour format. All numeric components are zero-padded to two digits.
"12" for 12-hour AM/PM format, or "24" for 24-hour format. When omitted, reads the timeFormat setting.If
true, returns three separate values — hour, minute, ampm — instead of a full date-time string. Useful for rendering a compact clock.string in the format "YYYY-MM-DD HH:MM:SS AM" (or "YYYY-MM-DD HH:MM:SS" for 24-hour), or three values hour (string), minute (string), ampm (string) when hourMinOnly is true.
cosUtils.logToOS(msg)
Appends a timestamped line to the OS log file atos/data/OS.log. If the file does not exist it is created ("w" mode); if it does, the line is appended ("a" mode). The timestamp is appended in square brackets using cosUtils.getTime(). If the file grows beyond 50,000 bytes the log is cleared and a single reset notice is written.
The message to log. A timestamp is appended automatically.
The BSOD function calls
cosUtils.logToOS("[BSOD] " .. err) automatically before rebooting, so crash details are always captured in the log.cosUtils.isMonitorHere()
Searches for amonitor peripheral using peripheral.find().
Returns the monitor peripheral object if one is attached, or nil if none is found.
cosUtils.isModemHere()
Searches for amodem peripheral and verifies that it exposes a transmit method (confirming it is a functional wireless or wired modem rather than a stub).
Returns true, modem if a valid modem is found, or false if none is attached.
cosUtils.convertToSeconds(previous, current)
Converts the difference between twoos.epoch("utc") values into a seconds string formatted to three decimal places. os.epoch returns milliseconds in CC:Tweaked, so the function divides the raw difference by 0.01 (i.e. multiplies by 100 then divides by 1000, which equals dividing by 0.01) to produce seconds.
The earlier
os.epoch("utc") value.The later
os.epoch("utc") value.string with three decimal places, e.g. "1.500".
cosUtils.getSizeOfCosUtils()
Counts the number of function-type values currently registered in thecosUtils table. Useful for verifying that all expected functions loaded correctly after boot.
Returns a number.
cosUtils.Gemini(query, history)
Sends a text query to the Google Gemini API (gemini-1.5-flash-latest) and returns the AI’s response trimmed to a maximum of 600 characters. The AI persona is Davey — a player on a modded Minecraft server who is knowledgeable about Create, CC:Tweaked, Mekanism, Powah, Mystical Agriculture, and general programming. The model is configured with maxOutputTokens = 250 and temperature = 0.7.
Conversation history is supported: pass a table of "Speaker: message" strings. Lines starting with "Davey: " are mapped to the model role; all other lines are treated as user messages.
The current user message or question. An error is returned if the query is empty or whitespace-only.
Optional ordered table of prior conversation lines in
"Speaker: message" format. Pass nil or omit for a fresh conversation.response (string) on success, or nil, errorMessage (string) on failure (network error, API error, blocked prompt, etc.).