Skip to main content

Generated File Reference

This page describes the files a CCraft Studio export drops onto a computer — the folder tree, what each file is for, the order they load in, and the two output options. It is the single reference for the layout; the per‑mode pages (Full, UI Only, Logic Only) only describe what changes between modes.

Folder layout

A multi‑file export drops a folder like this onto the computer. This is the Full layout — UI Only and Logic Only are subsets of it (see each mode's page for what's left out):

MyProject/
├── components/ UI element classes (the rendering engine)
│ ├── BaseObject.lua Base class shared by every element
│ ├── Screen.lua Screen container + draw / hit-testing
│ ├── Button.lua
│ ├── Label.lua
│ ├── Panel.lua
│ ├── Container.lua
│ ├── Input.lua
│ ├── CheckBox.lua
│ ├── Slider.lua
│ └── ProgressBar.lua
├── screens/ One file per screen — builds the UI tree
│ └── <ScreenName>.lua
├── logic/ One file per screen — your block logic
│ └── <ScreenName>.lua
├── utils/
│ ├── vars.lua Global state + your project variables
│ └── functions.lua Helper + UI runtime functions
└── startup.lua Entry point — loads everything, then runs

Where do the files go? A typical destination is your CraftOS‑PC computer folder, e.g. …/CraftOS-PC/computer/0/MyProject/. In‑game you place the same files inside a computer's directory. Whatever folder you export to becomes the program's root.

What each file is

  • components/ — the rendering engine. Each file defines one element class (Button, Label, …) that inherits from BaseObject. These are identical across every project. See UI Components.
  • screens/<ScreenName>.lua — one file per screen that instantiates components and assembles the layout tree. Generated from what you built on the canvas.
  • logic/<ScreenName>.lua — one file per screen that registers your block logic as event handlers on that screen. A screen with no blocks produces no logic file.
  • utils/vars.lua — global runtime state plus the project variables you defined.
  • utils/functions.lua — helper functions. In UI modes it also includes the UI runtime (drawScreens, navigate, getScreen, setupMonitorsToScreens, …). In Logic Only mode it instead provides a small stub screen.
  • startup.lua — the entry point CC: Tweaked runs automatically.

How it runs: startup.lua

startup.lua loads the project in a fixed order and then hands control to the part that matches your export mode:

-- Load Utilities → utils/vars.lua, utils/functions.lua
-- Load Components → every file in components/ (UI modes only)
-- Load Screens → every file in screens/ (UI modes only)
-- Load Logic → every file in logic/ (Full & Logic Only)
-- Project Start → the event loop / drawScreens() for your mode

Because everything is loaded with dofile, load order matters: variables first, then the component classes, then the screen UI that uses those classes, then the logic that wires events onto the UI. You normally never edit startup.lua by hand. What "Project Start" expands to is covered on each mode's page.

Naming & sanitization

Screen names become file names and Lua identifiers, so any character that isn't a letter, number, or underscore is replaced with _.

Screen name in the editorGenerated file
Screen 1screens/Screen_1.lua
Main Menuscreens/Main_Menu.lua
Screen2screens/Screen2.lua

Export options

Two checkboxes in the export window change the shape of the output without changing which mode you picked.

Minify output

Removes comments and extra whitespace from every file (each line is trimmed and any line that is empty or starts with -- is dropped). The result is functionally identical but smaller — handy when disk space on a computer/turtle is tight.

Before minify
-- ============================================================
-- My Project
-- Generated by CCraft Studio
-- ============================================================

local screen = Screen:new("Screen_1", {
bgColor = colors.black,
})
After minify
local screen = Screen:new("Screen_1", {
bgColor = colors.black,
})

All‑In‑One File

Combines every file into a single startup.lua. Each screen and logic file is wrapped in an immediately‑invoked function (function() ... end)() so their local variables don't collide. Use this when you want to share your program as one paste‑able file (for example, on Pastebin).

See also