Projects
A Gamma project is a folder with a main.gma or main.luau in it. Everything else is up to you.
Layout
MyGame/
Gamma.json settings, optional
main.luau what runs
src/
Arena.luau
Hud.gma
assets/
Tree.gltf
Logo.png
.luaurc require aliases and type checking mode, optional- One main file. A folder with both
main.gmaandmain.luau, or neither, won't load. - Modules can be Gama or Luau, and either can require the other.
mainruns like a single file does, so it can yield at the top level.Gamma new <Folder>makes this for you. See Getting started.
Gamma run <Folder> runs it without a window until nothing is left to do. Gamma play <Folder> opens a window: each frame it reads input, fires Run.RenderStepped, draws the scene and UI, then steps Run, in sync with the display. Both also take a single file or a place file. Flags are in the CLI reference.
Settings
Gamma.json at the top of the project is a JSON object. Anything left out uses its default.
| Setting | Values | Default |
|---|---|---|
GraphicsQuality | Low, Medium, High, Ultra | High. Sets the defaults of the quality settings below; any you set yourself win. See the note under the table |
Renderer | Default, Direct3D11, Direct3D12, Vulkan, OpenGL | Default, the best API for the platform |
Shadows | ShadowMap, RayTraced, None | ShadowMap. See Shadows |
VSync | true, false | true. --vsync overrides it |
FrameRateLimit | frames per second, or 0 | 0, no limit beyond VSync |
Multisampling | 1, 2, 4, 8 | 4. 1 turns it off |
ShadowMapSize | 512, 1024, 2048, 4096 | 2048 per cascade |
LightShadowMapSize | 256, 512, 1024 | 512, for lights with Shadows on |
AmbientOcclusion | true, false | true (screen space) |
ScreenSpaceReflections | true, false | true. See Lighting |
SkyOcclusion | true, false | true, keeps sky light out of enclosed spaces. See Lighting |
TemporalAntiAliasing | true, false | true. Smooths edges and the grain of soft shadows, fog and reflections |
UpdateManifest | an https URL | none. See Updates |
Permissions | list of Http, Files, Process, Serial, Location, Network | none, which allows everything. See Permissions |
Quality presets:
Low: no multisampling, AO, reflections, TAA or sky occlusion; shadow maps 1024 (lights 256)Medium: likeLowbut with AO, TAA and sky occlusionHigh: the defaults in the tableUltra: 8× multisampling, shadow maps 4096 (lights 1024)
play reads the file when it opens the window; run only reads Permissions. An API the platform can't use, like Direct3D12 on Linux or the web, falls back to the default with a warning.
Assets
Asset paths are relative to the project folder, so "assets/Tree.gltf" works wherever you run Gamma from. That covers MeshId, TextureId, Image.Source, SoundId and fonts passed to Ui.LoadFont. A single file or a place file has no project folder, so its paths are relative to the working directory.
Files is different: its paths are always relative to the working directory, as a command-line tool expects.
Preloading
Models and images load in the background, so they pop in a few frames late. To avoid that at the start of a level, preload:
local statuses = Content:PreloadAsync({ Scene.Level2, "assets/Boss.glb", "assets/Sky.png" })
if statuses["assets/Boss.glb"] ~= Enum.AssetFetchStatus.Success then
warn("the boss did not load")
endContent:PreloadAsync(list) takes content ids and instances (it loads every MeshId, TextureId and SoundId in each instance and its descendants), yields until all have loaded or failed, and returns each id's Enum.AssetFetchStatus. Preloaded assets stay loaded for the rest of the game.
- The extension decides the type:
.png .jpg .jpeg .bmp .gif .tga .webpare images,.wav .mp3 .ogg .flacsounds, anything else a model. - URLs need the
Httppermission. Content.RequestQueueSizecounts what's still loading, for a progress bar.Content:GetAssetFetchStatus(id)checks one (Noneif never preloaded).- Sounds already load when
SoundIdis set, so preloading them only checks the file exists.
Services
Every service is a global, available from the first line of every script. There's no game and no GetService.
Run.Heartbeat:Connect(function(deltaTime)
spinner.Transform *= Transform.Angles(0, deltaTime, 0)
end)
local hit = Scene:Raycast(origin, direction)| Service | For |
|---|---|
Scene | The 3D world, its camera, raycasts and queries, physics |
Run | Per-frame events (Heartbeat, RenderStepped) and BindToClose |
Input, Actions, VirtualInput | Input |
Lighting | Lighting |
Audio | Audio |
Tweens | Tweening properties |
Tags | Tags on instances |
Debris | Destroying things after a delay |
Http, Network, Players | Networking |
Files, Process, Serial, Location | The machine Gamma runs on (see permissions) |
DataStores | Saving data |
Content | Preloading |
Pathfinding | Paths |
Encoding | Base64, compression, hashing |
Debug, Stats, Log | Debugging and output |
Each has a page in the API reference.
Encoding
Encoding does base64, compression and hashing. Every method takes a buffer or string and returns a new buffer; buffer.tostring turns it back.
local packed = Encoding:CompressBuffer(Files:ReadFile("save.json"), Enum.CompressionAlgorithm.Gzip)
Files:WriteFile("save.json.gz", buffer.tostring(packed))
local text = buffer.tostring(Encoding:Base64Encode(packed))Base64Encode(input),Base64Decode(input). Decoding also accepts the URL-safe alphabet, missing padding and line breaks, and fails on anything else.CompressBuffer(input, algorithm?, level?),DecompressBuffer(input, algorithm?).Zlib(default),GziporDeflate(raw), as anEnum.CompressionAlgorithmor its name. Level 0 to 9. Decompression fails on bad data or output over 1 GiB.ComputeBufferHash(input, algorithm?): the 32-byte SHA-256 digest. SHA-256 is the only algorithm.
Finding instances
instance:QueryDescendants(selector) finds descendants with a CSS-like selector, parents before children.
for _, part in Scene:QueryDescendants("Model.Enemy > Part[$Health > 0]:not(.Shielded)") do
part.Color = Color.new(1, 0, 0)
end| Selector | Matches |
|---|---|
Part | That class or a subclass, like IsA |
* | Anything |
.Hazard | Tagged Hazard |
#Door, #"Front Door" | Named Door |
[Anchored = true] | A property. Enums match by item name: [Material = Neon] |
[$Damage >= 10] | An attribute |
[CanCollide], [$Damage] | Set and not false |
A > B | A B that's a child of an A |
A B, A >> B | A B anywhere inside an A |
> B | Direct children of the instance you called it on |
:not(...) | Matches none of the selectors inside |
:has(...), :has(> ...) | Has a matching descendant, or child |
A, B | Either. Instances matching both are listed once |
Comparisons: =, !=, ^= (starts with), $= (ends with), *= (contains), and <, <=, >, >= for numbers. Quote values with spaces or ]. An instance whose class doesn't have the property fails the test. The search never goes above the instance you call it on.
Running scripts
main and the modules it requires are plain files. Script instances, from a place file or Instance.new("Script"), start when they're in the game and enabled, at the next point the engine gets control back from Luau.
- A running script keeps running wherever it's moved.
- Setting
Enabled = falseor destroying it stops it, along with every thread it started (throughtask,coroutineor event handlers) and its connections. SettingEnabled = trueruns it again from the top. - Threads a
ModuleScriptstarts while loading belong to no script and aren't stopped. scriptrefers to the runningScriptorModuleScript. Inmainand modules required by path it'snil.
When nothing is left to run, the game closes: every Run:BindToClose function runs in its own thread, and run keeps stepping for up to 30 seconds while they yield. That's where to save progress, for example to a data store. Under --watch they get 2 seconds.
Require
require("./Path")andrequire("@Alias/Path")load files relative to the requiring file, with aliases from.luaurc.x.gma,x.luau,x/init.gmaandx/init.luauall work; having bothx.gmaandx.luauis an error.- A module runs once. Every later
requiregets the same value. - A file module can't yield while it loads. If it needs to wait, return a function for the caller to run, or start a thread with
task.spawn. require(moduleScript)runs aModuleScriptinstance. Those may yield while loading (inWaitForChild, say), and every caller waits for the same result. AModuleScripthas no file, so it can only require instances.- A module that requires itself while loading, directly or in a loop, errors. So does one that doesn't return exactly one value.