// Name: Brookhaven RP Toolkit // Description: Multi-tab GUI for car spawn commands, roleplay presets, teleports, house customization, and a simple fly toggle (copy/paste helper). // Author: suhubig-bit // GitHub: suhubig-bit import "@johnlindquist/kit" type Teleport = { label: string; note?: string } type House = { color: string; style: string; theme: string } type Roleplay = { name: string; job: string; bio: string } const kv = await store("brookhaven-toolkit", {}) const defaultCars = [ "SUV", "Police Car", "Motorcycle", "Sports Car", "Bus", "Van", "Truck", "Jeep", ] async function getOrSet<T>(key: string, def: T): Promise<T> { let v = await kv.get<T>(key as any) if (v === undefined || v === null) { await kv.set(key, def as any) v = def } return v as T } // Initialize defaults await getOrSet<string[]>("cars", defaultCars) await getOrSet<Teleport[]>("teleports", []) await getOrSet<House>("house", { color: "#ffffff", style: "Modern", theme: "Default" }) await getOrSet<Roleplay>("roleplay", { name: "", job: "", bio: "" }) await getOrSet<boolean>("fly", false) async function copyOrPasteText(text: string) { const action = await arg( { placeholder: "Copy or paste?", enter: "Copy", }, [ { name: "Copy to Clipboard", value: "copy" }, { name: "Paste into Foreground App", value: "paste" }, ] ) if (action === "paste") { await setSelectedText(text, true) await notify(`Pasted: ${text}`) } else { await copy(text) await notify(`Copied: ${text}`) } } async function carsTab(input = ""): Promise<void> { let cars = await getOrSet<string[]>("cars", defaultCars) const selection = await micro<string>( { input, placeholder: "Car Spawner: select a car to copy '/car <name>' or type to add", strict: false, enter: "Copy /car command", onNoChoices: async () => { setEnter("Add Car") }, onChoiceFocus: async () => { setEnter("Copy /car command") }, shortcuts: [ { name: "Remove Focused", key: `${cmd}+backspace`, bar: "right", visible: true, onPress: async (_input, { focused }) => { const name = focused?.name?.trim() if (!name) return cars = cars.filter(c => c !== name) await kv.set("cars", cars) await setHint(`Removed "${name}"`) submit(preventSubmit) }, }, ], }, cars ) if (typeof selection === "string") { const name = selection.trim() if (!name) return if (!cars.includes(name)) { cars.push(name) await kv.set("cars", cars) await notify(`Added car: ${name}`) await carsTab(name) return } else { const cmdText = `/car ${name}` await copyOrPasteText(cmdText) } } await carsTab() } async function roleplayTab(): Promise<void> { const current = await getOrSet<Roleplay>("roleplay", { name: "", job: "", bio: "" }) const [name, job, bio] = await fields([ { label: "Display Name", value: current.name || "" }, { label: "Job/Role", value: current.job || "" }, { label: "Bio", value: current.bio || "" }, ]) const updated: Roleplay = { name: name?.trim() || "", job: job?.trim() || "", bio: bio?.trim() || "" } await kv.set("roleplay", updated) const summary = `[RP] Name: ${updated.name || "N/A"} | Job: ${updated.job || "N/A"} | Bio: ${updated.bio || "N/A"}` await copyOrPasteText(summary) await roleplayTab() } async function teleportsTab(input = ""): Promise<void> { let teleports = await getOrSet<Teleport[]>("teleports", []) const choices = teleports.map(t => ({ name: t.label, description: t.note || "", value: t, })) const picked = await micro<Teleport | string>( { input, placeholder: "Teleport System: select a saved label to copy '/tp <label>' or type a new one", strict: false, enter: "Copy /tp command", onNoChoices: async () => { setEnter("Add Teleport") }, onChoiceFocus: async () => { setEnter("Copy /tp command") }, shortcuts: [ { name: "Delete Focused", key: `${cmd}+backspace`, bar: "right", onPress: async (_input, { focused }) => { const label = focused?.name?.trim() if (!label) return teleports = teleports.filter(t => t.label !== label) await kv.set("teleports", teleports) await setHint(`Deleted teleport "${label}"`) submit(preventSubmit) }, visible: true, }, ], }, choices.length ? choices : [{ name: "No teleports saved", info: true, miss: true }] ) if (typeof picked === "string") { const label = picked.trim() if (!label) return const [note] = await fields([{ label: "Note / Coords (optional)", value: "" }]) teleports.push({ label, note }) await kv.set("teleports", teleports) await notify(`Saved teleport: ${label}`) await teleportsTab(label) return } else if (picked && typeof picked === "object") { const cmdText = `/tp ${picked.label}` await copyOrPasteText(cmdText) } await teleportsTab() } async function houseTab(): Promise<void> { const current = await getOrSet<House>("house", { color: "#ffffff", style: "Modern", theme: "Default" }) const [color, style, theme] = await fields([ { label: "Primary Color (hex)", value: current.color || "#ffffff" }, { label: "Style", value: current.style || "Modern" }, { label: "Theme / Notes", value: current.theme || "" }, ]) const updated: House = { color: color?.trim() || "#ffffff", style: style?.trim() || "Modern", theme: theme?.trim() || "", } await kv.set("house", updated) const summary = `/house color ${updated.color} | style ${updated.style} | theme ${updated.theme || "Default"}` await copyOrPasteText(summary) await houseTab() } async function flyingTab(): Promise<void> { const isOn = await getOrSet<boolean>("fly", false) const action = await arg("Flying toggle", [ { name: `Toggle (currently ${isOn ? "ON" : "OFF"})`, value: "toggle" }, { name: "Fly ON", value: "on" }, { name: "Fly OFF", value: "off" }, ]) let next = isOn if (action === "toggle") next = !isOn if (action === "on") next = true if (action === "off") next = false await kv.set("fly", next) const cmdText = `/fly ${next ? "on" : "off"}` await copyOrPasteText(cmdText) } async function infoTab(): Promise<void> { await div( md(` # Brookhaven RP Toolkit - This GUI helps you quickly prepare text commands and roleplay presets. - Use "Copy" to keep commands on the clipboard or "Paste" to send them to the active app. - Note: This script does not modify or inject code into games. It only assists with text generation and management. `) ) } // Tabs onTab("Car Spawner", carsTab) onTab("Roleplay", roleplayTab) onTab("Teleports", teleportsTab) onTab("House", houseTab) onTab("Flying", flyingTab) onTab("Info", infoTab)