From 68f6bde37d7ea1fc761fadc186ce2b509d8431bf Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Wed, 15 Apr 2026 10:41:22 +1000 Subject: [PATCH 1/5] Minor copyedits to Lua `tastudio.*` docs --- .../tools/Lua/Libraries/TAStudioLuaLibrary.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs b/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs index 6c7406e0428..339dc128be5 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs @@ -471,12 +471,12 @@ public LuaTable GetBranches() """)] [LuaMethod( name: "get_branch_index_by_id", - description: "Finds the branch with the given UUID (0-indexed). Returns nil if not found.")] + description: "Finds the branch with the given ID (0-indexed). Returns nil if not found.")] public int? GetBranchIndexByID(string id) { if (!Guid.TryParseExact(id, format: "D", out var parsed)) { - Log($"not a valid UUID: {id}"); + Log($"[tastudio.get_branch_index_by_id] not a valid UUID: {id}"); return null; } return Tastudio.CurrentTasMovie.Branches.Index() From 4e7502ab57450205722b4b9b09e6483e46a3edca Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Mon, 27 Apr 2026 16:21:09 +1000 Subject: [PATCH 2/5] Add Lua function `tastudio.load_branch_by_id` --- .../tools/Lua/Libraries/TAStudioLuaLibrary.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs b/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs index 339dc128be5..2f0108bcc7b 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs @@ -506,6 +506,28 @@ public LuaTable GetBranchInput(string branchId, int frame) return table; } + [LuaMethodExample(""" + tastudio.load_branch_by_id("97021544-2454-4483-824f-47f75e7fcb6a"); + """)] + [LuaMethod( + name: "load_branch_by_id", + description: "Loads the branch with the given ID.")] + public void LoadBranchByID(string id) + { + if (!Guid.TryParseExact(id, format: "D", out var parsed)) + { + Log($"[tastudio.load_branch_by_id] not a valid UUID: {id}"); + return; + } + var found = Tastudio.CurrentTasMovie.Branches.FirstOrDefault(b => b.Uuid == parsed); + if (found is null) + { + Log($"[tastudio.load_branch_by_id] no such branch: {id}"); + return; + } + Tastudio.LoadBranch(found); + } + [LuaMethodExample("tastudio.loadbranch(0)")] [LuaMethod("loadbranch", "Loads a branch at the given index, if a branch at that index exists.")] public void LoadBranch(int index) From 91a7100253f6667cd4fdac0b5dff838d574e9ba5 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Wed, 15 Apr 2026 10:53:32 +1000 Subject: [PATCH 3/5] Add Lua function `tastudio.create_branch` --- .../tools/Lua/Libraries/TAStudioLuaLibrary.cs | 16 ++++++++++++++++ .../tools/TAStudio/TAStudio.Designer.cs | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs b/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs index 2f0108bcc7b..df610fdd222 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs @@ -547,6 +547,22 @@ public void LoadBranch(int index) } } + [LuaMethodExample(""" + local branch_id = tastudio.create_branch("automated attempt"); + """)] + [LuaMethod( + name: "create_branch", + description: "Creates a new branch at the end of the list, and returns its ID.")] + public string CreateBranch(string/*?*/ text = null) + { + Tastudio.BookMarkControl.Branch(); + var index = Tastudio.CurrentTasMovie.Branches.Count - 1; + var branch = Tastudio.CurrentTasMovie.Branches[index]; + branch.UserText = text; + Tastudio.BranchSavedCallback?.Invoke(index); + return branch.Uuid.ToString("D"); + } + [LuaMethodExample("local sttasget = tastudio.getmarker( 500 );")] [LuaMethod( name: "getmarker", diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs index 79a3f6325d7..f52b1d5a13b 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs @@ -898,7 +898,7 @@ private void InitializeComponent() private BizHawk.WinForms.Controls.ToolStripMenuItemEx ToBk2MenuItem; private BizHawk.WinForms.Controls.ToolStripMenuItemEx recentMacrosToolStripMenuItem; private BizHawk.WinForms.Controls.ToolStripSeparatorEx toolStripSeparator22; - private BookmarksBranchesBox BookMarkControl; + internal BookmarksBranchesBox BookMarkControl; private BizHawk.WinForms.Controls.ToolStripMenuItemEx BranchContextMenuItem; private System.Windows.Forms.SplitContainer BranchesMarkersSplit; private System.Windows.Forms.SplitContainer MainVertialSplit; From 7d8eff1a5f78690631ea700143c86d0e3fddb3b1 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Mon, 27 Apr 2026 16:21:25 +1000 Subject: [PATCH 4/5] Add Lua function `tastudio.delete_branch_by_id` --- .../tools/Lua/Libraries/TAStudioLuaLibrary.cs | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs b/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs index df610fdd222..81d665b9eeb 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs @@ -513,19 +513,22 @@ public LuaTable GetBranchInput(string branchId, int frame) name: "load_branch_by_id", description: "Loads the branch with the given ID.")] public void LoadBranchByID(string id) + { + var found = GetBranchObjByID(id: id, callerFunctionName: "load_branch_by_id"); + if (found is not null) Tastudio.LoadBranch(found); + // else already logged error + } + + private TasBranch/*?*/ GetBranchObjByID(string id, string callerFunctionName) { if (!Guid.TryParseExact(id, format: "D", out var parsed)) { - Log($"[tastudio.load_branch_by_id] not a valid UUID: {id}"); - return; + Log($"[tastudio.{callerFunctionName}] not a valid UUID: {id}"); + return null; } var found = Tastudio.CurrentTasMovie.Branches.FirstOrDefault(b => b.Uuid == parsed); - if (found is null) - { - Log($"[tastudio.load_branch_by_id] no such branch: {id}"); - return; - } - Tastudio.LoadBranch(found); + if (found is null) Log($"[tastudio.{callerFunctionName}] no such branch: {id}"); + return found; } [LuaMethodExample("tastudio.loadbranch(0)")] @@ -563,6 +566,20 @@ public string CreateBranch(string/*?*/ text = null) return branch.Uuid.ToString("D"); } + [LuaMethodExample(""" + tastudio.delete_branch_by_id("97021544-2454-4483-824f-47f75e7fcb6a"); + """)] + [LuaMethod( + name: "delete_branch_by_id", + description: "Deletes the branch with the given ID." + + " There is no confirmation, so remember to back up your project before botting with it.")] + public void DeleteBranchByID(string id) + { + var found = GetBranchObjByID(id: id, callerFunctionName: "delete_branch_by_id"); + if (found is not null) Tastudio.CurrentTasMovie.Branches.Remove(found); + // else already logged error + } + [LuaMethodExample("local sttasget = tastudio.getmarker( 500 );")] [LuaMethod( name: "getmarker", From dc7c820e20dc95617c532c29fa3ec07036a2a886 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Wed, 15 Apr 2026 11:04:58 +1000 Subject: [PATCH 5/5] Add Lua function `tastudio.set_branch_text_by_id` --- .../tools/Lua/Libraries/TAStudioLuaLibrary.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs b/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs index 81d665b9eeb..e49a7600f6b 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs @@ -448,6 +448,19 @@ public void SetBranchText(string text, int? index = null) } } + [LuaMethodExample(""" + tastudio.set_branch_text_by_id("97021544-2454-4483-824f-47f75e7fcb6a", "success at frame "..emu.framecount()); + """)] + [LuaMethod( + name: "set_branch_text_by_id", + description: "Loads the branch with the given ID.")] + public void SetBranchTextByID(string id, string/*?*/ text) + { + var found = GetBranchObjByID(id: id, callerFunctionName: "set_branch_text_by_id"); + if (found is not null) found.UserText = text; + // else already logged error + } + [LuaMethodExample("local nltasget = tastudio.getbranches( );")] [LuaMethod("getbranches", "Returns a list of the current tastudio branches. Each entry will have the Id, Frame, and Text properties of the branch")] [return: LuaZeroIndexed]