Templates

A template is what a new project can start from. The project hub lists them, and so does template.list.

Using one

{"command": "project.create", "directory": "/path/to/MyGame", "name": "My Game"}
{"command": "project.open", "path": "/path/to/MyGame/MyGame.cairnproject"}
{"command": "template.apply", "template": "TopDownShooter"}

template.apply is meant for a project that was just made. It copies the template's files in, builds its scene and saves it. Files the project has already are kept.

What comes with the engine

IDWhat it is
ThirdPersonA character that walks, runs and jumps, a camera that follows, and a park with trees, rocks, platforms and a ramp
TopDownShooterA twin-stick shooter seen from above: enemies that chase, an arena with cover, a score and a health bar

Making your own

A template is a folder inside Templates/:

Templates/
  Racing/
    Template.jsonl      the commands that build the project
    Files/              copied into the project as it is
      Assets/
        Scripts/
          Car.lua

Template.jsonl starts with the template's name and description, and how its card in the hub looks: an icon from the editor's icons, by file name in Cairn-Editor/Icons, and a colour its picture fades from. Both are optional.

# Name: Racing game
# Description: Cars that go round a track.
# Icon: gamepad
# Tint: #3873D3
{"command": "input.set_action", "name": "Steer", "bindings": ["D", "-A", "Gamepad LeftX"]}
{"command": "material.create", "path": "Assets/Materials/Road.cairnmat", "data": {"BaseColor": [0.2, 0.2, 0.22, 1]}}
{"command": "entity.create", "name": "Car", "mesh": "Cube", "data": {"Scripts": [{"Script": "Assets/Scripts/Car.lua"}]}}
{"command": "scene.save"}

The rest is ordinary commands, run in order as if an agent had sent them. The first that fails stops the rest.

Rules:

  • Name assets by path, never by ID. The files in Files/ have no .meta files, so each project made from the template gets IDs of its own.
  • ${TEMPLATE} in a command becomes the template's folder, for asset.import of a file that should not be copied wholesale.
  • End with scene.save.
  • A template may not create or open projects.

The editor looks for templates in the Templates folder beside its program, where the build copies them. --templates DIR points it elsewhere.