Interface ILuaAPI


public interface ILuaAPI
Represents a Lua object which is stored as a global variable on computer startup. This must either provide LuaFunction annotated functions or implement IDynamicLuaObject.

Before implementing this interface, consider alternative methods of providing methods. It is generally preferred to use peripherals to provide functionality to users.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default String
    Get the module name this API should be available as.
    Get the globals this API will be assigned to.
    default void
    Called when the computer is turned off or unloaded.
    default void
    Called when the computer is turned on.
    default void
    Called every time the computer is ticked.
  • Method Details

    • getNames

      String[] getNames()
      Get the globals this API will be assigned to.

      This will override any other global, so you should be careful to pick a unique name. Alternatively, you may return the empty array here, and instead override getModuleName().

      Returns:
      A list of globals this API will be assigned to.
    • getModuleName

      @Nullable default String getModuleName()
      Get the module name this API should be available as.

      Rather than (or as well as) making this API available as a global, APIs can be exposed as requireable modules. This is generally more idiomatic, as it avoids polluting the global environment.

      Modules defined here take precedence over user-defined modules, and so like with getNames(), you should be careful to pick a unique name. It is recommended that module names should be camel case, and live under a namespace associated with your mod. For instance, "mod_id.a_custom_api".

      Returns:
      The module name of this API, or null if this API should not be loadable as a module.
    • startup

      default void startup()
      Called when the computer is turned on.

      One should only interact with the file system.

    • update

      default void update()
      Called every time the computer is ticked. This can be used to process various.
    • shutdown

      default void shutdown()
      Called when the computer is turned off or unloaded.

      This should reset the state of the object, disposing any remaining file handles, or other resources.