Skip to content

fix(start): recreate G.GAME.viewed_back when Steamodded's run select omits it - #249

Open
scarcer-1 wants to merge 1 commit into
coder:mainfrom
scarcer-1:fix/start-viewed-back-nil
Open

scarcer-1 wants to merge 1 commit into
coder:mainfrom
scarcer-1:fix/start-viewed-back-nil

Conversation

@scarcer-1

@scarcer-1 scarcer-1 commented Nov 13, 2026 •

Copy link
Copy Markdown

Problem

On current Steamodded, start fails on every run, including the first one after a cold launch:

INTERNAL_ERROR - [SMODS balatrobot "src/lua/endpoints/start.lua"]:116:
attempt to index field 'viewed_back' (a nil value)

Same failure as #244.

Cause

Steamodded's reworked run select (smods#1560/#1571, September 2026) no longer creates G.GAME.viewed_back on the setup_run() path. start creates the run with G.FUNCS.setup_run({ config = {} }) and then dereferences G.GAME.viewed_back unconditionally while applying the requested deck, so the endpoint aborts before a run exists.

It is not a "second run in the same session" condition — restarting Balatro does not help, which is what made this hard to pin down.

Fix

Recreate the object when missing, then keep change_to behind a nil check:

G.GAME.selected_back:change_to(deck_data)
if not G.GAME.viewed_back and Back then
  G.GAME.viewed_back = Back(deck_data)
end
if G.GAME.viewed_back then
  G.GAME.viewed_back:change_to(deck_data)
end

viewed_back only backs the deck-preview graphic, so recreating it is closer to vanilla behaviour than skipping the update. This follows the workaround in #244.

Verification

Not run here. No Lua toolchain in this environment, and pytest -n 6 tests/lua needs a live Balatro instance, so make test was not executed. CI should be the check.

What I verified: the failure reproduces on a cold launch with Steamodded main under balatrobot v1.5.2 (macOS, Steam Balatro), and per #244 the Back(deck_data) recreation is what gets past it.

Open question from #244

Whether the deck choice still reaches the run on new Steamodded is untested upstream, since the run-select path changed. Worth confirming after merge that gamestate reports the requested deck rather than the default.

…omits it

On current Steamodded (main, 26.1026.0~dev-b), start fails on every run,
including the first after a cold launch:

  INTERNAL_ERROR - src/lua/endpoints/start.lua:116:
  attempt to index field 'viewed_back' (a nil value)

Steamodded's reworked run select (smods#1560/#1571, September 2026) no longer
creates G.GAME.viewed_back on the setup_run() path, and the endpoint dereferences
it unconditionally while applying the requested deck. It is not a "second run in
the session" condition; restarting the game does not help.

Recreate the object when it is missing (Back(deck_data)) and keep change_to
behind a nil check, so start() works on both vanilla and current Steamodded.
viewed_back only backs the deck-preview graphic, so recreating it is closer to
vanilla behaviour than skipping the update.

Upstream report: coder#244
@scarcer-1
scarcer-1 force-pushed the fix/start-viewed-back-nil branch from 082daaa to 1600464 Compare November 13, 2026 18:19
@scarcer-1 scarcer-1 changed the title fix(start): guard G.GAME.viewed_back before dereferencing it fix(start): recreate G.GAME.viewed_back when Steamodded's run select omits it Nov 13, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant