Skip to content

Instantly share code, notes, and snippets.

@pjobson
Last active June 13, 2026 02:27
Show Gist options
  • Select an option

  • Save pjobson/d30f3c2bfb6fc17d2d51488505c1db5b to your computer and use it in GitHub Desktop.

Select an option

Save pjobson/d30f3c2bfb6fc17d2d51488505c1db5b to your computer and use it in GitHub Desktop.
Balatro Mod - Smash R to Restart
--- STEAMODDED HEADER
--- MOD_NAME: Smash R to Restart
--- MOD_ID: SmashRtoRestart
--- MOD_AUTHOR: [pjobson]
--- MOD_DESCRIPTION: Press R 5 times in a row to start a new random run, this is useful if you play balatro via synergy and holding the R key does not work.
--- PRIORITY: 0
--- BADGE_COLOUR: E63946
--- DISPLAY_NAME: Smash R to Restart
----------------------------------------------
local r_press_count = 0
-- Store the original key_press function
local original_key_press = Controller.key_press
function Controller:key_press(key)
-- During a run, intercept 'r' key to prevent base game restart handler
if G.STAGE == G.STAGES.RUN and key == "r" then
r_press_count = r_press_count + 1
if r_press_count >= 5 then
r_press_count = 0
-- Start a new random run
if G.GAME then
-- Save run parameters before transition
local saved_stake = G.GAME.stake
local saved_challenge = G.GAME.challenge
local saved_back = G.GAME.selected_back
-- Build a fake UI element with proper structure
local fake_element = {
config = {
id = ''
}
}
G.FUNCS.start_run(fake_element, {
stake = saved_stake,
challenge = saved_challenge,
deck = saved_back
})
end
end
-- Don't call original - we're handling 'r' ourselves during a run
return
end
-- For all other keys (or 'r' outside of a run), call original handler
original_key_press(self, key)
-- Reset counter if any other key is pressed during a run
if G.STAGE == G.STAGES.RUN then
r_press_count = 0
end
end
----------------------------------------------
------------MOD CODE END----------------------

Comments are disabled for this gist.