Skip to content

TAS Movie API

Eddio0141 edited this page Jun 20, 2023 · 21 revisions

API for the extra functionality availiable in the TAS movie scripts

MOVIE_CONFIG

  • All movie config options are in the MOVIE_CONFIG table
  • Accessed like so MOVIE_CONFIG.fps
  • All options MUST be defined in the first frame of the movie (so before the first movie.frame_advance call)
  • Make sure if the is_global_scope option is enabled, the options are defined in the global scope and not in the main script coroutine

fps - DEFAULT = 100

The FPS of the movie, this is used to calculate the frametime

frametime - DEFAULT = 0.01

The frametime of the movie, this is applied to the first frame of the movie

start_time - DEFAULT = year 0001, jan 1st

  • Using a string to set this will use the invariant DateTime format to start the movie in that system time
  • Using a value will set the time by ticks

is_global_scope - DEFAULT = false

  • Enabling this will unwrap the main script coroutine into the global scope, basically letting you use the lua script in its raw form
    • Make sure to return a coroutine function from the main script, which will be used as the main script coroutine

seed - DEFAULT = 0

  • The seed to use for the random number generator on soft restart

update_type - DEFAULT = Update

  • The type of update to use on frame advance, it is case insensitive
    • Types
      • Update - Updates before frame update either MonoBehaviour.Update or input system update
      • FixedUpdate - Updates before fixed update either MonoBehaviour.FixedUpdate or input update
      • Both - Both of the above

concurrent

Contains methods used to register / unregister a concurrent method

register(method, post_update, arg0, arg1, arg2, ...) -> register_uid

Registers a method to concurrently run along with the main script coroutine

This will also run the method for the current frame if the post_update flag is set to false

  • method
    • The method to be ran
  • post_update - DEFAULT = false
    • Boolean on running before the execution of the main script coroutine, or after
    • By default, its false so it will run before the main script coroutine
  • arg0 - OPTIONAL
    • Default argument to pass to the method
    • Overload so you don't have to put anything in if no arguments are present
    • If you don't match the number of arguments as same as the function signature, it will throw an exception on most occasions
  • Return
    • A unique identifier object to distinguish a registered concurrent method

register_once(method, post_update, arg0, arg1, arg2, ...) -> register_uid

Registers a method to concurrently run along with the main script coroutine, but will only run once

Rest is the same as register()

unregister(register_uid)

Unregisters a concurrently running method\

NOTE: If the pre_update flag is set for a method, it will run for that frame if you try unregistering from the main coroutine

  • register_uid
    • The unique identifier object that was returned from register

key

Used for manipulating the keyboard

hold(key)

Holds a key down

  • key
    • The key to hold down
    • A string of the key name which is the enum from here

release(key)

Releases a key

  • key
    • The key to release
    • A string of the key name which is the enum from here

clear()

Clears all keys that are currently held down

mouse

Used for manipulating the mouse

left(hold)

Holds the left mouse button

  • hold - DEFAULT = true
    • Boolean on whether to click or not
    • If false, it will release the button

right(hold)

Holds the right mouse button

  • hold - DEFAULT = true
    • Boolean on whether to click or not
    • If false, it will release the button

middle(hold)

Holds the middle mouse button

  • hold - DEFAULT = true
    • Boolean on whether to click or not
    • If false, it will release the button

move(x, y)

Moves the mouse to a position

  • x
    • The x position to move to
  • y
    • The y position to move to

move_rel(x, y)

Moves the mouse to a position relative to the current position

  • x
    • The x offset to move to
  • y
    • The y offset to move to

set_scroll(x, y)

Sets the scroll speed

  • x
    • The x scroll speed
  • y
    • The y scroll speed

controller

⚠️ NOTE: Because I want to support multiple controllers, the API for this section is not final, and will be changed in the future along with better legacy input system support for unity

Used for manipulating the controller

hold(button)

⚠️ NOTE: This will be eventually replaced after better legacy input system support for unity

Holds a controller button down

  • button
    • The button name in string to be held down

release(button)

⚠️ NOTE: This will be eventually replaced after better legacy input system support for unity

Releases a controller button

  • button
    • The button name in string to be released

clear_buttons()

Clears all buttons that are currently held down

axis(axis, value)

⚠️ NOTE: This will be eventually replaced after better legacy input system support for unity

Sets the value of an axis

  • axis
    • The axis name in string to set the value of
  • value
    • The value to set the axis to

env

Game environment, used for changing the game environment

fps

The current FPS of the game, you can read / write to this

NOTE: Setting this will apply the change on the next frame (so after the frame_advance call on the main coroutine)

frametime

The current frametime of the game, you can read / write to this

NOTE: Setting this will apply the change on the next frame (so after the frame_advance call on the main coroutine)

update_type(type)

Sets the update type of the game

  • type
    • The update type to set the game to
    • Types
      • Update - Updates before MonoBehaviour.Update
      • FixedUpdate - Updates before MonoBehaviour.FixedUpdate
      • Both - Both of the above

movie

Used to control movie playback

playback_speed(speed_multiplier)

Sets the current playback speed of the movie

  • speed_multiplier
    • The speed multiplier to set the playback speed to
      • Setting this to 0 will run the game as fast as possible\
      • Setting this to 1 will run the game at 1x speed\
      • Setting this to 0.5 will run the game at 0.5x speed, etc

frame_advance(count)

Alias for coroutine.yield()

  • count - OPTIONAL
    • The number of times to yield (or advance the frame in the movie)
    • If passing nothing or nil, it will yield once
    • It WILL fail with an error if you pass any type other than a number or nil

start_capture(args)

Starts capturing the movie
You don't need to call stop_capture() at the end of the script, it will automatically stop the capture when the script ends

  • args - OPTIONAL
    • A table of arguments to pass to the capture, using lua's named arguments
    • If not passed, it will use the default arguments
    • If passed, it will use the arguments passed in
    • Table args
      • fps - DEFAULT = 60
        • The FPS to capture the movie at
      • width - DEFAULT = 1920
        • The width of the rendered movie
      • height - DEFAULT = 1080
        • The height of the rendered movie
      • path - DEFAULT = output.mp4
        • The path to save the movie to

stop_capture()

Stops capturing the movie

unity - ONLY IN LATEST MAIN BRANCH

Provides read only access to unity side

find_objects_by_type(type_name)

Finds unity objects by type

  • type_name - string
    • The C# type name of the object to find. It would be ideal to include the namespace
    • Example: UnityEngine.GameObject

gui - ONLY IN LATEST MAIN BRANCH

GUI controls for UniTAS

show_overlays

Shows or hides the UniTAS overlays

bool, read/write