@lumiastream/lumia-types 3.9.0 → 3.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -69,4 +69,67 @@ These are the built-in `type` values for each system base.
|
|
|
69
69
|
|
|
70
70
|
> Tip: most of the `lumia` and `overlay` actions already have dedicated helper functions (`tts`, `chatbot`, `overlaySetTextContent`, etc.) in `helper-functions.md`. Reach for `actions()` mainly when you need an integration action that does not have a helper yet.
|
|
71
71
|
|
|
72
|
+
### Common `lumia` action examples
|
|
73
|
+
|
|
74
|
+
Most `lumia` actions have a dedicated helper already (`chatbot`, `tts`, `playAudio`, `setVariable`, etc.) — prefer those. Reach for `actions()` for the engagement / system features that have no helper. The `value` fields are not uniform across types, so if you need a type not shown here, set that action up once in the normal action editor to read off its fields. Verified examples:
|
|
75
|
+
|
|
76
|
+
```js
|
|
77
|
+
async function() {
|
|
78
|
+
// Song requests
|
|
79
|
+
await actions([{ base: "lumia", type: "addSongRequest", value: { value: "never gonna give you up" } }]); // a search term or url
|
|
80
|
+
await actions([{ base: "lumia", type: "skipSongRequest" }]);
|
|
81
|
+
|
|
82
|
+
// Raffle (ends_after is in seconds; raffleStop / raffleEnd take no value)
|
|
83
|
+
await actions([{ base: "lumia", type: "raffleStart", value: { title: "My Raffle", auto_end: true, ends_after: 120 } }]);
|
|
84
|
+
|
|
85
|
+
// Viewer queue
|
|
86
|
+
await actions([{ base: "lumia", type: "viewerQueueEntry", value: { value: "{{username}}" } }]);
|
|
87
|
+
|
|
88
|
+
// Stream mode and connections
|
|
89
|
+
await actions([{ base: "lumia", type: "setStreamMode", value: { on: true } }]);
|
|
90
|
+
await actions([{ base: "lumia", type: "setConnection", value: { value: "obs", on: true } }]); // on:true enables, false disables
|
|
91
|
+
|
|
92
|
+
// Counter (operator is one of + - * /)
|
|
93
|
+
await actions([{ base: "lumia", type: "updateCounter", value: { value: "deaths", message: "1", operator: "+" } }]);
|
|
94
|
+
done();
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### OBS (v5) actions
|
|
99
|
+
|
|
100
|
+
OBS has a dedicated helper, so you do **not** need `actions()` for it: pass any OBS websocket v5 request to `sendRawObsJson({ "request-type": "...", ...params })` (see `helper-functions.md`). The `request-type` and fields are exactly the same ones Lumia's OBS action editor uses. Common ones:
|
|
101
|
+
|
|
102
|
+
```js
|
|
103
|
+
async function() {
|
|
104
|
+
// Scenes
|
|
105
|
+
sendRawObsJson({ "request-type": "SetCurrentProgramScene", "sceneName": "My Scene" });
|
|
106
|
+
sendRawObsJson({ "request-type": "SetCurrentPreviewScene", "sceneName": "My Scene" });
|
|
107
|
+
|
|
108
|
+
// Source visibility (by name — Lumia resolves the scene item id for you)
|
|
109
|
+
sendRawObsJson({ "request-type": "SetSceneItemEnabled", "sceneName": "My Scene", "inputName": "My Source", "sceneItemEnabled": true });
|
|
110
|
+
sendRawObsJson({ "request-type": "SetSourceFilterEnabled", "sourceName": "My Source", "filterName": "My Filter", "filterEnabled": true });
|
|
111
|
+
|
|
112
|
+
// Audio
|
|
113
|
+
sendRawObsJson({ "request-type": "SetInputMute", "inputName": "Mic/Aux", "inputMuted": true });
|
|
114
|
+
sendRawObsJson({ "request-type": "ToggleInputMute", "inputName": "Mic/Aux" });
|
|
115
|
+
sendRawObsJson({ "request-type": "SetInputVolume", "inputName": "Mic/Aux", "inputVolumeMul": 1 });
|
|
116
|
+
|
|
117
|
+
// Source settings (url / text / file / image / media)
|
|
118
|
+
sendRawObsJson({ "request-type": "SetInputSettings", "inputName": "Browser", "inputSettings": { "url": "https://lumiastream.com" } });
|
|
119
|
+
|
|
120
|
+
// Media, transitions, screenshot
|
|
121
|
+
sendRawObsJson({ "request-type": "TriggerMediaInputAction", "inputName": "My Video", "mediaAction": "OBS_WEBSOCKET_MEDIA_INPUT_ACTION_RESTART" });
|
|
122
|
+
sendRawObsJson({ "request-type": "SetCurrentSceneTransition", "transitionName": "Fade" });
|
|
123
|
+
|
|
124
|
+
// Recording / streaming / replay buffer / virtual cam (no params)
|
|
125
|
+
sendRawObsJson({ "request-type": "StartRecord" });
|
|
126
|
+
sendRawObsJson({ "request-type": "ToggleStream" });
|
|
127
|
+
sendRawObsJson({ "request-type": "SaveReplayBuffer" });
|
|
128
|
+
sendRawObsJson({ "request-type": "StartVirtualCam" });
|
|
129
|
+
done();
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Other available request-types include `SetCurrentProfile`, `SetCurrentSceneCollection`, `CreateInput`, `RemoveInput`, `SetSceneItemTransform`, `SetSceneItemBlendMode`, `SetInputAudioMonitorType`, `TriggerHotkeyByName`, `SetStudioModeEnabled`, `SendStreamCaption`, and the `Start/Stop/Toggle` variants for recording, streaming, replay buffer and virtual cam — the same list as the OBS action editor.
|
|
134
|
+
|
|
72
135
|
This documentation can get extremely broad for every integration, so if you get stuck please visit our [**Discord**](https://discord.gg/R8rCaKb) to ask us any questions.
|
|
@@ -27,3 +27,31 @@ async function() {
|
|
|
27
27
|
**code blocks** like the one above 👆 have a copy button on the **top right corner** click it then paste in Lumia stream
|
|
28
28
|
|
|
29
29
|
:::
|
|
30
|
+
|
|
31
|
+
## Show an OBS source and play a sound
|
|
32
|
+
|
|
33
|
+
You can drive OBS and audio straight from the code with the built-in helpers — there is no need to make a separate command and call it by an id. This rolls a dice, shows the matching `Dice1`–`Dice6` source in your scene, plays a sound on a 6, then hides the source again.
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
async function() {
|
|
37
|
+
const roll = Math.ceil(Math.random() * 6);
|
|
38
|
+
const sceneName = "IN-GAME ACTION";
|
|
39
|
+
const sourceName = "Dice" + roll;
|
|
40
|
+
|
|
41
|
+
chatbot({ message: "{{username}} rolled a " + roll + "!" });
|
|
42
|
+
|
|
43
|
+
// Show the matching dice source. Lumia finds the source's id from its name for you
|
|
44
|
+
sendRawObsJson({ "request-type": "SetSceneItemEnabled", "sceneName": sceneName, "inputName": sourceName, "sceneItemEnabled": true });
|
|
45
|
+
|
|
46
|
+
// Play a celebration sound only on a 6
|
|
47
|
+
if (roll === 6) {
|
|
48
|
+
playAudio({ path: "C:\\sounds\\gold.mp3", volume: 100 });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Leave it on screen for 6 seconds, then hide it again
|
|
52
|
+
await delay(6000);
|
|
53
|
+
sendRawObsJson({ "request-type": "SetSceneItemEnabled", "sceneName": sceneName, "inputName": sourceName, "sceneItemEnabled": false });
|
|
54
|
+
|
|
55
|
+
done();
|
|
56
|
+
}
|
|
57
|
+
```
|
|
@@ -41,6 +41,16 @@ You generate **Lumia Stream Custom Code**: JavaScript snippets that a streamer p
|
|
|
41
41
|
8. For `callAlert`, the `name` must be a valid alert key from the list in `helper-functions.md` (e.g. `twitch-subscriber`, `kick-follower`, `kofi-donation`). Do not guess keys that aren't on that list.
|
|
42
42
|
9. If a capability is not documented, say so clearly and offer a documented alternative rather than fabricating an API.
|
|
43
43
|
|
|
44
|
+
## Use built-in helpers directly — never command IDs
|
|
45
|
+
|
|
46
|
+
Run actions straight from the code with the documented helpers. Do **not** tell the streamer to first build a separate Lumia Command/Alert and then call it by an ID, and never output placeholder IDs like `REPLACE_WITH_..._COMMAND_ID`. There is **no** `executeCommand` global. `callCommand`, `callChatbotCommand` and `callAlert` take a **name** and only trigger something the streamer has *already* created — they are not a way to change scenes or play sounds.
|
|
47
|
+
|
|
48
|
+
- **OBS scene change:** `sendRawObsJson({ "request-type": "SetCurrentProgramScene", "sceneName": "My Scene" })`
|
|
49
|
+
- **OBS show/hide a source (by name):** `sendRawObsJson({ "request-type": "SetSceneItemEnabled", "sceneName": "My Scene", "inputName": "My Source", "sceneItemEnabled": true })` — set `sceneItemEnabled: false` to hide. Lumia looks up the source's id from the name for you, so you never need a numeric `sceneItemId`.
|
|
50
|
+
- **Any other OBS request:** the same pattern through `sendRawObsJson` (for example `SetInputMute`, `TriggerMediaInputAction`, `SetCurrentSceneTransition`).
|
|
51
|
+
- **Play audio:** `playAudio({ path: "C:\\sounds\\gold.mp3", volume: 100 })` — a URL works too and `playSound` is an alias. Use `await playAudio({ ..., waitForAudioToStop: true })` to wait for it to finish.
|
|
52
|
+
- For an integration action that has no dedicated helper, use `actions([...])` (see `custom-actions.md`).
|
|
53
|
+
|
|
44
54
|
## Quality checklist before returning code
|
|
45
55
|
|
|
46
56
|
- Wrapped in `async function() { ... }` and calls `done()` once.
|
|
@@ -456,16 +456,21 @@ async function() {
|
|
|
456
456
|
|
|
457
457
|
### Send Raw OBS JSON
|
|
458
458
|
|
|
459
|
-
`sendRawObsJson(value: { request-type: string; sceneName?: string; sceneItemId?: number; [key: string]: any })`: You can send raw JSON to OBS that will automatically handle the context id. Just send
|
|
459
|
+
`sendRawObsJson(value: { request-type: string; sceneName?: string; inputName?: string; sceneItemId?: number; [key: string]: any })`: You can send raw JSON to OBS that will automatically handle the context id. Just send the request type and your other parameters and Lumia Stream will take care of the rest. This is the simplest way to drive OBS from custom code — you do not need to build a separate OBS command or alert and call it by id.
|
|
460
460
|
|
|
461
461
|
```js
|
|
462
462
|
async function() {
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
463
|
+
// Change the active scene
|
|
464
|
+
sendRawObsJson({ "request-type": "SetCurrentProgramScene", "sceneName": "My Scene" });
|
|
465
|
+
|
|
466
|
+
// Show a source by its name. Lumia resolves the scene item id from the name for you, so no numeric id is needed
|
|
467
|
+
sendRawObsJson({ "request-type": "SetSceneItemEnabled", "sceneName": "My Scene", "inputName": "My Source", "sceneItemEnabled": true });
|
|
468
|
+
|
|
469
|
+
// Hide that same source again by passing false
|
|
470
|
+
sendRawObsJson({ "request-type": "SetSceneItemEnabled", "sceneName": "My Scene", "inputName": "My Source", "sceneItemEnabled": false });
|
|
471
|
+
|
|
472
|
+
// You can still target a source by its numeric sceneItemId if you already know it
|
|
473
|
+
sendRawObsJson({ "request-type": "SetSceneItemEnabled", "sceneName": "Scene 1", "sceneItemId": 1, "sceneItemEnabled": true });
|
|
469
474
|
}
|
|
470
475
|
```
|
|
471
476
|
|