-
Notifications
You must be signed in to change notification settings - Fork 450
Lua tastudio branches #4681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Lua tastudio branches #4681
Changes from all commits
70a7d8a
7ae4c45
8cc9aba
58e3a96
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -447,6 +447,19 @@ public void SetBranchText(string text, int? index = null) | |
| } | ||
| } | ||
|
|
||
| [LuaMethodExample(""" | ||
| tastudio.set_branch_text_by_id("97021544-2454-4483-824f-47f75e7fcb6a", "success"); | ||
| """)] | ||
| [LuaMethod( | ||
| name: "set_branch_text_by_id", | ||
| description: "Loads the branch with the given UUID.")] | ||
| public void SetBranchTextByID(string id, string/*?*/ text) | ||
| { | ||
| var found = GetBranchObjByID(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] | ||
|
|
@@ -505,6 +518,31 @@ 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 UUID.")] | ||
| public void LoadBranchByID(string id) | ||
| { | ||
| var found = GetBranchObjByID(id); | ||
| if (found is not null) Tastudio.LoadBranch(found); | ||
| // else already logged error | ||
| } | ||
|
|
||
| private TasBranch/*?*/ GetBranchObjByID(string id) | ||
| { | ||
| if (!Guid.TryParseExact(id, format: "D", out var parsed)) | ||
| { | ||
| Log($"not a valid UUID: {id}"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| return null; | ||
| } | ||
| var found = Tastudio.CurrentTasMovie.Branches.FirstOrDefault(b => b.Uuid == parsed); | ||
| if (found is null) Log($"no such branch: {id}"); | ||
| return 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) | ||
|
|
@@ -524,6 +562,36 @@ 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 UUID.")] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) |
||
| 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); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer changing the Also, I think the |
||
| 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 UUID." | ||
| + " There is no confirmation, so remember to back up your project before botting with it.")] | ||
| public void DeleteBranchByID(string id) | ||
| { | ||
| var found = GetBranchObjByID(id); | ||
| if (found is not null) Tastudio.CurrentTasMovie.Branches.Remove(found); | ||
| // else already logged error | ||
| } | ||
|
|
||
| [LuaMethodExample("local sttasget = tastudio.getmarker( 500 );")] | ||
| [LuaMethod( | ||
| name: "getmarker", | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
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.