Skip to content

Place Files ​

A place file saves a game as readable JSON, so it can be kept in git and its diffs stay small. Gamma run <Place.json> and Gamma play <Place.json> load one and run it as they would a project folder. Any path ending in .json is read as a place file, and one ending in .gplace as a binary place.

Saving the same game always writes the same bytes, on every platform. Saving a place right after loading it writes the file unchanged.

Layout ​

json
{
	"Format": "Gamma place",
	"Version": 1,
	"Services": [
		{
			"ClassName": "Scene",
			"Properties": {
				"CurrentCamera": {"Ref":1},
				"Name": "Scene"
			},
			"Children": [
				{
					"ClassName": "Camera",
					"Id": 1,
					"Properties": {
						"Transform": {"Transform":[0,0,0,1,0,0,0,1,0,0,0,1]},
						"FieldOfView": 70,
						"Name": "Camera"
					}
				},
				{
					"ClassName": "Part",
					"Properties": {
						"Anchored": false,
						"Transform": {"Transform":[1,2.5,-3,1,0,0,0,1,0,0,0,1]},
						"Color": {"Color":[0.5,0.25,1]},
						"Name": "Box",
						"Size": {"Vector3":[4,1,2]},
						"Transparency": 0
					},
					"Attributes": {
						"Points": 10
					},
					"Tags": ["Goal"]
				}
			]
		}
	]
}
  • Services lists the game's services that hold something to save, ordered by class name. Loading one gets the game's existing service, as GetService does.
  • Each instance has, in this order: ClassName; Id, only when another saved instance refers to it; Properties; Attributes and Tags, when it has any; and Children, in tree order, when it has any saved children.
  • Properties and attributes are sorted by name. Tags keep the order they were added in. Files are indented with tabs and end with a newline.

What is saved ​

Everything goes through the class registry, so a new class or property is saved without any change to the format.

  • An instance whose Archivable is false is not saved, and neither are its descendants, as in Roblox. Nor is an instance of a class that cannot be made again, such as InputObject or Tween.
  • Every property that can be set is saved, except Parent and the ones marked as not serialised: Archivable (always true for a saved instance) and BasePart.Position (part of Transform).
  • A reference to another saved instance is written as {"Ref":Id}. Ids are numbered from 1 in tree order, counting only instances that are referred to, so adding an instance does not renumber the others unless it is itself referred to. A reference to an instance that is not saved, or to nothing, is written as null, and loading leaves that property at its default.
  • A script's Source is saved, but not the file it was loaded from, so a script from a place can only require instances.

When a place's Scene sets CurrentCamera, the camera a new Scene comes with is destroyed, so the loaded game has only the saved camera.

Values ​

true, false and strings are written as they are. A number is written in the shortest form that reads back to the same double. Every other value is an object with one key naming its type:

TypeForm
number that is infinite or NaN{"Number":"inf"}, "-inf" or "nan"
Instance reference{"Ref":1}
Vector3{"Vector3":[x,y,z]}
Vector2{"Vector2":[x,y]}
Color{"Color":[r,g,b]}
Transform{"Transform":[x,y,z,R00,R01,R02,R10,R11,R12,R20,R21,R22]}, the rotation by rows as Transform:GetComponents() returns it
EnumItem{"EnumItem":"Material.Plastic"}
NumberRange{"NumberRange":[min,max]}
PhysicalProperties{"PhysicalProperties":[density,friction,elasticity,frictionWeight,elasticityWeight]}
Ray{"Ray":[originX,originY,originZ,directionX,directionY,directionZ]}
Rect{"Rect":[minX,minY,maxX,maxY]}
Region3{"Region3":[minX,minY,minZ,maxX,maxY,maxZ]}
NumberSequenceKeypoint{"NumberSequenceKeypoint":[time,value,envelope]}
NumberSequence{"NumberSequence":[[time,value,envelope],...]}
ColorSequenceKeypoint{"ColorSequenceKeypoint":[time,r,g,b]}
ColorSequence{"ColorSequence":[[time,r,g,b],...]}
DateTime{"DateTime":unixTimestampMillis}
TweenInfo{"TweenInfo":{"DelayTime":0,"EasingDirection":"Out","EasingStyle":"Quad","RepeatCount":0,"Reverses":false,"Time":1}}
table (array){"Array":[...]}
table (string keys){"Dictionary":{...}}

The components of Vector3, Vector2, Color, Transform, NumberRange, PhysicalProperties, Ray, Rect, Region3 and the sequences and their keypoints are 32-bit floats, written in the shortest form that reads back to the same float, so 0.1 stays 0.1. A component that is infinite or NaN is written as the string "inf", "-inf" or "nan". Signal values cannot be saved.

Loading errors ​

Loading stops with an error, naming the problem, for a file that is not valid JSON, has another Format or Version, names a class that cannot be created or a property its class does not save, gives a value of the wrong shape, or refers to an id no instance has.

Binary places ​

For shipping, a place can also be saved in a binary form, which holds the same document as the text form but is smaller and quicker to read. Gamma place <Input> <Output> converts a place file either way: an Output ending in .gplace gets the binary form and any other the text form. Converting a binary place back gives exactly the text the game would save. Gamma reads either form, telling them apart by their first bytes.

The binary form starts with the 8 bytes GAMMAPLC and a version number. Version 2, which Gamma writes, is followed by the size of the rest of version 1's contents as a variable-length integer and then those contents compressed with zlib (deflate at its best compression). Version 1, which earlier builds wrote and Gamma still reads, is followed by them as they are: a table of every string the document uses, each once, and then the document itself. Each value is one byte for its kind followed by its contents:

KindByteContents
null, false, true0, 1, 2nothing
whole number3a zigzag variable-length integer
float44 bytes, little-endian
double58 bytes, little-endian
float as the text form writes it64 bytes; the number is the shortest decimal that reads back as this float
string7its index in the string table
list8its length, then each item
object9its number of keys, then each key's index in the string table and its value

Numbers in the binary form are always exactly the numbers in the text form. Saving the same game always gives the same bytes with the same zlib, which Gamma builds in. Compression shrinks script source as well as parts, so a binary place is usually a small fraction of its text.

Apache License 2.0