CookieOS provides two complementary pieces of chat functionality: a Chat program that lets you type messages from the computer terminal and broadcast them into the Minecraft in-game chat, and a Gemini Chat event handler that runs continuously in the background, watching all in-game messages and responding to any that start with theDocumentation 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.
., prefix using Google’s Gemini AI.
Chat Program
The Chat program lives atos/programs/chat and is launched from the Programs menu. It requires a chatBox peripheral attached to the computer.
Prerequisites
AchatBox peripheral must be connected before launching. If none is found, the program prints an error and exits without entering the main loop. In the Programs menu, the “Chat” entry is shown in red text when no chatBox is detected.
How It Works
On launch, the program locates thechatBox peripheral with peripheral.find("chatBox"). It then enters a loop that reads a line of input from the terminal with read() and sends any non-empty input to in-game chat as the player Dave using:
"<>" sets the message prefix displayed in chat. Each send is wrapped in cosUtils.safeRun so that any runtime error triggers a CookieOS BSOD rather than silently dropping the message.
Usage
Gemini Chat Event Handler
The Gemini integration lives atos/events/geminichat.lua. It is not launched manually — it is auto-loaded as a background coroutine by startup/startEvents.lua when CookieOS boots.
How It Works
The handler callsperipheral.find("chatBox") and then enters an infinite loop listening for chat events. Every in-game message received by the chatBox is processed:
- The sender’s name and message are logged into a per-player history table (
players). - History entries are sorted by
os.clock()timestamp, newest first. - If the message begins with
.,, the text after those two characters is extracted as a query. - The query and the last 10 messages from all tracked players are passed to
cosUtils.Gemini(). - The AI response (capped at 600 characters) is sent back into in-game chat as Davey with the
<>prefix.
Trigger Pattern
AI Persona
Davey is configured via a system instruction embedded incosUtils.Gemini:
“Your name is Davey. You’re someone playing on a modded Minecraft server, and you’re an expert with Create, CC:Tweaked, Mekanism, Powah, Mystical Agriculture and much more. You’re also knowledgeable about programming, and things outside Minecraft. Please be concise in your responses.”Davey’s own responses are stored under the key
"gem" in the players history table, and are labelled "Davey" when passed back to the API as conversation history, so the model receives full multi-turn context.
Configuring the Gemini API Key
The API key is defined insidecosUtils.Gemini in apis/cUtils.lua. You must replace the placeholder before the feature will work:
Locate the cosUtils.Gemini function
Search for the line
local geminiApiKey = "YOUR_GEMINI_API_KEY" near the bottom of the file.Replace the placeholder
Replace
"YOUR_GEMINI_API_KEY" with your actual key obtained from Google AI Studio.geminichat.lua is auto-loaded because startup/startEvents.lua iterates over every .lua file in the os/events/ directory and runs each one as a background handler via parallel.waitForAny. You can add your own background event handlers to that directory and they will be loaded automatically on the next boot — no changes to startup files required.