lucent/script module
Lifecycle, inputs, options, logging, and utilities for the current script.
const script = require("lucent/script");
Members
script.alert()
Opens a message dialog and waits until it is dismissed.
script.alert(message: string): Effect.Effect<void>
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
message |
string |
Returns: void
Errors: never
script.beep()
script.beep(times?: number): Effect.Effect<void, ScriptExecutionError>
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
times |
number |
1 |
Number of repetitions. |
Returns: void
Errors: ScriptExecutionError
script.confirm()
Opens a confirmation dialog. Canceling the dialog yields false.
script.confirm(message: string): Effect.Effect<boolean>
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
message |
string |
Returns: boolean
Errors: never
script.exit()
Exits the current script and prevents later queued scripts from running. Use this as an explicit escape hatch.
script.exit(options?: ScriptExitOptions): Effect.Effect<never, ScriptStopSignal>
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
options |
ScriptExitOptions |
{ closeClient: false, logout: false } |
Exit actions. |
Returns: never
Errors: ScriptStopSignal
script.inputs.get()
script.inputs.get(key: string): Effect.Effect<ScriptInputValue | undefined>
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
key |
string |
Returns: ScriptInputValue | undefined
Errors: never
script.inputs.getAll()
script.inputs.getAll(): Effect.Effect<ScriptInputValues>
Returns: ScriptInputValues
Errors: never
script.log()
script.log(...values: unknown[]): Effect.Effect<void>
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
...values |
unknown[] |
Returns: void
Errors: never
script.options.get()
Returns a snapshot of the current options.
script.options.get(): Effect.Effect<ScriptRuntimeOptions>
Returns: ScriptRuntimeOptions
Errors: never
script.options.reset()
Restores Lucent’s built-in defaults, not the options from before the script.
script.options.reset(): Effect.Effect<void>
Returns: void
Errors: never
script.options.update()
Updates the supplied options, leaving the rest unchanged.
script.options.update(patch: ScriptRuntimeOptionsPatch): Effect.Effect<void, ScriptExecutionError>
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
patch |
ScriptRuntimeOptionsPatch |
Returns: void
Errors: ScriptExecutionError
Example
yield* script.options.update({
restartAfterReconnect: true,
roomPolicy: { kind: "specific", roomNumber: 42 },
});
script.prompt()
Opens a text prompt with an empty input. Canceling the dialog yields null;
submitting without entering text yields an empty string, not the placeholder.
script.prompt(message: string, placeholder?: string): Effect.Effect<string | null>
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
message |
string |
|||
placeholder |
string |
"" |
Hint shown in the empty input. It is not a default value. |
Returns: string | null
Errors: never
Example
const name = yield* script.prompt("Character name", "Artix");
if (name === null) {
yield* script.stop("Prompt canceled.");
}
if (name === "") {
yield* script.stop("No name entered.");
}
yield* script.log(name);
script.signal
script.signal: AbortSignal
Returns: AbortSignal
script.sleep()
script.sleep(duration: Duration.Input): Effect.Effect<void, ScriptExecutionError>
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
duration |
Duration.Input |
Returns: void
Errors: ScriptExecutionError
script.stop()
Stops the current script. If it is part of a queue, the next script runs.
script.stop(reason?: string): Effect.Effect<never, ScriptStopSignal>
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
reason |
string |
"Script stopped." |
Stop message. |
Returns: never
Errors: ScriptStopSignal