Skip to content

Lua tastudio branches#4681

Draft
YoshiRulz wants to merge 4 commits intomasterfrom
lua-tastudio-branches
Draft

Lua tastudio branches#4681
YoshiRulz wants to merge 4 commits intomasterfrom
lua-tastudio-branches

Conversation

@YoshiRulz
Copy link
Copy Markdown
Member

dev build for branch | TASEmulators:lua-tastudio-branches

resolves #4073

@YoshiRulz YoshiRulz requested a review from adelikat April 15, 2026 01:02
@YoshiRulz YoshiRulz added Tool: TAStudio re: Lua API/scripting Relating to EmuHawk's Lua API (not the Lua Console) labels Apr 15, 2026
Comment thread src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs Outdated
@SuuperW

This comment was marked as resolved.

@YoshiRulz YoshiRulz force-pushed the lua-tastudio-branches branch from f667900 to 58e3a96 Compare April 20, 2026 11:38
Copy link
Copy Markdown
Contributor

@SuuperW SuuperW left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(and there might be stuff to update regarding the recent addition of LuaCATS documentation, but I haven't looked at that)


[LuaMethodExample("""
tastudio.set_branch_text_by_id("97021544-2454-4483-824f-47f75e7fcb6a", "success");
""")]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "success" is a strange branch text to use as the example here. Something more obviously a branch's text (even "branch text" or "branch name") would be more appropriate.

{
if (!Guid.TryParseExact(id, format: "D", out var parsed))
{
Log($"not a valid UUID: {id}");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something indicating that this message is about a branch operation would be good. Seeing this pop up in the output when running a Lua script, the user (even if they are the script author) might have no idea what this is about or what a UUID is. "not a valid branch id: {id}" would be better, I think.

""")]
[LuaMethod(
name: "create_branch",
description: "Creates a new branch at the end of the list, and returns its UUID.")]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly here I think UUID should just be ID. (and the description for delete)

var index = Tastudio.CurrentTasMovie.Branches.Count - 1;
var branch = Tastudio.CurrentTasMovie.Branches[index];
branch.UserText = text;
Tastudio.BranchSavedCallback?.Invoke(index);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer changing the Branch method to return the instance, instead of grabbing it by index here.

Also, I think the Branch method should handle calling BranchSavedCallback. It looks like from reading related code that the callback isn't called if you branch with the context menu item, so you'd be fixing that too.

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

Labels

re: Lua API/scripting Relating to EmuHawk's Lua API (not the Lua Console) Tool: TAStudio

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow saving new branches via Lua?

2 participants