Skip to content

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.gma and main.luau, or neither, won't load.
  • Modules can be Gama or Luau, and either can require the other.
  • main runs 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.

SettingValuesDefault
GraphicsQualityLow, Medium, High, UltraHigh. Sets the defaults of the quality settings below; any you set yourself win. See the note under the table
RendererDefault, Direct3D11, Direct3D12, Vulkan, OpenGLDefault, the best API for the platform
ShadowsShadowMap, RayTraced, NoneShadowMap. See Shadows
VSynctrue, falsetrue. --vsync overrides it
FrameRateLimitframes per second, or 00, no limit beyond VSync
Multisampling1, 2, 4, 84. 1 turns it off
ShadowMapSize512, 1024, 2048, 40962048 per cascade
LightShadowMapSize256, 512, 1024512, for lights with Shadows on
AmbientOcclusiontrue, falsetrue (screen space)
ScreenSpaceReflectionstrue, falsetrue. See Lighting
SkyOcclusiontrue, falsetrue, keeps sky light out of enclosed spaces. See Lighting
TemporalAntiAliasingtrue, falsetrue. Smooths edges and the grain of soft shadows, fog and reflections
UpdateManifestan https URLnone. See Updates
Permissionslist of Http, Files, Process, Serial, Location, Networknone, which allows everything. See Permissions

Quality presets:

  • Low: no multisampling, AO, reflections, TAA or sky occlusion; shadow maps 1024 (lights 256)
  • Medium: like Low but with AO, TAA and sky occlusion
  • High: the defaults in the table
  • Ultra: 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:

luau
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")
end

Content: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 .webp are images, .wav .mp3 .ogg .flac sounds, anything else a model.
  • URLs need the Http permission.
  • Content.RequestQueueSize counts what's still loading, for a progress bar. Content:GetAssetFetchStatus(id) checks one (None if never preloaded).
  • Sounds already load when SoundId is 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.

luau
Run.Heartbeat:Connect(function(deltaTime)
	spinner.Transform *= Transform.Angles(0, deltaTime, 0)
end)
local hit = Scene:Raycast(origin, direction)
ServiceFor
SceneThe 3D world, its camera, raycasts and queries, physics
RunPer-frame events (Heartbeat, RenderStepped) and BindToClose
Input, Actions, VirtualInputInput
LightingLighting
AudioAudio
TweensTweening properties
TagsTags on instances
DebrisDestroying things after a delay
Http, Network, PlayersNetworking
Files, Process, Serial, LocationThe machine Gamma runs on (see permissions)
DataStoresSaving data
ContentPreloading
PathfindingPaths
EncodingBase64, compression, hashing
Debug, Stats, LogDebugging 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.

luau
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), Gzip or Deflate (raw), as an Enum.CompressionAlgorithm or 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.

luau
for _, part in Scene:QueryDescendants("Model.Enemy > Part[$Health > 0]:not(.Shielded)") do
	part.Color = Color.new(1, 0, 0)
end
SelectorMatches
PartThat class or a subclass, like IsA
*Anything
.HazardTagged 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 > BA B that's a child of an A
A B, A >> BA B anywhere inside an A
> BDirect children of the instance you called it on
:not(...)Matches none of the selectors inside
:has(...), :has(> ...)Has a matching descendant, or child
A, BEither. 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 = false or destroying it stops it, along with every thread it started (through task, coroutine or event handlers) and its connections. Setting Enabled = true runs it again from the top.
  • Threads a ModuleScript starts while loading belong to no script and aren't stopped.
  • script refers to the running Script or ModuleScript. In main and modules required by path it's nil.

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") and require("@Alias/Path") load files relative to the requiring file, with aliases from .luaurc. x.gma, x.luau, x/init.gma and x/init.luau all work; having both x.gma and x.luau is an error.
  • A module runs once. Every later require gets 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 a ModuleScript instance. Those may yield while loading (in WaitForChild, say), and every caller waits for the same result. A ModuleScript has 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.

Apache License 2.0