<pclass="rvps10"><spanclass="rvts21">TAS Editor v1.0 comes with the library of 24 functions available for Lua scripts running in FCEUX emulator. With Lua scripts you can automate some aspects of TASing and even create your own tools for movie editing.</span></p>
<pclass="rvps10"><spanclass="rvts21">In FCEUX folder there's </span><spanclass="rvts20">/luaScripts</span><spanclass="rvts21"> folder with </span><spanclass="rvts20">/taseditor</span><spanclass="rvts21"> subfolder in it. There you can find examples of scripts using functions of this library.</span></p>
<pclass="rvps10"><spanclass="rvts21">If you don't know how to make and run Lua scripts in emulators, read </span><aclass="rvts27"href="AdvancedFeatures.html#UsingLua">Advanced Features</a><spanclass="rvts21"> and also refer to </span><aclass="rvts27"href="http://www.fceux.com/web/help/fceux.html?Commands.html"target="_blank">FCEUX Help</a><spanclass="rvts21">.</span></p>
<pclass="rvps10"><spanclass="rvts21">Registers a callback function ("Auto Function") that runs periodically. The Auto Function can be registered and will be called even when TAS Editor isn't engaged.</span></p>
<pclass="rvps10"><spanclass="rvts21">When FCEUX is unpaused, your function will be called at the end of every frame (running 60 times per second on NTSC and 50 times per second on PAL).</span></p>
<pclass="rvps10"><spanclass="rvts21">When FCEUX is paused, your function will be called 20 times per second.</span></p>
<pclass="rvps10"><spanclass="rvts21">User can switch on/off auto-calling by checking "Auto function" checkbox in TAS Editor GUI.</span></p>
<pclass="rvps10"><spanclass="rvts21">Like other callback-registering functions provided by FCEUX, there is only one registered callback at a time per registering function per script. If you register two callbacks, the second one will replace the first, and the call to </span><spanclass="rvts20">taseditor.registerauto()</span><spanclass="rvts21"> will return the old callback. You may register </span><spanclass="rvts71">nil</span><spanclass="rvts21"> instead of a function to clear a previously-registered callback.</span></p>
<pclass="rvps10"><spanclass="rvts21">If a script returns while it still has registered callbacks, FCEUX will keep it alive to call those callbacks when appropriate, until either the script is stopped by the user or all of the callbacks are de-registered.</span></p>
<pclass="rvps10"><spanclass="rvts21">Registers a callback function ("Manual Function") that can be called manually by TAS Editor user. The function can be registered even when TAS Editor isn't engaged.</span></p>
<pclass="rvps10"><spanclass="rvts21">The Manual function doesn't depend on paused or unpaused FCEUX status. It will be called once every time user presses </span><spanclass="rvts29">Run function</span><spanclass="rvts21"> button in TAS Editor GUI.</span></p>
<pclass="rvps10"><spanclass="rvts21">You can provide a new name for this button.</span></p>
<pclass="rvps10"><spanclass="rvts21">The Manual function cannot be run more often than TAS Editor window updates (60/50 FPS or 20FPS when emulator is paused).</span></p>
<pclass="rvps10"><spanclass="rvts21">In FCEUX code Manual function runs right after Auto Function.</span></p>
<pclass="rvps10"><spanclass="rvts21">You can use this feature to create new tools for TAS Editor. For example, you can write a script that reverses currently selected input, so user will be able to reverse input by selecting a range and clicking </span><spanclass="rvts29">Run function</span><spanclass="rvts21"> button.</span></p>
<pclass="rvps10"><spanclass="rvts21">Like other callback-registering functions provided by FCEUX, there is only one registered callback at a time per registering function per script. If you register two callbacks, the second one will replace the first, and the call to </span><spanclass="rvts20">taseditor.registermanual()</span><spanclass="rvts21"> will return the old callback. You may call </span><spanclass="rvts20">taseditor.registermanual(</span><spanclass="rvts71">nil</span><spanclass="rvts20">)</span><spanclass="rvts21"> to clear a previously-registered callback.</span></p>
<pclass="rvps10"><spanclass="rvts21">If a script returns while it still has registered callbacks, FCEUX will keep it alive to call those callbacks when appropriate, until either the script is stopped by the user or all of the callbacks are de-registered.</span></p>
<pclass="rvps10"><spanclass="rvts21">Returns </span><spanclass="rvts71">true</span><spanclass="rvts21"> if TAS Editor is currently engaged, </span><spanclass="rvts71">false</span><spanclass="rvts21"> if otherwise.</span></p>
<pclass="rvps10"><spanclass="rvts21">Also when TAS Editor is engaged, </span><spanclass="rvts20">movie.mode()</span><spanclass="rvts21"> returns "taseditor" string.</span></p>
<pclass="rvps10"><spanclass="rvts21">Returns </span><spanclass="rvts71">true</span><spanclass="rvts21"> if given frame is marked in TAS Editor, </span><spanclass="rvts71">false</span><spanclass="rvts21"> if not marked.</span></p>
<pclass="rvps10"><spanclass="rvts21">If TAS Editor is not engaged, returns </span><spanclass="rvts71">false</span><spanclass="rvts21">.</span></p>
<pclass="rvps10"><spanclass="rvts21">Sets Marker on given frame. Returns index number of the Marker created.</span></p>
<pclass="rvps10"><spanclass="rvts21">If that frame is already marked, no changes will be made, and the function will return the index number of existing Marker.</span></p>
<pclass="rvps10"><spanclass="rvts21">You can set markers even outside input range.</span></p>
<pclass="rvps10"><spanclass="rvts21">If TAS Editor is not engaged, returns -1.</span></p>
<pclass="rvps10"><spanclass="rvts21">Returns string representing the Note of given Marker.</span></p>
<pclass="rvps10"><spanclass="rvts21">Returns </span><spanclass="rvts71">nil</span><spanclass="rvts21"> if TAS Editor is not engaged.</span></p>
<pclass="rvps10"><spanclass="rvts21">If given index is invalid (if Marker with this index number doesn't exist), returns note of the zeroth marker.</span></p>
<pclass="rvps10"><spanclass="rvts21">Returns </span><spanclass="rvts71">nil</span><spanclass="rvts21"> if TAS Editor is not engaged.</span></p>
<pclass="rvps10"><spanclass="rvts21">When you want to check Recorder's read-only state, use </span><spanclass="rvts20">emu.readonly()</span><spanclass="rvts21">.</span></p>
<pclass="rvps10"><spanclass="rvts21">Returns a table (array) containing numbers of currently selected frames. These numbers are sorted in ascending order.</span></p>
<pclass="rvps10"><spanclass="rvts21">If no frames are selected at the moment, returns </span><spanclass="rvts71">nil</span><spanclass="rvts21">.</span></p>
<pclass="rvps10"><spanclass="rvts21">If TAS Editor is not engaged, returns </span><spanclass="rvts71">nil</span><spanclass="rvts21">.</span></p>
<pclass="rvps10"><spanclass="rvts21">Changes current selection to the given set of frames. Frame number in your table don't have to be sorted.</span></p>
<pclass="rvps10"><spanclass="rvts21">Call </span><spanclass="rvts20">taseditor.setselection(</span><spanclass="rvts71">nil</span><spanclass="rvts20">)</span><spanclass="rvts21"> to clear selection.</span></p>
<pclass="rvps10"><spanclass="rvts21">If TAS Editor is not engaged, nothing will be done.</span></p>
<pclass="rvps10"><aname="getinput"></a>
<spanclass="rvts21"><br/></span></p>
<pclass="rvps9"><spanclass="rvts68">int taseditor.getinput(int frame, int joypad)</span></p>
<pclass="rvps10"><spanclass="rvts21">Returns a number representing input of given joypad stored in current movie at given frame.</span></p>
<pclass="rvps10"><spanclass="rvts21">If given frame is negative, returns -1.</span></p>
<pclass="rvps10"><spanclass="rvts21">If given frame is outside current input range, returns 0, which can be interpreted as a blank frame (no buttons pressed at this frame yet).</span></p>
<pclass="rvps10"><spanclass="rvts21">Joypad value must be one of the following:</span></p>
<pclass="rvps10"><spanclass="rvts21">0 –</span><spanclass="rvts21">to get hardware commands (bit 0 = reset, bit 1 = poweron, bit 2 = FDS insert disk, bit 3 = FDS switch side)</span></p>
<pclass="rvps10"><spanclass="rvts21">2 –</span><spanclass="rvts21">to get 2P buttons</span></p>
<pclass="rvps10"><spanclass="rvts21">3 –</span><spanclass="rvts21">to get 3P buttons</span></p>
<pclass="rvps10"><spanclass="rvts21">4 –</span><spanclass="rvts21">to get 4P buttons</span></p>
<pclass="rvps10"><spanclass="rvts21">You should handle returned number (if it's not equal to -1) as a byte, each bit corresponds to one button (e.g. if bit 1 is set that means A button is pressed). Use Bitwise Operations to retrieve the state of specific buttons.</span></p>
<pclass="rvps10"><spanclass="rvts21">If given joypad is outside [0-4] range, returns -1.</span></p>
<pclass="rvps10"><spanclass="rvts21">If TAS Editor is not engaged, returns -1.</span></p>
<pclass="rvps10"><aname="submitinputchange"></a>
<spanclass="rvts21"><br/></span></p>
<pclass="rvps9"><spanclass="rvts68">taseditor.submitinputchange(int frame, int joypad, int input)</span></p>
<pclass="rvps10"><spanclass="rvts21">Sends request to TAS Editor asking to change input of given joypad at given frame.</span></p>
<pclass="rvps10"><spanclass="rvts21">Actual movie input won't be changed until the moment you call </span><spanclass="rvts20">taseditor.applyinputchanges()</span><spanclass="rvts21">.</span></p>
<pclass="rvps10"><spanclass="rvts21">Using several consecutive requests and then calling </span><spanclass="rvts20">applyinputchanges()</span><spanclass="rvts21"> at the end, you can change several frames of current movie in one moment.</span></p>
<pclass="rvps10"><spanclass="rvts21">When applying the pile of requests, TAS Editor will execute them in consecutive order.</span></p>
<pclass="rvps10"><spanclass="rvts21">If given frame is negative, TAS Editor will ignore such request.</span></p>
<pclass="rvps10"><spanclass="rvts21">If given frame is outside current input range, TAS Editor will expand movie during </span><spanclass="rvts20">applyinputchanges()</span><spanclass="rvts21"> to fit the frame.</span></p>
<pclass="rvps10"><spanclass="rvts21">If given joypad is outside [0-4] range, TAS Editor will ignore such request.</span></p>
<pclass="rvps10"><spanclass="rvts21">Given input will be treated by TAS Editor as a sequence of bits representing state of each button of given joypad </span><spanclass="rvts21">(</span><spanclass="rvts21">bit</span><spanclass="rvts21"> 0 = A, </span><spanclass="rvts21">bit</span><spanclass="rvts21"> 1 = B, </span><spanclass="rvts21">bit</span><spanclass="rvts21"> 2 = Select, </span><spanclass="rvts21">bit</span><spanclass="rvts21"> 3 = Start, </span><spanclass="rvts21">bit</span><spanclass="rvts21"> 4 = Up, </span><spanclass="rvts21">bit</span><spanclass="rvts21"> 5 = Down, </span><spanclass="rvts21">bit</span><spanclass="rvts21"> 6 = Left, </span><spanclass="rvts21">bit</span><spanclass="rvts21"> 7 = Right)</span><spanclass="rvts21">.</span></p>
<pclass="rvps10"><spanclass="rvts21">If TAS Editor is not engaged, nothing will be done.</span></p>
<pclass="rvps10"><aname="submitinsertframes"></a>
<spanclass="rvts21"><br/></span></p>
<pclass="rvps9"><spanclass="rvts68">taseditor.submitinsertframes(int frame, int number)</span></p>
<pclass="rvps10"><spanclass="rvts21">Sends request to TAS Editor asking to insert given number of blank frames before given frame.</span></p>
<pclass="rvps10"><spanclass="rvts21">Actual movie won't be changed until the moment you call </span><spanclass="rvts20">taseditor.applyinputchanges()</span><spanclass="rvts21">.</span></p>
<pclass="rvps10"><spanclass="rvts21">Insertion can move down some old input and Markers (if "</span><aclass="rvts27"href="ProgramCustomization.html#BindMarkerstoInput">Bind Markers to Input</a><spanclass="rvts21">" option is checked by user).</span></p>
<pclass="rvps10"><spanclass="rvts21">If given number is less or equal to zero, TAS Editor will ignore such request.</span></p>
<pclass="rvps10"><spanclass="rvts21">If given frame is negative, TAS Editor will ignore such request.</span></p>
<pclass="rvps10"><spanclass="rvts21">If given frame is outside current input range, TAS Editor will expand movie during </span><spanclass="rvts20">applyinputchanges()</span><spanclass="rvts21"> to fit the frame.</span></p>
<pclass="rvps10"><spanclass="rvts21">If TAS Editor is not engaged, nothing will be done.</span></p>
<pclass="rvps10"><aname="submitdeleteframes"></a>
<spanclass="rvts21"><br/></span></p>
<pclass="rvps9"><spanclass="rvts68">taseditor.submitdeleteframes(int frame, int number)</span></p>
<pclass="rvps10"><spanclass="rvts21">Sends request to TAS Editor asking to delete given number of frames starting from given frame.</span></p>
<pclass="rvps10"><spanclass="rvts21">Actual movie won't be changed until the moment you call </span><spanclass="rvts20">taseditor.applyinputchanges()</span><spanclass="rvts21">.</span></p>
<pclass="rvps10"><spanclass="rvts21">Deletion can move up some old input and Markers (if "</span><aclass="rvts27"href="ProgramCustomization.html#BindMarkerstoInput">Bind Markers to Input</a><spanclass="rvts21">" option is checked by user).</span></p>
<pclass="rvps10"><spanclass="rvts21">If given number is less or equal to zero, TAS Editor will ignore such request.</span></p>
<pclass="rvps10"><spanclass="rvts21">If given frame is negative, TAS Editor will ignore such request.</span></p>
<pclass="rvps10"><spanclass="rvts21">If given frame is outside current input range, TAS Editor will expand movie during </span><spanclass="rvts20">applyinputchanges()</span><spanclass="rvts21"> to fit the frame.</span></p>
<pclass="rvps10"><spanclass="rvts21">If TAS Editor is not engaged, nothing will be done.</span></p>
<pclass="rvps10"><spanclass="rvts21">Instantly applies the list of previously requested changes to current movie. If these requests actually modified movie data, new item will appear in History Log (so user can undo these changes), and Greenzone may become truncated, Playback cursor may lose its position, auto-seeking may be triggered.</span></p>
<pclass="rvps10"><spanclass="rvts21">Returns number of frame where first actual changes occurred.</span></p>
<pclass="rvps10"><spanclass="rvts21">If no actual changes were found (for example, you asked TAS Editor to set buttons that were already pressed), returns -1.</span></p>
<pclass="rvps10"><spanclass="rvts21">If pending list of changes is empty, returns -1.</span></p>
<pclass="rvps10"><spanclass="rvts21">You can provide a name that will be assigned to this change. This name will be shown in History Log. If you don't provide a name, TAS Editor will use default name ("Change").</span></p>
<pclass="rvps10"><spanclass="rvts21">After applying all requests TAS Editor clears the list of requests.</span></p>
<pclass="rvps10"><spanclass="rvts21">If TAS Editor is not engaged, nothing will be done.</span></p>
<pclass="rvps10"><spanclass="rvts21">Clears the list of previously requested changes, making TAS Editor forget about them before you call </span><spanclass="rvts20">applyinputchanges()</span><spanclass="rvts21">. Use this function to discard previously submitted input changes.</span></p>
<pclass="rvps10"><spanclass="rvts21">It's also recommended to call this function before making several requests in a row, so that you'll be sure that only your new changes will apply.</span></p>
<pclass="rvps10"><spanclass="rvts21">If TAS Editor is not engaged, nothing will be done.</span></p>
<pclass="rvps8"><spanclass="rvts17">Created with the Personal Edition of HelpNDoc: </span><aclass="rvts18"href="http://www.helpndoc.com">Full-featured Documentation generator</a></p>