Skip to content

106 worked example standalone projects with no base content

Alex Diakovsky edited this page Sep 27, 2026 · 1 revision

106. Worked example: standalone projects, with no base content at all

Question: the user sharpened the port's end goal: not just "moddable," but able to develop original content -- "even create our own game based on this framework." Checking that against the code found a real blocker: the editor could not open or create a project with no base content. Design in PORTING_PLAN.md, just before "## 5. Standing instructions".

Step 1: the blocker

ModLoader.mod_problem(dir) was the editor's one gate for "can this be opened":

static func mod_problem(dir: String) -> String:
	...
	if m.get("base_pack") == null or String(m.get("base_pack")) == "":
		return "it is a base pack, not a mod"
	return ""

It exists to stop the editor from ever opening original_pc for editing -- but the check it actually performs is "does this pack's manifest name a base_pack," which conflates two different things: "this is the bundled original content" and "this pack has nothing layered under it." A brand-new standalone project is the second thing, not the first, and got refused for it.

The same field is genuinely required elsewhere, though: ModLoader.load_game_pack() builds the running game's pack as [base_dir] + enabled mods, and a pack in GameSettings.enabled_mods with no base_pack doesn't make sense there -- it isn't meant to layer over anything, it's its own thing. So mod_problem() stays exactly as it was for that use (load_game_pack, list_mods); a new, separate function answers the editor's actual question:

static func protected_base_dirs() -> Array[String]:
	return [BASE_PACK]

static func editor_open_problem(dir: String) -> String:
	...
	var resolved := ProjectSettings.globalize_path(dir)
	for protected in protected_base_dirs():
		if resolved == ProjectSettings.globalize_path(protected):
			return "it is original content, never edited directly"
	return ""

ModWorkspace.open() and editor_main.gd's pre-check both switched to this. protected_base_dirs() is a list (today just original_pc) so a future second bundled base pack, if there ever is one, is one line to add -- the rule was never really "no base_pack field," it was "not the directory this build ships."

Step 2: the second blocker, found by actually trying it

Adding "New game..." (ModWorkspace.create(dir, name, "")) and opening the result immediately hit a second wall: Pack.load_stack() hard-failed with "no layer provides sprites/sprites.json," because a fresh project has no sprites.json at all until something is imported. The check exists to catch a real error (a typo'd directory, a broken layer) -- but a legitimately empty new project looks identical to that from inside load_stack(). Both get_sprite() and get_texture() already degrade gracefully on an empty pack (return {} / null), so nothing downstream actually needs the hard failure; it became a warning instead:

if atlas_textures.is_empty():
	push_warning("Pack.load_stack: no layer provides sprites/sprites.json (%s)" % pack_dir)

Step 3: does every panel survive an empty pack?

Checked directly rather than assumed: VehiclePreviewPanel and MapViewPanel were opened against a project with zero vehicles and zero levels. Both build their pickers/lists from pack.vehicle_order / pack.list_levels(), both empty collections iterate to nothing without error, and both panels' _rebuild()/_fill_list() already guard on "nothing selected" rather than assuming an entry exists. No changes were needed there -- confirmed, not guessed, per returnfire-trace-dont-guess applied to the editor's own code, not just the traced game.

Step 4: confirmation

tools/tests/standalone_project_check.gd:

  • ModWorkspace.create(dir, name, "") succeeds; the manifest's base_pack is "".
  • editor_open_problem() allows it; mod_problem() still refuses it (correctly -- it isn't a layerable mod).
  • ModWorkspace.open() succeeds; the resulting pack has exactly one layer, itself.
  • The vehicle preview and map panels open onto it with nothing selected, not an error.
  • A first vehicle added directly to the project (no roster, no original content anywhere in the chain) shows up after a reload.
  • original_pc itself is still refused, by both editor_open_problem() and ModWorkspace.open().

What this does not change

Nothing about layered mods changed: an ordinary mod (base_pack: "original_pc") still works exactly as before, still shows up in GameSettings.enabled_mods, still gets validated by the unchanged mod_problem(). This is additive -- a second, legitimate way to use the same editor and the same file formats, not a different mode bolted on. The model assembler plan and the rest of the vehicle/map editor work apply to a standalone project exactly as they do to a mod, since neither one has ever assumed a base layer exists.

Clone this wiki locally