Skip to content

Raisin API Documentation

hugeblank edited this page Jan 2, 2021 · 10 revisions

Create A Manager

To access what's fun about Raisin the manager function needs to be called:

manager: Creates a new manager

  • Parameters
  • Returns
    • manager: Manager object

Manager Functions

All of the following documentation is for what is returned by the manager function.

See the "Details on the Manager" section below for more information/explanation on the objects/functions at play.

thread: Creates a new thread

  • Parameters
    • function: Function to be executed as a coroutine
    • [number]: Priority of thread | Default: 0
    • [table]: Event buffer whitelist | Default: empty table
  • Returns
    • thread: Raisin thread object with exposed common functions

group: Creates a new group

  • Parameters
    • function: onDeath function (See below)
    • [number]: Priority of group | Default: 0
    • [table]: Event buffer whitelist | Default: empty table
  • Returns
    • group: Raisin group object with exposed common functions

run: Executes the manager

  • Parameters
    • function: onDeath function (See below)
  • Returns
    • none

Details on the Manager

The thread object as provided in the thread function features the common state and priority functions.

The group object as provided in the group function is just a wrapped sub-manager within a thread, meaning that there is no difference in API function names between a group and the main manager, and feature the same common state and priority functions as thread objects (hence why they're common).

The event buffer whitelist is a list of events that the manager should exlusively pass onto the thread event buffer while it's disabled. This is especially useful when combined with ComputerCrafts event system. For example, a thread or group that is paused may have been both waiting on a websocket message, as well as updating the screen. The thread you want to pause does both, but you still want it to receive socket events.

Both the run and group calls request for a onDeath function. The onDeath function is a simple function that gets called whenever a thread dies during execution.

The onDeath Function

onDeath: Determine whether to stop execution based on the incoming dead thread

  • Parameters
    • [thread]: Raisin thread object that died
    • [table]: Table of all remaining living threads
    • [table]: Table of all remaining living threads that were defined before the run call
  • Returns
    • boolean: Whether or not to stop execution

onDeath Constructors

In the main manager there are several onDeath function constructors to fit several use cases, for ease of use. These functions return the onDeath function and are not the function themselves. They can be found by accessing manager.onDeath.<name>

Note that the waitForN set of functions listed here if passed 1 will wait for any thread to die of the matching criteria (before/after run-time). Use this if you're looking for a waitForAny style of constructor.

waitForAll: Wait for all threads to die

  • Parameters
    • none
  • Returns
    • function: onDeath function

waitForN: Wait for N threads to die

  • Parameters
    • number: Number of threads to wait for before dying
  • Returns
    • function: onDeath function

waitForAllInit: Wait for all threads to die that were created before run-time

  • Parameters
    • none
  • Returns
    • function: onDeath function

waitForNInit: Wait for N threads to die that were created before run-time

  • Parameters
    • number: Number of threads to wait for before dying
  • Returns
    • function: onDeath function

waitForAllRuntime: Wait for all threads to die that were created after run-time

  • Parameters
    • none
  • Returns
    • function: onDeath function

waitForNRuntime: Wait for N threads to die that were created after run-time

  • Parameters
    • number: Number of threads to wait for before dying
  • Returns
    • function: onDeath function