ConstA button. onClick runs in the mod when the player presses it. tip is a tooltip, shown on
a disabled button too, to say why it cannot be pressed.
OptionalonClick: () => voidPuts text on the Windows clipboard, for the player to paste anywhere. Works in
Node mods and in overlay apps; use it instead of navigator.clipboard, which an
overlay window cannot always reach. It only writes: no package can read the
clipboard.
A picture from a file or from bytes, for a mod that makes or fetches pictures: a
render, a preview, a before and after. src is a PNG, JPEG, WebP or GIF file (a
relative path in the package's folder, or a full path in pkg.dataDir), a
data:image/ URL, or the file's bytes (a Buffer or Uint8Array). Give a width
in pixels; the height follows the picture. set({ src }) shows another picture, or
the same file again after the mod wrote over it. A picture that cannot be shown says
why in the window and in the Mod log. Needs REDnode 0.55.0 or later.
import path from "node:path";
import { pkg, ui } from "rednode";
const file = path.join(pkg.dataDir, "before.png"); // written by the mod
const before = ui.image(file, { width: 220, alt: "The hat before" });
const after = ui.image("waiting.png", { width: 220, onClick: () => console.log("larger") });
ui.window({ title: "Reshape", width: 480, height: 320, children: [ui.row(before, after)] });
after.set({ src: path.join(pkg.dataDir, "after.png") });
A text field. onSubmit runs on Enter; onChange when the field loses focus.
A list of lines that scrolls on its own, for a log or a live feed. It keeps the newest
lines only (keep, 500 by default), follows the newest line unless the player has
scrolled up, and without a height fills the window's free height. It keeps at least
160 px: when the other nodes leave less, the window scrolls.
Hears the app's key: the key the player gave this app in its title bar (Key binding)
or the Mod Manager. A press shows only this app's windows with the cursor (shown
true), and the next press hides them and gives the game its input back (shown
false). Pressing F10 or Esc, or clicking empty screen, ends that and shows the app
again (shown true if the key had hidden it).
An app whose page fills the screen ("fill": "screen", such as an editor's viewport)
is not hidden: its page stays, with the cursor, so its own view keeps the mouse, and
the key hides only the page's rn-windows, its panels (the UI kit does it). panels
is then true. A page drawing panels of its own, not in rn-windows, hides them here.
The key never changes the app's own state: an editor stays in its edit mode while hidden. Use this to pause what only makes sense on screen, such as a drag in progress. Works in Node mods and in overlay apps. Returns a function that stops listening.
Calls the handler when this package's solo mode starts or ends, also when the player ends it from the launcher. Returns a function that stops listening.
A progress bar from 0 to max (100 by default).
A dropdown: a box showing the chosen option, with the list opening below it (or above it near
the bottom of the window). The player picks with the mouse, or with the arrows and Enter.
onChange gets the value the player picks. Change the options or the choice later with
set({ options, value }). Needs REDnode 0.68.0 or later.
A slider. onChange gets the value when the player lets go, or while they drag with
live: true.
OptionalonChange: (value: number) => voidSolo mode: while on, REDnode hides every other package's windows and HUD widgets, so this package has the screen to itself (an editing viewport, a full-screen tool). REDnode's own tool windows stay: the launcher tab, which shows the solo and an End solo button, the Mod log, the Mod Manager and the Test timer. Solo ends when the package turns it off, stops or crashes, or the player ends it; ui.onSolo hears that.
The package must list "solo" in its rednode-app.json permissions and the
player must allow it in the Mod Manager; until then this rejects and says so.
Works in Node mods and in overlay apps.
An on and off switch. onChange gets the new state.
OptionalonChange: (checked: boolean) => voidOpens a window in the game. It looks like any overlay app window: the player can move it in interactive mode (F10), and its position is saved.
import { game, ui } from "rednode";
const where = ui.text("Waiting for the game");
ui.window({
title: "Where am I",
children: [
where,
ui.button("Update", async () => {
const p = await game.player.position();
where.set({ text: `${p.x.toFixed(1)}, ${p.y.toFixed(1)}, ${p.z.toFixed(1)}` });
}),
],
});
Builds overlay windows from a Node mod.