TASEmulators / TASEmulators/BizHawk

Allow Lua scripts to control TAStudio state capture

Open
#4,627 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

re: Lua API/scripting Request: Feature/Enhancement Tool: TAStudio
Dominant language
C#
Stars
2.8k
Forks
468
PR merge metrics
No merged PRs in 30d

Description

I think it would be useful if Lua scripts could control when savestates are captured in TAStudio. My immediate use case is poking RAM to disable rendering in melonDS while doing long auto-restore seeks, and preventing TAStudio from capturing states where rendering is disabled. (Yes I know this has potential to cause desyncs if used in certain situations.)

Although my particular use case only requires a way for Lua to prevent state capture, it may be worthwhile to give Lua full control to enable other possible use cases as well. This could take the form of a pair of callbacks:

  1. bool? CaptureOverride(frame) If return value is true, force capture. If false, do not capture. If nil, run regular capture logic.
  2. int RemoveState() Similar to PagedStateManager.FreePage, but returns a frame number. The state on the given frame will be removed. If there is no state on that frame, regular state removal logic will be used.

As-is, support for CaptureOverride returning true will only be useful when used in combination with RemoveState because force-captured states are quickly removed once more states are force-captured. We could also address this by making Lua-forced captures go in the "new states" group.

Support will be limited to PagedStateManager. ZwinderStateManager cannot accept out-of-order states, so it is not always possible to force capture.

Other potential use cases could be not capturing during loading screens, capturing based on in-game events, or making it easier for users to manage states for cores that don't automatically capture states.

Thoughts?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading PagedStateManager and ZwinderStateManager, then trace how TAStudio decides when to capture and remove states and how Lua callbacks are exposed. Done requires a settled callback/API design that respects PagedStateManager's ordering constraints and covers the requested capture and removal behavior; the issue names no files or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, lua
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.