Menu
Sign inDownload

Example: Landing checklist

A page of the pad's own buttons, every way to use them, and a widget that reads the game.

Most of this add-on is its ready-made page: the pad's own buttons, each naming a game action (pressed through the game when it can, else with the player's own keybind), a toggle's Deploy form, a button on Hold and one on Toggle, a fixed key, lights, readouts and a gauge. Its one widget reads the game's live state in its frame and says when you're clear to land. Tested with every Comms Array build. Buttons on a page: the reference.

manifest.json

{"name": "landing", "package": "ca_landing", "version": "1.0.0", "title": "Landing checklist (example)",
 "description": "A landing page for Star Citizen: the pad's own buttons (gear, VTOL, doors, lights, space brake, request landing) and a checklist that lights up when you're clear to land.",
 "author": "you", "api": 1, "api_version": "1.4", "games": ["starcitizen"],
 "permissions": ["pad.widgets", "state.live"],
 "widgets": ["landing_checklist"], "pad_js": "pad_landing.js",
 "pages": [{"title": "Landing", "desc": "Gear, VTOL, doors, lights and a clear-to-land checklist", "cols": 24,
            "when": ["in_ship", "flying"], "priority": 15,
            "widgets": [
              {"type": "landing_checklist", "label": "Clear to land", "x": 0, "y": 0, "w": 8, "h": 6},
              {"type": "readout", "metric": "speed", "x": 8, "y": 0, "w": 4, "h": 2},
              {"type": "readout", "metric": "radar_altitude", "label": "Above ground", "x": 12, "y": 0, "w": 4, "h": 2},
              {"type": "gauge", "metric": "hydrogen", "label": "Fuel", "x": 16, "y": 0, "w": 4, "h": 2},
              {"type": "light", "metric": "warning_lights", "part": "PWR", "x": 20, "y": 0, "w": 2, "h": 2},
              {"type": "light", "metric": "warning_lights", "part": "HIT", "x": 22, "y": 0, "w": 2, "h": 2},

              {"type": "button", "action": "v_atc_request", "label": "Request landing", "x": 8, "y": 2, "w": 8, "h": 2},
              {"type": "button", "action": "v_toggle_landing_system", "label": "Gear", "x": 16, "y": 2, "w": 4, "h": 2},
              {"type": "button", "action": "v_deploy_landing_system", "label": "Gear down", "color": "green", "x": 20, "y": 2, "w": 4, "h": 2},

              {"type": "button", "action": "v_vtol_toggle", "label": "VTOL", "x": 8, "y": 4, "w": 4, "h": 2},
              {"type": "button", "action": "v_toggle_all_doors", "label": "Doors", "x": 12, "y": 4, "w": 4, "h": 2},
              {"type": "button", "action": "v_lights", "label": "Lights", "x": 16, "y": 4, "w": 4, "h": 2},
              {"type": "button", "action": "v_space_brake", "label": "Space brake", "mode": "hold", "color": "amber", "x": 20, "y": 4, "w": 4, "h": 2},

              {"type": "button", "action": "v_flightready", "label": "Flight ready", "color": "green", "when": ["landed"], "x": 0, "y": 6, "w": 8, "h": 2},
              {"type": "button", "action": "moveforward", "label": "Auto-walk", "mode": "toggle", "when": ["on_foot"], "x": 8, "y": 6, "w": 8, "h": 2},
              {"type": "button", "keys": "f11", "label": "Screenshot (F11)", "color": "grey", "x": 16, "y": 6, "w": 8, "h": 2}
            ]}]}

ca_landing/__init__.py

"""Example Comms Array add-on: a landing page made of the pad's own buttons, plus one widget that reads the game.

Most of this add-on is its ready-made page (manifest.json "pages"): buttons that name the game's actions (the pad presses
them through the game when it offers them, else with the player's current keybind, so the page follows everyone's own
binds), a button on Hold and one on Toggle, a fixed key, lights, readouts and a gauge. Its own widget
(pad_landing.js) only reads the live state in its frame, so the PC side has nothing to do: it just has to exist.
"""


class Landing:
    def __init__(self, api):
        self.api = api


def create(api):
    return Landing(api)

ca_landing/pad_landing.js

// The Landing checklist's one widget. Everything else on its page is the pad's own: buttons that press the game's
// actions (through the game when it can, else with the player's own keybind), lights and readouts (manifest.json).
// This tile only reads: the game's live values and situations (CA.value, CA.state.tags), no call to the PC at all.

// The checks: a label, and how to judge it from the live state ("ok" | "bad" | "" when the game doesn't say).
const CHECKS = [
  ["Gear down", (s) => (s.tags.includes("gear_down") ? "ok" : "bad")],
  ["Under 20 m/s", () => { const v = CA.value("speed").v; return v == null ? "" : v <= 20 ? "ok" : "bad"; }],
  ["Under 150 m", () => { const v = CA.value("radar_altitude").v; return v == null ? "" : v <= 150 ? "ok" : "bad"; }],
  ["Not in combat", (s) => (s.tags.includes("combat") ? "bad" : "ok")],
];

CA.widget("landing_checklist", {
  add: { label: "Landing checklist", desc: "Lights up when you're clear to land: gear, speed, height, no combat", size: [8, 6],
         props: () => ({ label: "Clear to land" }) },
  settings: [{ key: "label", type: "text", label: "Label", max: 40 }],
  tile(root, w) {
    // the pack's parts by class name (API 1.4): a screen for the verdict, the table (with its lamps) for the checks.
    // On a button pack they're drawn in the pack; without one, in the pad's plain look.
    root.innerHTML = `<div class="w" style="display:flex;flex-direction:column;gap:6px;padding:8px">
      <div class="pk-screen verdict" style="text-align:center;font-weight:700"></div>
      <div class="checks" style="flex:1;min-height:0;display:flex"></div></div>`;
    const verdict = root.querySelector(".verdict"), checks = root.querySelector(".checks");
    const draw = () => {
      const s = { tags: CA.state?.tags || [] };
      if (s.tags.includes("landed")) { verdict.textContent = "Landed"; checks.innerHTML = ""; return; }
      const rows = CHECKS.map(([label, judge]) => ({ label, level: judge(s) }));
      const clear = rows.every((r) => r.level === "ok");
      verdict.textContent = clear ? (w.label || "Clear to land").toUpperCase() : "Not yet";
      verdict.style.color = clear ? "var(--ok)" : "";
      checks.innerHTML = CA.table([{ kind: "lamp" }, { kind: "text" }],
        rows.map((r) => ({ cells: [r.level || "off", r.label], level: r.level })), "");
      CA.fitTable(checks);
    };
    CA.onState(draw);                                  // every live update (several a second)
    draw();
  },
});
From the Comms Array source, commsarray-agent d615c4d.