Skip to content

Commit 8fefa49

Browse files
committed
feat: add fps cap setting
1 parent b92afe3 commit 8fefa49

5 files changed

Lines changed: 11 additions & 2 deletions

File tree

docs/cli.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ All options can be set via CLI flags or environment variables. CLI flags overrid
2424
| `--audio` | `BALATROBOT_AUDIO` | `0` | Enable audio |
2525
| `--debug` | `BALATROBOT_DEBUG` | `0` | Enable debug mode (requires DebugPlus mod) |
2626
| `--no-shaders` | `BALATROBOT_NO_SHADERS` | `0` | Disable all shaders |
27+
| `--fps-cap FPS_CAP` | `BALATROBOT_FPS_CAP` | `60` | Maximum FPS cap |
2728
| `--balatro-path BALATRO_PATH` | `BALATROBOT_BALATRO_PATH` | auto-detected | Path to Balatro game directory |
2829
| `--lovely-path LOVELY_PATH` | `BALATROBOT_LOVELY_PATH` | auto-detected | Path to lovely library (dll/so/dylib) |
2930
| `--love-path LOVE_PATH` | `BALATROBOT_LOVE_PATH` | auto-detected | Path to LOVE executable (native only) |

src/balatrobot/cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def create_parser() -> argparse.ArgumentParser:
1515
# No defaults - env vars and dataclass defaults handle it
1616
parser.add_argument("--host", help="Server hostname (default: 127.0.0.1)")
1717
parser.add_argument("--port", type=int, help="Server port (default: 12346)")
18+
parser.add_argument("--fps-cap", type=int, help="Maximum FPS cap (default: 60)")
1819
parser.add_argument("--logs-path", help="Directory for log files (default: logs)")
1920

2021
# Boolean flags - store_const so None means "not provided" -> check env var

src/balatrobot/config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"audio": "BALATROBOT_AUDIO",
1515
"debug": "BALATROBOT_DEBUG",
1616
"no_shaders": "BALATROBOT_NO_SHADERS",
17+
"fps_cap": "BALATROBOT_FPS_CAP",
1718
"balatro_path": "BALATROBOT_BALATRO_PATH",
1819
"lovely_path": "BALATROBOT_LOVELY_PATH",
1920
"love_path": "BALATROBOT_LOVE_PATH",
@@ -24,7 +25,7 @@
2425
BOOL_FIELDS = frozenset(
2526
{"fast", "headless", "render_on_api", "audio", "debug", "no_shaders"}
2627
)
27-
INT_FIELDS = frozenset({"port"})
28+
INT_FIELDS = frozenset({"port", "fps_cap"})
2829

2930

3031
def _parse_env_value(field: str, value: str) -> str | int | bool:
@@ -51,6 +52,7 @@ class Config:
5152
audio: bool = False
5253
debug: bool = False
5354
no_shaders: bool = False
55+
fps_cap: int = 60
5456

5557
# Launcher
5658
balatro_path: str | None = None

src/lua/settings.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ BalatroBot configure settings in Balatro using the following environment variabl
2424
2525
- BALATROBOT_NO_SHADERS: whether to disable all shaders for better performance.
2626
1 for disable shaders, 0 for enable shaders (default: 0)
27+
28+
- BALATROBOT_FPS_CAP: the maximum FPS cap for the game.
29+
Type number (default: 60)
2730
]]
2831

2932
---@diagnostic disable: duplicate-set-field
@@ -38,6 +41,7 @@ BB_SETTINGS = {
3841
audio = os.getenv("BALATROBOT_AUDIO") == "1" or false,
3942
debug = os.getenv("BALATROBOT_DEBUG") == "1" or false,
4043
no_shaders = os.getenv("BALATROBOT_NO_SHADERS") == "1" or false,
44+
fps_cap = tonumber(os.getenv("BALATROBOT_FPS_CAP")) or 60,
4145
}
4246

4347
---@type boolean?
@@ -67,7 +71,7 @@ local function configure_settings()
6771
G.F_MUTE = true
6872

6973
-- performance
70-
G.FPS_CAP = 60
74+
G.FPS_CAP = BB_SETTINGS.fps_cap
7175
G.SETTINGS.GAMESPEED = 4
7276
G.ANIMATION_FPS = 10
7377

src/lua/utils/types.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@
275275
---@field audio boolean Whether to play audio (enables sound thread and sets volume levels)
276276
---@field debug boolean Whether debug mode is enabled (requires DebugPlus mod)
277277
---@field no_shaders boolean Whether to disable all shaders for better performance (causes visual glitches)
278+
---@field fps_cap integer Maximum FPS cap for the game (default: 60)
278279
---@field setup fun()? Initialize and apply all BalatroBot settings
279280

280281
---@class Debug

0 commit comments

Comments
 (0)