Skip to content

Commit 00c2a7b

Browse files
committed
Add tastudio.get_branch_index_by_id
1 parent a073e6b commit 00c2a7b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,19 @@ public LuaTable GetBranches()
403403
indexFrom: 0);
404404
}
405405

406+
[LuaMethodExample("""
407+
tastudio.setbranchtext("New label", tastudio.get_branch_index_by_id(branch_id));
408+
""")]
409+
[LuaMethod(
410+
name: "get_branch_index_by_id",
411+
description: "Finds the branch with the given UUID (0-indexed). Returns -1 if not found.")]
412+
public int GetBranchIndexByID(string id)
413+
{
414+
if (!Guid.TryParseExact(id, format: "D", out var parsed)) return -1;
415+
return Tastudio.CurrentTasMovie.Branches.Index()
416+
.FirstOrNull(tuple => tuple.Item.Uuid == parsed)?.Index ?? -1;
417+
}
418+
406419
[LuaMethodExample("local nltasget = tastudio.getbranchinput( \"97021544-2454-4483-824f-47f75e7fcb6a\", 500 );")]
407420
[LuaMethod("getbranchinput", "Gets the controller state of the given frame with the given branch identifier")]
408421
public LuaTable GetBranchInput(string branchId, int frame)

0 commit comments

Comments
 (0)