Release the resource. Resolves once the player confirmed the release (or immediately for purely local resources). Never rejects.
A "Turn feature off" item removes the feature's own menu item at once,
before the plugin stops. dispose takes the command out of the menu and
the binding table and resolves once the player confirmed it; the id can
be added again later.
const extra = plugin.commands.add({ id: "extra", path: ["Tools", "Extra"], run() {} });
plugin.commands.add({
id: "extra-off",
path: ["Tools", "Turn extra off"],
run: () => extra.dispose(), // never rejects
});
Replace what the row shows.
Listen to the user activating the row (Enter, Shift+Enter or a click). The player starts a stopped plugin for it.
A unit converter shows its answer and, after Shift+Enter, leaves the
palette open for the next one. The listener gets the typed text and
keep; the player closes the palette on Enter by itself.
lead.onRun(async ({ query, keep, ticket }) => {
const gigabytes = Number.parseFloat(query); // "3.5 GB in MB"
await plugin.osd.show("{} MB", [gigabytes * 1024]);
if (keep) await plugin.osd.show("Type the next value");
await lead.done(ticket);
});
End a request's ticket: Commands.run refuses it from now on.
A macro plugin stops at the first command that fails and ends the
ticket, so nothing more runs for this request. done ends the ticket
at once; without it the ticket would end 120 s after its last run.
lead.onRun(async ({ ticket }) => {
try {
await plugin.commands.run("host/mute", { ticket });
} catch {
await plugin.osd.show("Macro stopped"); // ticket, limit, disabled…
} finally {
await lead.done(ticket);
}
});
The palette's lead row, from Palette.lead. Disposing it removes the row.
Remarks
Holds the row while the scope lives.
updatechanges what it shows (a status while a request runs, a note while it cannot run);onRunhears each activation;doneends the ticket of a finished request.Example: Show a status while a request runs
While the plugin works on a request the row shows "Working… (Enter to stop)"; Enter on it stops the work. The status row replaces the lead while nothing is typed; its run event has
status: true.Player
0.7.6
Since
1.7.9