User guide

Build a Godot backglass

Start with the Pinball CTL vector sample to see cabinet controls, live scores and short cues in one project. The tutorial below shows how to build a menu and a scoreboard from a blank Godot 4.6 project.

Pinball CTL vector sample

All eight scenes share a header with the pinballCTL wordmark. Each has a different animated vector backdrop. Attract has its original drifting rays and arcs. Menu fans out from the cabinet, Mode pairs curved and angular rays, and High Scores uses low perspective rays to frame the board. Tilt sends out shock arcs and a zigzag, and Bonus bursts upward in gold. Game Over keeps its slow purple swirl. Ball in Play uses diagonal rays that sweep behind the live score. Stars drift and fade to 30% opacity before brightening.

Relay winks and waves in Attract, recoils with red eyes at Tilt, laughs and pumps a fist at Bonus, and lowers his gaze beside the final score at Game Over. The flippers react as you move through the menu.

Scene previews

The Attract preview runs for the full 38-second loop. Relay is centred from the first frame. He waves, crouches, jumps aside and bounces on landing. He follows the falling parts with his eyes as a candy-striped progress bar shows what is being built. During the replay, the panel beneath Relay shows shot updates and the score sits above him. A spring plunger launches three balls, each with its own character sequence. Relay winks and points during the first ball, gives side-eye and presents a shot with an open palm during the second, and squints at launch before the biggest celebration on the third. Each signature gesture plays once, and Relay nods at the end. A soft gradient sweeps behind the Press Start prompt. Start opens the menu at any point.

Run and export the vector sample

Open media/backglass/sample/project.godot in Godot 4.6 or launch it from the repository root.

godot --path media/backglass/sample

Left and Right act as the flippers. Enter or Space acts as Start. Use F1 through F6 to preview Attract, Menu, High Scores, Tilt, Bonus and Game Over. F7 opens Mode and F8 opens Game Started.

godot --headless --path media/backglass/sample --editor --import --quit
godot --headless --path media/backglass/sample --export-pack Linux /absolute/path/pinballctl-sample.pck

Upload the pack in Media and choose an entry from res://ctl_sample/entries/ for each primary Godot layer. In Layer Settings → Input Mapping, map cabinet buttons using the Action input kind.

Cabinet button Godot action Effect
Left flipper ui_left Previous menu item or score board
Right flipper ui_right Next menu item or score board
Start ui_accept Open the menu, choose an item or return from High Scores
Back, if fitted ui_cancel Return to the previous screen

Choosing Start game emits BACKGLASS_SAMPLE_START_REQUESTED with an empty payload. Bind it to your game-start rule. The controller owns game state and scoring.

Choose Easy or Hard

Choose Mode in the menu to open the dedicated Easy/Hard screen. Relay stands between the rounded Easy panel and the angular Hard panel. Use either flipper to move the highlight and see him point to that choice. Press Start to confirm and return to the menu with the chosen mode. Back cancels the choice.

The Mode entry is res://ctl_sample/entries/mode.tscn. Confirming sends BACKGLASS_SAMPLE_MODE_EASY_SELECTED or BACKGLASS_SAMPLE_MODE_HARD_SELECTED with an empty payload. Map those events to your controller rules for each difficulty. Easy is the default. To restore a controller-managed choice, pass easy or hard as the {{MODE}} text value or the mode field in BACKGLASS_STATE.

Show Game Started

Use res://ctl_sample/entries/game_started.tscn for the live scoreboard titled Ball in Play. Use a GAME_STARTED rule to play Game Started after a confirmed start. Use a GAME_ENDED rule to play res://ctl_sample/entries/game_over.tscn and set Attract as the display's default scene. Media returns to Attract when the 10-second Game Over cue finishes. Relay plays a shuffled set of gestures beside the live score, player and ball during play.

Supply live values and queue cues

The standalone project uses example values. The imported scenes use live text values and the controller’s High Scores boards, including an active competition.

Scene Values supplied by pinballctl Playback
Attract Its own replay score Relay opens the scene, the table assembles and three balls play in one 38-second loop
Menu Current mode Waits for cabinet input
Mode {{MODE}} or BACKGLASS_STATE.mode Confirms Easy or Hard and returns to Menu
High Scores Controller score boards Waits for cabinet input
Tilt {{PLAYER}} or {{PLAYER_NAME}}, and {{BALL}} Finishes in 1.20 seconds
Bonus {{BONUS}}, {{MULTIPLIER}}, and player and ball values Final total lands at 0.65 seconds. Cue finishes in 2.12 seconds
Game Over {{SCORE}}, and player and ball values Holds the final score through Relay’s reaction and exits at 10 seconds
Game Started Live score, current player and ball Loops every 30 seconds and remains active until another scene replaces it

Set the text values before triggering the corresponding Media scene. Supply the final award as bonus. The multiplier is displayed alongside it. The sample also accepts a BACKGLASS_STATE JSON string. Omit screen when Media selects the entry. When selecting a view inside one entry, send its scene name and a fresh event_id with each occurrence.

For consecutive cues, set Attract as the display’s autoplay fallback. Enable the queue and choose the Queue interrupt policy for cues that should wait their turn. A host with scene-completion support advances the display queue when the active timed cue finishes. Standalone previews return to Attract.

1. Create a project and a scene

  1. In Godot’s Project Manager, choose Create. Name the project Pinball Backglass, choose an empty folder and select the Compatibility renderer. Open the project.
  2. Choose User Interface in the Scene panel to create a root Control. Rename it Backglass, then save the scene as res://backglass.tscn. Godot uses res:// for files inside the project folder.
  3. In Project → Project Settings → Display → Window, set Viewport Width to 1280 and Viewport Height to 720. Set Stretch → Mode to canvas_items so the layout can scale to another window size.
  4. Select Backglass in the Scene tree, choose Add Child Node and add a ColorRect named Background. In the 2D toolbar, open Layout → Full Rect to fill the scene. In the Inspector, set Color to a dark colour such as #101823. Keep Background first in the tree so the controls draw on top.

2. Build the menu and scoreboard

  1. Add a CenterContainer under Backglass, name it Menu, and use Layout → Full Rect. Add a VBoxContainer under Menu and name it Items. The center container centres the box, and the vertical box stacks its children in order.
  2. Under Menu’s Items, add a Label named Title with Text set to Pinball Backglass. Add a Button named ViewScores and set its Text to View scores. The node name and its visible text are separate fields.
  3. Add a second CenterContainer directly under Backglass, name it Scoreboard, and set it to Full Rect. Add a VBoxContainer named Items inside it. Add the following children to that second Items box.
Node type Node name Inspector → Text
Label Title Scoreboard
Label Score Score {{SCORE}}
Label Turn Player {{PLAYER}} Ball {{BALL}}
Label Credits Credits {{CREDIT}}
Button Back Back to menu

Godot Inspector showing Score {{SCORE}} in the Label’s Text field

  1. For each box, set Theme Overrides → Constants → Separation to 16. For the title labels, set Theme Overrides → Font Sizes → Font Size to 64. Use 36 for the scoreboard values and 28 for the buttons. Set each label’s Horizontal Alignment to Center.
  2. Check the Scene tree. Indentation matters because the script in the next step looks up the buttons by their full path.
Backglass (Control)
├── Background (ColorRect)
├── Menu (CenterContainer)
│   └── Items (VBoxContainer)
│       ├── Title (Label)
│       └── ViewScores (Button)
└── Scoreboard (CenterContainer)
    └── Items (VBoxContainer)
        ├── Title (Label)
        ├── Score (Label)
        ├── Turn (Label)
        ├── Credits (Label)
        └── Back (Button)

Godot Scene panel showing Backglass with Background, Menu and Scoreboard, and the child nodes inside each Items container

3. Connect the menu buttons

Select Backglass and click Attach Script above the Scene tree. You can also right-click Backglass and choose Attach Script. In the dialog, choose GDScript, set Path to res://backglass.gd and click Create.

Attach Node Script dialog with GDScript selected, Control as the inherited type, res://backglass.gd as the path and Create at the bottom

Replace the script contents with the following, then save the script and the scene.

extends Control

@onready var menu: CenterContainer = $Menu
@onready var scoreboard: CenterContainer = $Scoreboard


func _ready() -> void:
    $Menu/Items/ViewScores.pressed.connect(_show_scoreboard)
    $Scoreboard/Items/Back.pressed.connect(_show_menu)
    _show_menu()


func _show_menu() -> void:
    scoreboard.hide()
    menu.show()


func _show_scoreboard() -> void:
    menu.hide()
    scoreboard.show()


func _unhandled_input(event: InputEvent) -> void:
    if event.is_action_pressed("ui_accept"):
        pinballctl_input_action("ui_accept")
        accept_event()
    elif event.is_action_pressed("ui_cancel"):
        pinballctl_input_action("ui_cancel")
        accept_event()


func pinballctl_input_action(action: String) -> void:
    match action:
        "ui_accept":
            if menu.visible:
                _show_scoreboard()
            else:
                _show_menu()
        "ui_cancel":
            _show_menu()

Click Run Current Scene or press F6. Click View scores and Back to menu to test both buttons. With the game window focused, try Enter to switch screens and Esc to return to the menu. If the script reports a missing node, compare the node names and indentation with the tree above.

The tutorial’s backglass menu running in Godot with its View scores button

The scoreboard shows literal placeholders in standalone Godot. PinballCTL supplies the live values after it loads the exported scene. The labels should keep their placeholder text in the editor.

4. Export and load the backglass

PinballCTL needs a Godot executable on the machine that runs the display. Check Media → Runtime for Godot binary. If it reports missing, set the executable path under Media → Settings → Godot Binary.

  1. In Godot, choose Project → Export → Add and select Linux for a Pi setup. If the export window requests templates, install the matching version through Editor → Manage Export Templates. With the preset selected, open Resources and keep Export all resources in the project selected. Choose Export PCK/ZIP at the bottom and save Backglass.pck outside the project folder. Godot export guide Godot Export dialog showing the Linux preset and Export all resources in the project selected in the Resources tab

  2. In PinballCTL, open Media → Library and upload Backglass.pck. Go to Scenes → Add Scene, name it Tutorial Backglass, and select its target display.

  3. Add a layer with Type set to Godot Scene. Choose the uploaded pack, select res://backglass.tscn as the Entry Scene, and set Render Mode to Primary so the backglass fills the runtime window.
  4. In that layer’s Input Mapping, add your cabinet Select input. Use Hardware as the trigger type and choose its mapped source and press event. Set Input Kind to Action, Action to ui_accept, and Phase to Tap. This opens the scoreboard from the menu and returns from the scoreboard. For a separate Back input, add another mapping to ui_cancel. Save the Media scene.
  5. In Media → Runtime, choose Launch, select the display and Tutorial Backglass, and choose Launch / Play. Use Windowed for a desktop test. Click View scores on the running display or use the mapped Select input. Keep coil power disconnected during cabinet input tests.

5. Check live values

For a desktop check, open the scoreboard, then reopen Media → Runtime → Launch. Choose the same display, enter score in Token and 00001234 in Value, then choose Update Token. The score label should change. Try player, ball and credit the same way.

To check that gameplay supplies the values, configure your launch and drain sensors in Ball Management, then follow these steps.

  1. In Game Management, start a test game and add Player 2 if your joining policy allows it.
  2. With the scoreboard visible, simulate a launch from Game Management. Trigger a configured Scoring award and check that Player 1’s score changes on the display.
  3. Simulate a drain once the ball-save window has expired. The scoreboard should show the next player and their score. Continue through the players to see the logical ball number change. Add a test credit from Game Management → Credits and check the credit label.

The tutorial scoreboard rendered by PinballCTL showing a sample score, Player 2, Ball 3 and 4 credits

The screenshot uses sample values. If the menu opens but the scoreboard still shows braces, check that the pack is running in PinballCTL and that the Label text uses {{SCORE}}, {{PLAYER}}, {{BALL}} and {{CREDIT}} exactly.

Integration reference

Pinball CTL can inject either:

The most robust pattern is:

That keeps the project easy to test outside Pinball CTL.

Basic Input Setup In Godot

The host runtime already provides these common actions:

For a standalone Godot project, add the same bindings in Project Settings -> Input Map.

Typical menu bindings are:

Here is the simplest standalone-friendly input handler:

func _unhandled_input(event: InputEvent) -> void:
    if not event.is_pressed():
        return
    if event is InputEventKey and event.is_echo():
        return

    if event.is_action_pressed("ui_left"):
        focus_left()
        accept_event()
    elif event.is_action_pressed("ui_right"):
        focus_right()
        accept_event()
    elif event.is_action_pressed("ui_accept"):
        activate_focused()
        accept_event()

This is the preferred pattern because the scene stays fully testable with a keyboard before it is ever exported.

Optional Pinball CTL Runtime Hooks

Pinball CTL will also look for scene methods that can receive input directly.

These are optional, but useful:

func pinballctl_input_action(action: String) -> void:
    match String(action).strip_edges():
        "ui_left":
            focus_left()
        "ui_right":
            focus_right()
        "ui_accept":
            activate_focused()


func pinballctl_input_key(key_name: String, phase: String = "tap") -> void:
    if String(phase).strip_edges().to_lower() == "release":
        return

    match String(key_name).strip_edges().to_lower():
        "left", "arrowleft", "leftarrow":
            focus_left()
        "right", "arrowright", "rightarrow":
            focus_right()
        "up", "arrowup", "uparrow", "enter", "return", "kp_enter":
            activate_focused()

Use these when:

Sending Events Back To Pinball CTL

If your scene should notify the rest of the machine when focus changes or a button is activated, emit custom signals from the scene.

Pinball CTL listens for:

Example:

signal pinballctl_focus_changed(mode_name: String, mode_index: int)
signal pinballctl_custom_event(event_name: String, event_params: Dictionary)


func _emit_focus_event() -> void:
    var mode_name := "CLASSIC"
    var mode_index := 0
    pinballctl_focus_changed.emit(mode_name, mode_index)
    pinballctl_custom_event.emit("BACKGLASS_MENU_FOCUS_CHANGED", {})
    pinballctl_custom_event.emit("BACKGLASS_MENU_FOCUS_" + mode_name, {})


func activate_focused() -> void:
    var mode_name := "CLASSIC"
    pinballctl_custom_event.emit("BACKGLASS_MENU_SELECTED", {})
    pinballctl_custom_event.emit("BACKGLASS_MENU_SELECTED_" + mode_name, {})

Important Custom Event Rule

At the moment, custom scene events should be treated as event names only.

For reliable rule matching:

Good:

Avoid relying on extra custom parameters for Rules matching.

Example Reference Project

The Pinball CTL vector sample shows how cabinet actions, live values and scene events work together.

Exporting As A .pck

Pinball CTL consumes exported Godot packs, not raw project folders.

In The Godot Editor

  1. Open your project in Godot.
  2. Go to Project -> Export.
  3. Create an export preset that supports pack export.
  4. Choose Export PCK/ZIP.
  5. Save the output as a .pck.

From The Command Line

If you prefer CLI export, the typical pattern is:

godot --headless --path /path/to/project --export-pack "Linux" MyScene.pck

Notes:

Uploading The Pack To Media

Open Media -> Library and upload the .pck.

After upload, Pinball CTL treats it as a Godot Scene asset and indexes the scenes inside the pack.

The library entry shows the uploaded pack name, detected scenes and default entry scene.

Adding A Godot Layer

In Media -> Scenes:

  1. Create or open a scene.
  2. Add a layer.
  3. Set Type to Godot Scene.
  4. Choose Godot Scene Pack.
  5. Choose Entry Scene.
  6. Choose Render Mode.

Choose Layered to place Godot content in the scene stack, or Primary to give it the whole runtime window.

Use Primary for menus, full-screen score scenes, and other UI that should control the full display.

Layer Settings Input Mapping

Godot layer inspector with input mapping

Open the sliders settings for a Godot Scene layer. The Input Mapping section sits directly below Entry Scene in the right-side panel.

In each mapping row, choose a Trigger Type and fill in its trigger fields. Resolved Event shows the resulting event. Use Input Kind to choose an Action or Key, then set its Phase.

Trigger Types

Choose Hardware, System or Custom, as in the Rules editor.

Hardware

Choose the mapped device and a gesture such as CLICKED. Pinball CTL shows the canonical event name in Resolved Event.

System

Choose a system category, then select one of its events.

Custom

Enter the event name directly.

Mapping To Actions Or Keys

Use Input Kind to send a Godot action or a keyboard key.

Action Mapping

Use this when your scene listens for Godot actions:

Hardware -> Left Flipper -> CLICKED -> Action -> ui_left -> Clicked
Hardware -> Right Flipper -> CLICKED -> Action -> ui_right -> Clicked
Hardware -> Start Button -> CLICKED -> Action -> ui_accept -> Clicked

Key Mapping

Use this when your scene listens for keys instead of actions.

Set Input Kind to Key, select the capture field and press the key you want to send. Pinball CTL stores its normalised name.

Examples:

Hardware -> Left Flipper -> CLICKED -> Key -> Left -> Clicked
Hardware -> Right Flipper -> CLICKED -> Key -> Right -> Clicked
Hardware -> Start Button -> CLICKED -> Key -> Up -> Clicked

Example Menu Scene

In the vector sample, Left and Right move through the choices and Start selects the highlighted item. The same functions handle keyboard input in Godot and ui_left, ui_right and ui_accept from the cabinet. A rule can handle the Start request from the menu.

Testing The Pack

A good validation sequence is:

  1. Run the scene in Godot with a keyboard.
  2. Export the .pck.
  3. Upload it to Media -> Library.
  4. Add it to a Godot Scene layer.
  5. Launch it from Media -> Runtime.
  6. Test cabinet input through the Input Mapping section.
  7. Check the event log if the scene emits custom events back out.

Troubleshooting

The Scene Looks Wrong In The Scene Editor Preview

The editor preview is not a full embedded Godot renderer.

Test the final scene via Media → Runtime or launch a window from the scene preview controls.

The Wrong Entry Scene Appears

If the selected entry scene does not belong to the chosen pack, Pinball CTL resets it to that pack’s own entry list. Re-select the pack and then choose the entry scene again.

Inputs Do Not Trigger

Check these in order:

  1. The layer Type is Godot Scene.
  2. The correct Godot Scene Pack is selected.
  3. The correct Entry Scene is selected.
  4. The mapping row was saved.
  5. The hardware trigger matches the real event type, usually CLICKED.
  6. The scene actually listens for the mapped action or key.

Custom Events Do Not Appear In The Event Log

Check:

  1. the scene emits pinballctl_custom_event
  2. the event name is non-empty
  3. the parameters are empty: {}
  4. the running .pck was re-exported after the latest scene changes

Render high scores and collect initials

The controller supplies the rows for a Godot scene to lay out using its own labels, containers or drawing code. The vector sample displays the controller’s boards, including active competitions. For on-display initials entry, use a scene that implements the prompt flow below.

  1. In an imported scene that declares signal pinballctl_custom_event(event_name: String, event_params: Dictionary), emit BACKGLASS_HIGH_SCORES_REQUESTED with an empty dictionary to refresh scores. The vector sample requests updates every two seconds in its High Scores and Ball in Play scenes.
  2. In pinballctl_text_values(values: Dictionary), read the PINBALLCTL_HIGH_SCORES dictionary. Its boards dictionary contains all-time, year, month and latest arrays. Each row includes rank, initials, name, score and endedAtMs. Use one row per entry and format the score as an integer. When competition.active is true, use competition.title as the heading and render the boards.competition rows. The same update includes a game dictionary with the controller’s current status, player, ball, score and multiball observation.
  3. If prompt is a dictionary, show initials entry for its name and final score. On confirmation emit BACKGLASS_INITIALS_SUBMITTED with gameId, playerId and the three initials letters. To skip, emit BACKGLASS_INITIALS_SKIPPED with gameId and playerId. Use the returned prompt to move to the next player. A null prompt means entry is finished.

The Godot host uses the configured Media event bridge to read the boards and submit initials. After changing your scene, export and upload the updated pack to Media. See High Scores for rankings and browser controls.

In Development

Find your next step.

Type to search the site.

Fit