Variables
The Variables namespace provides in-memory key-value storage scoped to the current mod. Data is lost when the game is closed (session-only). Each mod has its own isolated namespace.
For persistent storage, use Storage. For sharing data between mods at runtime, use SharedVariables.
No permission required.
Import
typescript
import { Variables } from "@hotbunny/hackhub-content-sdk";Methods
Variables.get<T>(key)
Get a value by key. Returns undefined if not found.
Returns: T | undefined
typescript
const found = Variables.get<boolean>("targetFound");Variables.set(key, value)
Set a value by key.
typescript
Variables.set("targetFound", true);
Variables.set("scanCount", 0);Variables.remove(key)
Remove a key.
typescript
Variables.remove("targetFound");Variables.clear()
Clear all variables for this mod.
Variables.getAll()
Get all stored key-value pairs.
Returns: Record<string, any>
When to Use Variables vs Storage
| Variables | Storage | |
|---|---|---|
| Persistence | Session only | Across game sessions |
| Use case | Temporary state, counters, flags | Save data, settings, progress |
| Performance | Faster (in-memory) | Slightly slower (disk I/O) |
| Scoping | Per-mod | Per-mod |
typescript
// Use Variables for temporary quest state
Variables.set("nmapAttempts", 0);
// Use Storage for permanent progress
Storage.set("questsCompleted", ["quest1", "quest2"]);