Count launches on this computer. The key is shared by all Programs on that computer,
so it uses an example_ prefix to reduce accidental collisions.
terminal.clear();
const stored = load.computer("example_visits");
const previous = typeof stored === "number" && Number.isSafeInteger(stored) && stored >= 0 ? stored : 0;
const visits = previous + 1;
await save.computer("example_visits", visits);
terminal.writeLine(`Visits to this computer: ${visits}`);
terminal.writeLine(visits === 1 ? "No previous activity recorded." : "Welcome back, operator.");
The first launch prints Visits to this computer: 1. Later launches increment it,
including after closing the window, power cycling, or restarting Foundry.
Another computer starts its own counter. Invalid existing counter data starts at zero.
Uses load.computer and save.computer. This read/change/save is not an atomic increment; concurrent Programs can overwrite an update. The example awaits the save before displaying success.