@@ -461,40 +461,35 @@ public void LoadBranch(int index)
461
461
return null ;
462
462
}
463
463
464
- private LuaTable CreateMarkerTuple ( TasMovieMarker marker )
465
- {
466
- var table = _th . CreateTable ( ) ;
467
- table [ "Frame" ] = marker . Frame ;
468
- table [ "Text" ] = marker . Message ;
469
- return table ;
470
- }
471
-
472
- [ LuaMethodExample ( "local markerframe = tastudio.getmarkerabove(100).Frame" ) ]
473
- [ LuaMethod ( "getmarkerabove" , "returns a table of the marker at or above the given frame with fields Frame and Text" ) ]
474
- public LuaTable GetMarkerAbove ( int frame )
464
+ /// <remarks>assumes a TAStudio project is loaded</remarks>
465
+ private TasMovieMarkerList MarkerListForBranch ( int ? branchIndex )
466
+ => branchIndex is int i
467
+ ? Tastudio . CurrentTasMovie . Branches [ i ] . Markers
468
+ : Tastudio . CurrentTasMovie . Markers ;
469
+
470
+ [ LuaMethodExample ( """
471
+ local marker_label = tastudio.getmarker(tastudio.find_marker_on_or_before(100));
472
+ """ ) ]
473
+ [ LuaMethod (
474
+ name : "find_marker_on_or_before" ,
475
+ description : "Returns the frame number of the marker closest to the given frame (including that frame, but not after it)."
476
+ + " This may be the power-on marker at 0. Returns nil if the arguments are invalid or TAStudio isn't active."
477
+ + " If branchIndex is specified, searches the markers in that branch instead." ) ]
478
+ public int ? FindMarkerOnOrBefore ( int frame , int ? branchIndex = null )
475
479
=> Engaged ( )
476
- ? CreateMarkerTuple ( Tastudio . CurrentTasMovie . Markers . PreviousOrCurrent ( frame ) )
477
- : _th . CreateTable ( ) ;
478
-
479
- [ LuaMethodExample ( "local branchmarkertext = tastudio.getbranchmarkerabove(0, 100).Text" ) ]
480
- [ LuaMethod ( "getbranchmarkerabove" , "returns a table of the marker at or above the given frame for the given branch index, starting at 0, with fields Frame and Text" ) ]
481
- public LuaTable GetBranchMarkerAbove ( int index , int frame )
482
- => Engaged ( )
483
- ? CreateMarkerTuple ( Tastudio . CurrentTasMovie . Branches [ index ] . Markers . PreviousOrCurrent ( frame ) )
484
- : _th . CreateTable ( ) ;
485
-
486
- [ LuaMethodExample ( "local markertext = tastudio.getmarkers()[1].Text" ) ]
487
- [ LuaMethod ( "getmarkers" , "returns a table of all markers with fields Frame and Text" ) ]
488
- public LuaTable GetMarkers ( )
489
- => Engaged ( )
490
- ? _th . EnumerateToLuaTable ( Tastudio . CurrentTasMovie . Markers . Select ( CreateMarkerTuple ) )
491
- : _th . CreateTable ( ) ;
492
-
493
- [ LuaMethodExample ( "local branchmarkerframe = tastudio.getmarkers(0)[1].Frame" ) ]
494
- [ LuaMethod ( "getbranchmarkers" , "returns a table of all markers for the given branch index, starting at 0, with fields Frame and Text" ) ]
495
- public LuaTable GetBranchMarkers ( int index )
480
+ ? MarkerListForBranch ( branchIndex ) . PreviousOrCurrent ( frame ) ? . Frame
481
+ : null ;
482
+
483
+ [ LuaMethodExample ( """
484
+ local marker_label = tastudio.getmarker(tastudio.get_frames_with_markers()[2]);
485
+ """ ) ]
486
+ [ LuaMethod (
487
+ name : "get_frames_with_markers" ,
488
+ description : "Returns a list of all the frames which have markers on them."
489
+ + " If branchIndex is specified, instead returns the frames which have markers in that branch." ) ]
490
+ public LuaTable GetFramesWithMarkers ( int ? branchIndex = null )
496
491
=> Engaged ( )
497
- ? _th . EnumerateToLuaTable ( Tastudio . CurrentTasMovie . Branches [ index ] . Markers . Select ( CreateMarkerTuple ) )
492
+ ? _th . EnumerateToLuaTable ( MarkerListForBranch ( branchIndex ) . Select ( static m => m . Frame ) )
498
493
: _th . CreateTable ( ) ;
499
494
500
495
[ LuaMethodExample ( "tastudio.removemarker( 500 );" ) ]
0 commit comments