Builtin Library
README.md
plugins Module
Public Luau surface over the __plugins Internal FFI namespace: what the
plugin host loaded, and the one way to call a plugin.
Purpose
A plugin installs no globals. It is reached by identity, like every other
piece of content: requiring the plugin gets you its surface module, and that
module calls through plugins.call here. The identity is written as a
literal, so the reference deriver records the plugin as a dependency, pins
it, and carries it into a pack.
Usage
-- Call a method the plugin's plugin.yaml exposes, and wait for the answer.
local agents = await(plugins.call("@builtin/plugins/dotbot.plugin", "agents"))
-- Wait for a plugin that is still loading.
while not plugins.isLoaded("motion") do task.wait(0.1) end
-- Listen to the events a plugin raises, and stop listening.
local id = plugins.on("motion", function(eventType, payload) print(eventType) end)
plugins.off("motion", id)
Functions
plugins.status(): what the host loaded, and each plugin asset that did not load with the reason.plugins.call(plugin, method, ...): call an exposed method; answers a promise. A call to a plugin asset whose load is still under way fails saying it is still loading, and one whose load was refused fails with the reasonplugins.status()lists for it.plugins.openUrl(plugin, url): ask the person to open one of the plugin's own pages, on a host itsnetwork.hostsdeclares.plugins.isLoaded(plugin): whether the plugin is loaded and answering. Never raises.plugins.awaitingPerson(plugin): whether a call to the plugin is waiting on a person to answer the engine's consent dialog.plugins.on(plugin, listener)/plugins.off(plugin, id): listen to the plugin's events.