@lumiastream/lumia-types 2.8.2 → 2.8.3
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.
- package/dist/custom-code/custom-actions.md +35 -0
- package/dist/custom-code/examples/create-counter.md +40 -0
- package/dist/custom-code/examples/global-store.md +36 -0
- package/dist/custom-code/examples/random-twitch-clip.md +38 -0
- package/dist/custom-code/examples/roll-dice.md +29 -0
- package/dist/custom-code/examples/send-different-chatbot-for-userlevel.md +41 -0
- package/dist/custom-code/examples/track-subscribers.md +30 -0
- package/dist/custom-code/gpt-instructions.md +29 -0
- package/dist/custom-code/helper-functions.md +561 -0
- package/dist/custom-code/important-notes.md +22 -0
- package/dist/custom-code/what-is-custom-javascript.md +40 -0
- package/dist/custom-overlays/custom-overlays-alerts.d.ts +0 -9
- package/dist/custom-overlays/gpt-instructions.md +2 -25
- package/dist/variables.types.js +4 -21
- package/package.json +3 -2
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 3
|
|
3
|
+
title: Custom actions
|
|
4
|
+
description: Custom Actions allow you to tap into how Lumia Stream calls actions from the inside
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
`Custom Actions` allow you to tap into how Lumia Stream calls actions from the inside.
|
|
8
|
+
`Custom Actions` are mainly meant for things that we haven't added as a `Helper function` yet. For instance, actions for Spotify, Twitch, Streamer.Bot etc are all actions that we do not have a have helper functions for. This is where an action will step in.
|
|
9
|
+
|
|
10
|
+
You can use actions by just passing in one object, or an array of objects.
|
|
11
|
+
If you pass in an array of actions then any action that can be awaited will be wait until the promise has been resolved.
|
|
12
|
+
|
|
13
|
+
This documentation for every action we use in Lumia can get extremely broad, so we will give examples for different actions, but if you get stuck please visit our [**Discord**](https://discord.gg/R8rCaKb) to ask us any questions.
|
|
14
|
+
|
|
15
|
+
Let's get started:
|
|
16
|
+
|
|
17
|
+
### Generic Action
|
|
18
|
+
|
|
19
|
+
`actions([ { base: "lumia", type: "tts", value: { message: "Hello" }, variables: {} } ]);`:
|
|
20
|
+
|
|
21
|
+
#### Before we begin, let's dissect this.
|
|
22
|
+
|
|
23
|
+
`base`: will be the base of actions that can be used with Custom Code. The different bases are:
|
|
24
|
+
`delay, lumia, overlay, api, websocket, commandRunner, inputEvent, obs, slobs, twitch, twitter, streamerbot, midi, osc, artnet, mqtt, serial, broadlink, spotify, vlc, voicemod`
|
|
25
|
+
|
|
26
|
+
`type`: Every base has different action types. For instance, the base `lumia` has: `chatbot, tts, setStreamMode, toggleStreamMode` and much more.
|
|
27
|
+
To find the list of types that each base has below. Check in the side bar to quickly get to the base you're interested in.
|
|
28
|
+
|
|
29
|
+
`value`: can sometimes be an object and sometimes a string, it all depends on the `base` and `type`
|
|
30
|
+
|
|
31
|
+
`variables`: allows you to send in different variables for each action. But do note that the variables that are already on the command/alert will also be spread on to this variables object. Variables are not required
|
|
32
|
+
|
|
33
|
+
There are more fields that are sometimes used in actions. We will try to list out as many common examples down below along with the schema for them
|
|
34
|
+
|
|
35
|
+
#### More documentation coming soon
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 1
|
|
3
|
+
title: Create counter
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
You can set up a manual counter so that you can trigger multiple things based on the counter value
|
|
7
|
+
|
|
8
|
+
e.g. the code below will trigger a command named **'money-12'** when the **counter = 12**
|
|
9
|
+
|
|
10
|
+
```js
|
|
11
|
+
async function() {
|
|
12
|
+
|
|
13
|
+
// You can get your variable's value that you just set here
|
|
14
|
+
let redeemCount = await getVariable('redeemCount');
|
|
15
|
+
|
|
16
|
+
if (!redeemCount) {
|
|
17
|
+
// If variable does not exist it will create it
|
|
18
|
+
redeemCount = await setVariable({ name: 'redeemCount', value: 10 });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
redeemCount++;
|
|
22
|
+
await setVariable({ name: 'redeemCount', value: redeemCount });
|
|
23
|
+
|
|
24
|
+
if (redeemCount === 12) {
|
|
25
|
+
// call the command named money-12
|
|
26
|
+
callCommand({ name: 'money-12' });
|
|
27
|
+
// show a popup message in the Lumia stream app with '{{username}} is the 12th redeemer' inside
|
|
28
|
+
showToast({ message: '{{username}} is the 12th redeemer' });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// always make sure this is the last line in the code otherwise your computer may get slower due to memory leaks
|
|
32
|
+
done();
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
:::tip
|
|
37
|
+
|
|
38
|
+
**code blocks** like the one above 👆 have a copy button on the **top right corner** click it then paste in Lumia stream
|
|
39
|
+
|
|
40
|
+
:::
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 6
|
|
3
|
+
title: Global Store (Persistent Storage)
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Storing data for Custom Code
|
|
7
|
+
|
|
8
|
+
We expose a global store that you can use with your custom code to store any data type that you need to and it will be persisted. This is useful to store things like arrays and objects without needing to store them in variables.
|
|
9
|
+
|
|
10
|
+
There are 4 different functions that you can use with the Store:
|
|
11
|
+
|
|
12
|
+
```md
|
|
13
|
+
- getStore()
|
|
14
|
+
- getStoreItem(name: string)
|
|
15
|
+
- setStore({ name: string; value: any })
|
|
16
|
+
- resetStore()
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
async function() {
|
|
21
|
+
let tempUsers = await getStoreItem('users');
|
|
22
|
+
if (!tempUsers) {
|
|
23
|
+
tempUsers = [];
|
|
24
|
+
}
|
|
25
|
+
tempUsers.push("{{username}}");
|
|
26
|
+
await setStore({ name: 'users', value: tempUsers });
|
|
27
|
+
showToast({ message: tempUsers.length, time: 10000 });
|
|
28
|
+
done();
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
:::tip
|
|
33
|
+
|
|
34
|
+
**code blocks** like the one above 👆 have a copy button on the **top right corner** click it then paste in Lumia stream
|
|
35
|
+
|
|
36
|
+
:::
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 2
|
|
3
|
+
title: Random Twitch Clip
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Randomly getting the latest Twitch Clip from a user
|
|
7
|
+
|
|
8
|
+
You can call requests from integrations that we support that have an access token. You can also pass in variable values when calling other commands/alerts to pass in extra data that you may need in that command.
|
|
9
|
+
|
|
10
|
+
```js
|
|
11
|
+
async function() {
|
|
12
|
+
try {
|
|
13
|
+
const twitchToken = await getToken('twitch');
|
|
14
|
+
const twitchClientId = await getClientId('twitch');
|
|
15
|
+
|
|
16
|
+
// userId is a variable that comes from chat commands. This will get the clips of the user who's chatting
|
|
17
|
+
const clipsRes = await fetch('https://api.twitch.tv/helix/clips?broadcaster_id={{userId}}', {
|
|
18
|
+
headers: {
|
|
19
|
+
Authorization: `Bearer ${twitchToken}`,
|
|
20
|
+
'Client-ID': twitchClientId
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const clips = (await clipsRes.json())?.data;
|
|
24
|
+
const randomClip = clips[Math.floor(Math.random() * clips.length)];
|
|
25
|
+
chatbot({ message: `${randomClip.title}: ${randomClip.url}` });
|
|
26
|
+
} catch (err) {
|
|
27
|
+
showToast({ message: 'error: ' + err.message });
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
done({ variables: { user_clip_title: randomClip.title, user_clip: randomClip.url } });
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
:::tip
|
|
35
|
+
|
|
36
|
+
**code blocks** like the one above 👆 have a copy button on the **top right corner** click it then paste in Lumia stream
|
|
37
|
+
|
|
38
|
+
:::
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 3
|
|
3
|
+
title: Roll dice
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Roll a dice with Text To Speech
|
|
7
|
+
|
|
8
|
+
You can use Javascript to randomly pick a number and if it lands on your chosen number the user will get a special Text To Speech shoutout
|
|
9
|
+
|
|
10
|
+
```js
|
|
11
|
+
async function() {
|
|
12
|
+
const diceRoll = Math.ceil(Math.random()*6);
|
|
13
|
+
|
|
14
|
+
if (diceRoll === 3) {
|
|
15
|
+
tts({ message: "Congratulations {{username}}! You rolled a 3", voice: "default", volume: 100 })
|
|
16
|
+
// you can switch between all the tts option that we support
|
|
17
|
+
// tts({ message: "Congratulations {{username}}! You rolled a 3", voice: "Brian", volume: 100 })
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// always make sure this is the last line in the code otherwise your computer may get slower due to memory leaks
|
|
21
|
+
done();
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
:::tip
|
|
26
|
+
|
|
27
|
+
**code blocks** like the one above 👆 have a copy button on the **top right corner** click it then paste in Lumia stream
|
|
28
|
+
|
|
29
|
+
:::
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 4
|
|
3
|
+
title: Different Chatbot message for user levels
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Different Chatbot message for user levels
|
|
7
|
+
|
|
8
|
+
You can check the different userlevels for the person chatting and do different things based on their user level.
|
|
9
|
+
In this example we'll be sending different chatbot messages based on the users level.
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
async function() {
|
|
13
|
+
// {{userLevelsRaw}} returns an object with the various user levels on it. Since we want the original object here we're using getVariable instead of using template variables
|
|
14
|
+
const userLevels = await getVariable('userLevelsRaw');
|
|
15
|
+
|
|
16
|
+
if (!userLevels) {
|
|
17
|
+
chatbot({ message: `Thanks for lurking in my stream {{username}}. You triggered {{command}}!` });
|
|
18
|
+
} else if (userLevels.isSelf) {
|
|
19
|
+
chatbot({ message: "Don't worry it's just me triggering a command named !{{command}}" });
|
|
20
|
+
} else if (userLevels.subscriber || userLevels.tier3 || userLevels.tier2 || userLevels.tier1) {
|
|
21
|
+
chatbot({ message: "Wow, you're a subscriber? Thanks for triggering {{command}}. Have a nice day!" });
|
|
22
|
+
} else if (userLevels.mod) {
|
|
23
|
+
chatbot({ message: 'Thank you for being a wonderful mod. My mod {{username}} triggered {{command}}!' });
|
|
24
|
+
} else if (userLevels.vip) {
|
|
25
|
+
chatbot({ message: 'VIPS raise the roof! {{username}}, the real VIP, triggered {{command}}!' });
|
|
26
|
+
} else if (userLevels.follower) {
|
|
27
|
+
chatbot({ message: `Thanks for being a loyal follower {{username}}. You triggered {{command}}!` });
|
|
28
|
+
} else {
|
|
29
|
+
chatbot({ message: `Thanks for lurking in my stream {{username}}. You triggered {{command}}!` });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// always make sure this is the last line in the code otherwise your computer may get slower due to memory leaks
|
|
33
|
+
done();
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
:::tip
|
|
38
|
+
|
|
39
|
+
**code blocks** like the one above 👆 have a copy button on the **top right corner** click it then paste in Lumia stream
|
|
40
|
+
|
|
41
|
+
:::
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 5
|
|
3
|
+
title: Track subscribers
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Read/Write to a file to keep track of subscribers
|
|
7
|
+
|
|
8
|
+
You can read from a file and get values from it as well as write to a file.
|
|
9
|
+
This can be very useful if other apps are reading and writing to a text file. An example of this is OBS text sources
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
async function() {
|
|
13
|
+
// You have the ability to overwrite the whole file by setting append to false, or appending to the file in case you would like to keep a log of things
|
|
14
|
+
await writeFile({ path: 'C: \\Users\\Lumia\\Desktop\\lastSubscriber.txt', message: '{{username}}\n', append: true });
|
|
15
|
+
|
|
16
|
+
// You can get your variable's value that you just set here
|
|
17
|
+
const lastSubscribers = await readFile('C:\\Users\\Lumia\\Desktop\\lastSubscriber.txt');
|
|
18
|
+
|
|
19
|
+
showToast({ message: 'The last subscribers were: ' + lastSubscribers });
|
|
20
|
+
|
|
21
|
+
// always make sure this is the last line in the code otherwise your computer may get slower due to memory leaks
|
|
22
|
+
done();
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
:::tip
|
|
27
|
+
|
|
28
|
+
**code blocks** like the one above 👆 have a copy button on the **top right corner** click it then paste in Lumia stream
|
|
29
|
+
|
|
30
|
+
:::
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Lumia Stream Custom Code GPT Instructions
|
|
2
|
+
|
|
3
|
+
Use this with the Custom Code docs:
|
|
4
|
+
- `what-is-custom-javascript.md`
|
|
5
|
+
- `important-notes.md`
|
|
6
|
+
- `helper-functions.md`
|
|
7
|
+
- `custom-actions.md`
|
|
8
|
+
- `examples/*.md`
|
|
9
|
+
|
|
10
|
+
## Required Output Rules
|
|
11
|
+
|
|
12
|
+
1. Always generate JavaScript (not TypeScript).
|
|
13
|
+
2. Prefer returning a full Lumia Custom Code wrapper:
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
async function() {
|
|
17
|
+
// logic
|
|
18
|
+
|
|
19
|
+
// Make sure you call done() to avoid memory leaks
|
|
20
|
+
done();
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
3. Always call `done()` exactly once before finishing the function, unless the user explicitly asks for a partial snippet.
|
|
25
|
+
4. Do not output markdown fences or prose when the caller expects code-only output.
|
|
26
|
+
5. Use helper functions documented in `helper-functions.md` instead of inventing undocumented APIs.
|
|
27
|
+
6. Keep examples compatible with Lumia variable syntax (e.g. `{{username}}`).
|
|
28
|
+
7. When accessing numeric variables, parse values safely before math/comparisons.
|
|
29
|
+
8. If a capability is not documented, state that clearly and provide a safe alternative.
|
|
@@ -0,0 +1,561 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 2
|
|
3
|
+
title: Helper functions
|
|
4
|
+
description: Helper functions are a premade code that helps you build your custom scripts
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
These helper functions are premade code that we setup that you can use to help you build your custom code. You will find `use case examples` in the each section as well.
|
|
8
|
+
|
|
9
|
+
### Done
|
|
10
|
+
|
|
11
|
+
`done({ shouldStop?: boolean; actionsToStop?: Array<string>; variables?: {[key: string]: string | number }}?)`: Done tell Lumia Stream that the script is complete and that the thread is safe to close now. You can also stop the command/alert in it's track by passing shouldStop true into the parameters.
|
|
12
|
+
If you would like to modify/add variables that other actions could use, you can return them in the variables parameter.
|
|
13
|
+
|
|
14
|
+
You can also choose to only stop some actions rather than stopping the whole command by using actionsToStop.
|
|
15
|
+
The different actionsToStop keys relate to the action. The keys are:
|
|
16
|
+
`devices, tts, chatbot, hfx, lumia, overlay, voicemod, streamerbot, obs, slobs, midi, osc, mqtt, serial, broadlink, websocket, twitter, twitch, spotify, vlc, artnet, api, commandRunner, inputEvent`
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
// Basic done
|
|
20
|
+
async function() {
|
|
21
|
+
done();
|
|
22
|
+
}
|
|
23
|
+
// Should stop
|
|
24
|
+
async function() {
|
|
25
|
+
done({ shouldStop: true, actionsToStop: [] });
|
|
26
|
+
}
|
|
27
|
+
// Should stop certain actions like tts and chatbot
|
|
28
|
+
async function() {
|
|
29
|
+
done({ shouldStop: true, actionsToStop: ['tts', 'chatbot'] });
|
|
30
|
+
}
|
|
31
|
+
// Passing variables
|
|
32
|
+
async function() {
|
|
33
|
+
done({ variables: { message: "Message changed" } });
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
:::tip
|
|
38
|
+
|
|
39
|
+
**code blocks** like the one above 👆 have a copy button on the **top right corner** click it then paste in Lumia stream
|
|
40
|
+
|
|
41
|
+
:::
|
|
42
|
+
|
|
43
|
+
### Add Log to both Toast and Dashboard
|
|
44
|
+
|
|
45
|
+
`log(message: any)`: The best way to log what's going on is to either use `log` or `console.log`. These will show a toast as well as add a log to the dashboard in case you need to reference it later.
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
async function() {
|
|
49
|
+
log({ data: "my data" });
|
|
50
|
+
// Or using console.log
|
|
51
|
+
console.log({ data: "my data" });
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Show Toast
|
|
56
|
+
|
|
57
|
+
`showToast({ message: string; time?: number })`: Show toast will show a popup message notification in Lumia. The time for how long it shows is in milliseconds. Leave it 0 to show forever
|
|
58
|
+
|
|
59
|
+
```js
|
|
60
|
+
async function() {
|
|
61
|
+
// shows a message popup saying command used for 200 milliseconds and the popup will close
|
|
62
|
+
showToast({ message: "command used", time: 200 });
|
|
63
|
+
|
|
64
|
+
// doing the same as the above but the popup does not close automatically
|
|
65
|
+
showToast({ message: "command used", time: 0 });
|
|
66
|
+
|
|
67
|
+
// you can also just send the message which by default the popup does not close automatically
|
|
68
|
+
showToast({ message: "command used" });
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Add Log to Dashboard
|
|
73
|
+
|
|
74
|
+
`addLog(message: string)`: Show a log in the dashboard to keep track of things
|
|
75
|
+
|
|
76
|
+
```js
|
|
77
|
+
async function() {
|
|
78
|
+
//shows in the logs section when this command is executed
|
|
79
|
+
addLog('log this command used');
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Delay
|
|
84
|
+
|
|
85
|
+
`delay(time: number)`: You can delay your code with our helper function that returns a promise. The time is in milliseconds.
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
async function() {
|
|
89
|
+
// Waits for 2 seconds
|
|
90
|
+
await delay(2000);
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Get Variable
|
|
95
|
+
|
|
96
|
+
`getVariable(name: string)`: Retrieve a variables value based on it's name
|
|
97
|
+
|
|
98
|
+
```js
|
|
99
|
+
async function() {
|
|
100
|
+
//so if you have a variable named "my variable" in the variable page this code will get it's value. Notice that you need to await the result since getVariable returns a promise
|
|
101
|
+
const myVar = await getVariable('my variable');
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Set Variable
|
|
106
|
+
|
|
107
|
+
`setVariable({ name: string; value: string | number })`: Creates/Updates a variable with name and value provided. If the variable doesn't exist it will create it
|
|
108
|
+
|
|
109
|
+
```js
|
|
110
|
+
async function() {
|
|
111
|
+
// This creates a variable named "coins" with the value of 3
|
|
112
|
+
setVariable({ name: 'coins', value: 3 });
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Delete Variable
|
|
117
|
+
|
|
118
|
+
`deleteVariable(name: string | Array<string>)`: Delete a variable or multiple variables. If the variable doesn't exist it will still return as successful
|
|
119
|
+
|
|
120
|
+
```js
|
|
121
|
+
async function() {
|
|
122
|
+
deleteVariable('coins');
|
|
123
|
+
// Or you can pass in an array of variables
|
|
124
|
+
deleteVariable(['coins', 'myVar', 'other variable']);
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Get All Variables
|
|
129
|
+
|
|
130
|
+
`getAllVariables()`: Ability to get all local and global variables with one easy call
|
|
131
|
+
|
|
132
|
+
```js
|
|
133
|
+
async function() {
|
|
134
|
+
let variables = await getAllVariables();
|
|
135
|
+
showToast({ message: JSON.stringify(variables) , time: 10000});
|
|
136
|
+
|
|
137
|
+
// always make sure this is the last line in the code otherwise your computer may get slower due to memory leaks
|
|
138
|
+
done();
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Get Persisted Store
|
|
143
|
+
|
|
144
|
+
`getStore()`: Retrieves the complete custom code store. This store is a persisted storage throughout all of your custom code and can assign any data type like string, numbers, arrays, and objects
|
|
145
|
+
|
|
146
|
+
```js
|
|
147
|
+
async function() {
|
|
148
|
+
//Notice that you need to await the result since getStore returns a promise
|
|
149
|
+
const store = await getStore();
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Get Persisted Store Item
|
|
154
|
+
|
|
155
|
+
`getStoreItem(name: string)`: Get's one item from the custom code store
|
|
156
|
+
|
|
157
|
+
```js
|
|
158
|
+
async function() {
|
|
159
|
+
//Notice that you need to await the result since getStoreItem returns a promise
|
|
160
|
+
const users = await getStoreItem('users');
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Set Persisted Store Item
|
|
165
|
+
|
|
166
|
+
`setStore({ name: string; value: any })`: Sets an item in the store. You can use any data type as your value
|
|
167
|
+
|
|
168
|
+
```js
|
|
169
|
+
async function() {
|
|
170
|
+
await setStore({ name: 'users', value: [] });
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Reset Persisted Store
|
|
175
|
+
|
|
176
|
+
`resetStore()`: Resets the store removing all items inside of it
|
|
177
|
+
|
|
178
|
+
```js
|
|
179
|
+
async function() {
|
|
180
|
+
//Notice that you need to await the result since resetStore returns a promise
|
|
181
|
+
await resetStore();
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Get Lights
|
|
186
|
+
|
|
187
|
+
`getLights()`: Get the list of lights the streamer has along with it's type and id. The type and id is required to send color or power to specific lights
|
|
188
|
+
|
|
189
|
+
```js
|
|
190
|
+
async function() {
|
|
191
|
+
const lights = await getLights()
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Send Color To Lights
|
|
196
|
+
|
|
197
|
+
`sendColor({ color?: string | { r: number; g: number; b: number }; power?: boolean; brightness?: number; transition?: number; lights?: Array<{ id: string | number; type: string }> })`: Send a color or power to either all lights or a set of lights. Do not send the `lights` array when you want to target every lights. Every parameter is optional. The type and id is required to send color or power to specific lights
|
|
198
|
+
|
|
199
|
+
```js
|
|
200
|
+
async function() {
|
|
201
|
+
// Send hex color to all lights
|
|
202
|
+
sendColor({ color: "#FF4076", brightness: 100 });
|
|
203
|
+
|
|
204
|
+
// Send rgb color to all lights
|
|
205
|
+
sendColor({ color: { r: 0, g: 0, b: 255 }, brightness: 100 });
|
|
206
|
+
|
|
207
|
+
// Send power to all lights
|
|
208
|
+
sendColor({ power: true });
|
|
209
|
+
|
|
210
|
+
// Send to specific lights
|
|
211
|
+
sendColor({ color: "#FF4076", brightness: 100, transition: 0, lights: [{ type: "hue", id: "1" }, { type: "lifx", id: "abc" }] });
|
|
212
|
+
|
|
213
|
+
// For Nanoleaf lights, ensure id values are integers without quotation marks (e.g., 14608). Quoted string IDs will not work for Nanoleaf.
|
|
214
|
+
sendColor({ color: "#FF4076", brightness: 100, transition: 0, lights: [{ type: "nanoleaf", id: 14608 }] });
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
// Send to an overlay virtual light
|
|
218
|
+
sendColor({ color: "#FF4076", brightness: 100, lights: [{ type: "virtuallights", id: "abc-123-520" }] });
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Get API Options
|
|
223
|
+
|
|
224
|
+
`getApiOptions()`: Contains information like commands, types, connections, and more
|
|
225
|
+
|
|
226
|
+
```js
|
|
227
|
+
async function() {
|
|
228
|
+
const lights = await getApiOptions()
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Call Alert
|
|
233
|
+
|
|
234
|
+
`callAlert({ name: string; variation?: string; variableValues?: {[key: string]: string|number } })`: Call an alert based on your conditions. You can also call a variation given it's name. When calling an alert/command from custom code the variableValues will be inherited from the parent, but you can also override variable values by passing it in to the call function.
|
|
235
|
+
|
|
236
|
+
The valid alert keys are:
|
|
237
|
+
|
|
238
|
+
```
|
|
239
|
+
lumia-redemption, twitch-streamLive, twitch-streamOffline, twitch-follower, twitch-subscriber, twitch-giftSubscription, twitch-host, twitch-raid, twitch-bits, twitch-redemption, twitch-hypetrainStarted, twitch-hypetrainProgressed, twitch-hypetrainLevelProgressed, twitch-hypetrainEnded, twitch-pollStarted, twitch-pollProgressed, twitch-pollEnded, twitch-predictionStarted, twitch-predictionProgressed, twitch-predictionLocked, twitch-predictionEnded, twitch-goalStarted, twitch-goalProgressed, twitch-goalEnded, twitch-categoryChanged, twitch-clip, youtube-member, youtube-subscriber, youtube-superchat, youtube-supersticker, facebook-follower, facebook-reaction, facebook-star, facebook-support, facebook-subscriptionGift, facebook-share, facebook-fan, tiktok-follower, tiktok-like, tiktok-gift, tiktok-subscriber, tiktok-share, tiktok-streamEnd, streamlabs-donation, streamlabs-charity, streamlabs-merch, streamlabs-redemption, streamlabs-primegift, streamelements-donation, extralife-donation, donordrive-donation, tiltify-campaignDonation, tipeeestream-donation, treatstream-treat, patreon-pledge, obs-switchProfile, obs-switchScene, obs-sceneItemVisibility, obs-sceneItemHidden, obs-switchTransition, obs-transitionBegin, obs-transitionEnd, obs-streamStarting, obs-streamStopping, obs-recordingStarting, obs-recordingStopping, slobs-switchSceneCollection, slobs-switchScene, slobs-sceneItemVisibility, slobs-sceneItemHidden, spotify-switchSong, spotify-songPlayed, spotify-songPaused, vlc-switchSong, vlc-songPlayed, vlc-songPaused, pulse-heartrate, pulse-calories, twitter-follower, twitter-like, twitter-retweet, woocommerce-order, kofi-donation, kofi-subscription, kofi-commission, kofi-shopOrder, streamerbot-action
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
```js
|
|
243
|
+
async function() {
|
|
244
|
+
// This will call alert 'twitch-subscriber' and call the variation of it named 'gift3' and change the variable named siren to 3
|
|
245
|
+
callAlert({ name: 'twitch-subscriber', variation: 'gift3', variableValues: {'message': 'Big gift' } })
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Call Command
|
|
250
|
+
|
|
251
|
+
`callCommand({ name: string; variableValues?: {[key: string]: string|number } })`: Call a command based on your conditions. When calling an alert/command from custom code the variableValues will be inherited from the parent, but you can also override variable values by passing it in to the call function.
|
|
252
|
+
|
|
253
|
+
```js
|
|
254
|
+
async function() {
|
|
255
|
+
// This will call command called 'cheers' and change the variable named "message" to the value "you are awesome"
|
|
256
|
+
callCommand({ name: 'cheers', variableValues: {'message': 'you are awesome' } })
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### Call Twitch Point Command
|
|
261
|
+
|
|
262
|
+
`callTwitchPoint({ name: string; variableValues?: {[key: string]: string|number } })`: Call a twitch point command based on your conditions. When calling an alert/command from custom code the variableValues will be inherited from the parent, but you can also override variable values by passing it in to the call function.
|
|
263
|
+
|
|
264
|
+
```js
|
|
265
|
+
async function() {
|
|
266
|
+
// This will call Twitch Point called 'point' and change the variable named "message" to the value "you are awesome"
|
|
267
|
+
callTwitchPoint({ name: 'point', variableValues: {'message': "you are awesome" } });
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### Call Twitch Extension Command
|
|
272
|
+
|
|
273
|
+
`callTwitchExtension({ name: string; variableValues?: {[key: string]: string|number } })`: Call a twitch extension command based on your conditions. When calling an alert/command from custom code the variableValues will be inherited from the parent, but you can also override variable values by passing it in to the call function.
|
|
274
|
+
|
|
275
|
+
```js
|
|
276
|
+
async function() {
|
|
277
|
+
// This will call Twitch Extension called 'point' and change the variable named "message" to the value "you are awesome"
|
|
278
|
+
callTwitchExtension({ name: 'point', variableValues: {'message': "you are awesome" } });
|
|
279
|
+
}
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
### Read File
|
|
284
|
+
|
|
285
|
+
`readFile(path: string)`: Read from a file on your local computer to get the contents of it to be displayed in your code. This is useful for other Apps that write and read to files so you can combine the usage of them in Lumia. To keep things consistent, try to use an absolute file path
|
|
286
|
+
|
|
287
|
+
```js
|
|
288
|
+
async function() {
|
|
289
|
+
// This will read the file from this path. Returns a promise so await is needed
|
|
290
|
+
const fileText = await readFile('C:\\Documents\\Lumiastream\\helper.txt');
|
|
291
|
+
}
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### Write File
|
|
295
|
+
|
|
296
|
+
`writeFile({ path: string; message: string | number; append?: boolean })`: Write to a file on your local computer to update the contents of it. This is useful for other Apps that write and read to files so you can combine the usage of them in Lumia. OBS Text source is a great exmaple of this. You can optionally pass in an `append` to append to a text file instead of overwriting the whole file. When using append you can create a new line by starting with a blank line
|
|
297
|
+
|
|
298
|
+
```js
|
|
299
|
+
async function() {
|
|
300
|
+
// This will create a new file in the 'C:\Documents\Lumiastream\' named helper.txt and add the text "text inside this file" inside that file
|
|
301
|
+
await writeFile({ path: 'C:\\Documents\\Lumiastream\\helper.txt', value: 'text inside this file', append: true });
|
|
302
|
+
}
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### Text To Speech (TTS)
|
|
306
|
+
|
|
307
|
+
`tts({ message: string; voice?: string; volume?: number })`: You can trigger Text To Speech directly inside of your code. You can even choose the voice and set the volume optionally
|
|
308
|
+
|
|
309
|
+
```js
|
|
310
|
+
async function() {
|
|
311
|
+
// This will read the message with text to speach using the voice that you added with the volume 60%
|
|
312
|
+
tts({ message: 'Lumia stream loves you',voice: 'Brian', volume: 60 });
|
|
313
|
+
}
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
### Chat Bot
|
|
317
|
+
|
|
318
|
+
`chatbot({ message: string; site?: 'twitch' | 'youtube' | 'facebook'; color?: string; chatAsSelf?: boolean })`: You can trigger a Chat bot directly inside of your code. You can even change the color of the message, whether to chat as your self or the bot, and the ability to change the site. Site can now be an array or a regular string.
|
|
319
|
+
|
|
320
|
+
```js
|
|
321
|
+
async function() {
|
|
322
|
+
//this will send a custom chatbot message "hello from Lumia Stream" to twitch colored with this hex code "#F57FAE" shown in the chat as your self
|
|
323
|
+
chatbot({ message: 'hello from Lumia Stream', site: "twitch", color:"#F57FAE", chatAsSelf:true });
|
|
324
|
+
|
|
325
|
+
// Send to multiple sites at once
|
|
326
|
+
chatbot({ message: 'hello from Lumia Stream', site: ["twitch", "youtube", "facebook"], color:"#F57FAE",chatAsSelf:true });
|
|
327
|
+
}
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### Play Audio
|
|
331
|
+
|
|
332
|
+
`playAudio({ path: string | string[]; volume?: number; waitForAudioToStop?: boolean })`: You can play an audio file from either a URL or from a local path on your computer inside of your code. You can even wait for the audio to stop playing before the code continues by setting an await before while also setting waitForAudioToStop to true. You can also allow Lumia Stream to randomly play an audio file from a selection by passing an array of strings to path
|
|
333
|
+
|
|
334
|
+
```js
|
|
335
|
+
async function() {
|
|
336
|
+
playAudio({ path: "C:\\Documents\\Lumiastream\\lumiajam.mp3", volume: 100, waitForAudioToStop: false });
|
|
337
|
+
|
|
338
|
+
// Or you can await the sound to stop playing first
|
|
339
|
+
await playAudio({ path: "C:\\Documents\\Lumiastream\\lumiajam.mp3", volume: 100, waitForAudioToStop: true });
|
|
340
|
+
|
|
341
|
+
// You can also play multiple files by passing an array to path
|
|
342
|
+
await playAudio({ path: ["C:\\Documents\\Lumiastream\\lumiajam.mp3", "C:\\Documents\\Lumiastream\\lumiasecond.mp3"], volume: 100 });
|
|
343
|
+
}
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### Send Raw OBS JSON
|
|
347
|
+
|
|
348
|
+
`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 end the request type and your other parameters and Lumia Stream will take care of the rest
|
|
349
|
+
|
|
350
|
+
```js
|
|
351
|
+
async function() {
|
|
352
|
+
sendRawObsJson({
|
|
353
|
+
"request-type": "SetSceneItemEnabled",
|
|
354
|
+
"sceneItemEnabled": true,
|
|
355
|
+
"sceneItemId": 1,
|
|
356
|
+
"sceneName": "Scene 1"
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### Execute Shell Command
|
|
362
|
+
|
|
363
|
+
`execShellCommand(command: string)`: You can execute shell commands and wait for their return value. It will send the stdout if successfull or the stderr if it fails. It will not reject the promise though
|
|
364
|
+
|
|
365
|
+
```js
|
|
366
|
+
async function() {
|
|
367
|
+
await execShellCommand("say wow");
|
|
368
|
+
}
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
### Get Token
|
|
372
|
+
|
|
373
|
+
`getToken(connection: "twitch" | "twitchChatbot" | "youtube" | "facebook" | "streamlabs" | "streamelements" | "treatstream" | "tipeeestream" | "tiltify" | "patreon" | "woocommerce" | "discord" | "twitter" | "spotify" | "pulsoid" | "wyze" | "homeassistant" | "govee" | "wled" )`: When you need to call a request that we don't directly support you can get the access token from Lumia before making the call. This is helpful for things where you need to call for instance the Twitch API, but you don't want to handle tokens and refreshing inside of your scripts. More examples of this below
|
|
374
|
+
|
|
375
|
+
```js
|
|
376
|
+
async function() {
|
|
377
|
+
// This will get the access token for your user on Twitch
|
|
378
|
+
const token = await getToken('twitch');
|
|
379
|
+
}
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
### Get Client ID For Twitch
|
|
383
|
+
|
|
384
|
+
`getClientId(connection: "twitch")`: When calling requests with Twitch's API you will need to pass in a Client-ID to the headers. We provide a Client ID that you can use to call the different api's with the permissions the user has selected. Check out [Twitch's developers docs](https://dev.twitch.tv/docs/api/reference) to learn what you can do
|
|
385
|
+
|
|
386
|
+
```js
|
|
387
|
+
async function() {
|
|
388
|
+
// This will get the client id for Twitch
|
|
389
|
+
const token = await getClientId('twitch');
|
|
390
|
+
}
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
## Overlay Actions
|
|
394
|
+
|
|
395
|
+
Note: When using layers you can call them by the layers name. But if you have multiple layers named the same thing in different overlays it may not trigger on the correct overlay. Make sure you give your layers a unique name so that you do not have any issues triggering the correct layer. We do not check for unique Overlay names and unique Layer names at this time since under the hood we use ID's
|
|
396
|
+
|
|
397
|
+
### Overlay Alert Trigger
|
|
398
|
+
|
|
399
|
+
`overlayAlertTrigger({ layer: string, firstMessage: string" })`: You can trigger a generic alert layer that you've created on your overlays. This will only trigger the generic alert though. To fire an alert that isn't the generic one you will need to use `callAlert`.
|
|
400
|
+
`firstMessage` is the message that will show for the alert
|
|
401
|
+
|
|
402
|
+
```js
|
|
403
|
+
async function() {
|
|
404
|
+
overlayAlertTrigger({ layer: "my unique layer name", firstMessage: "{{message}}" });
|
|
405
|
+
}
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
### Overlay Set Visibility
|
|
409
|
+
|
|
410
|
+
`overlaySetVisibility({ overlay: string, on: boolean })`: You can set the visibility of the full overlay using this function. You should make sure all of your overlays have unique names. We do not check for unique names since under the hood we use ID's
|
|
411
|
+
|
|
412
|
+
```js
|
|
413
|
+
async function() {
|
|
414
|
+
overlaySetVisibility({ overlay: "my cool overlay", on: false });
|
|
415
|
+
}
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### Overlay Set Layer Visibility
|
|
419
|
+
|
|
420
|
+
`overlaySetLayerVisibility({ layer: string, on: boolean })`: You can set the visibility of an overlay layer using this function. You should make sure all of your layers have unique names. We do not check for unique names since under the hood we use ID's
|
|
421
|
+
|
|
422
|
+
```js
|
|
423
|
+
async function() {
|
|
424
|
+
overlaySetLayerVisibility({ layer: "My layer", on: false });
|
|
425
|
+
}
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
### Overlay Set Layer Position (X and Y)
|
|
429
|
+
|
|
430
|
+
`overlaySetLayerPosition({ layer: string, content: string })`: You can set the x and y position of an overlay layer using this function. `content` is just a string that will correspond to the x and y position separated by a comma. Our overlay is also fast enough to handle interpolation in case you want to move things in a smooth way.
|
|
431
|
+
|
|
432
|
+
```js
|
|
433
|
+
async function() {
|
|
434
|
+
overlaySetLayerPosition({ layer: "My layer", content: "100,100" });
|
|
435
|
+
}
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
### Overlay Set Text Content
|
|
439
|
+
|
|
440
|
+
`overlaySetTextContent({ layer: string, content: string })`: You can set the text content of a text layer using this function. `content` is just a string that will correspond to the text that you want to set it to.
|
|
441
|
+
|
|
442
|
+
```js
|
|
443
|
+
async function() {
|
|
444
|
+
overlaySetTextContent({ layer: "My layer", content: "" });
|
|
445
|
+
}
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
### Overlay Set Image Content
|
|
449
|
+
|
|
450
|
+
`overlaySetImageContent({ layer: string, content: string })`: You can set the image content of an image layer using this function. `content` is just a string that will correspond to the image name or url that you want to set it to. If you use a name it will try to find the name of an asset that you have in your overlay library. So if you have an asset named `lumia_logo.gif` you can set the content to the exact name with or without the file extension. This can be useful to allow chat to change the media using a \{\{message\}\} variable. After the content is changed it will automatically make the layer visibile and start playing
|
|
451
|
+
|
|
452
|
+
```js
|
|
453
|
+
async function() {
|
|
454
|
+
overlaySetImageContent({ layer: "My layer", content: "lumia_logo.gif" });
|
|
455
|
+
// Without file extension
|
|
456
|
+
overlaySetImageContent({ layer: "My layer", content: "lumia_logo" });
|
|
457
|
+
// Or using a url
|
|
458
|
+
overlaySetImageContent({ layer: "My layer", content: "https://lumiastream.com/favicon.ico" });
|
|
459
|
+
}
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
### Overlay Set Video Content
|
|
463
|
+
|
|
464
|
+
`overlaySetVideoContent({ layer: string, content: string })`: You can set the video content of an video layer using this function. `content` is just a string that will correspond to the video name or url that you want to set it to. If you use a name it will try to find the name of an asset that you have in your overlay library. So if you have an asset named `lumia_video.webm` you can set the content to the exact name with or without the file extension. This can be useful to allow chat to change the media using a \{\{message\}\} variable. After the content is changed it will automatically make the layer visibile and start playing
|
|
465
|
+
|
|
466
|
+
```js
|
|
467
|
+
async function() {
|
|
468
|
+
overlaySetVideoContent({ layer: "My layer", content: "lumia_video.webm" });
|
|
469
|
+
// Without file extension
|
|
470
|
+
overlaySetVideoContent({ layer: "My layer", content: "lumia_video" });
|
|
471
|
+
// Or using a url
|
|
472
|
+
overlaySetVideoContent({ layer: "My layer", content: "https://lumiastream.com/video.webm" });
|
|
473
|
+
}
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
### Overlay Set Audio Content
|
|
477
|
+
|
|
478
|
+
`overlaySetAudioContent({ layer: string, content: string })`: You can set the audio content of an audio layer using this function. `content` is just a string that will correspond to the audio name or url that you want to set it to. If you use a name it will try to find the name of an asset that you have in your overlay library. So if you have an asset named `lumia_land.mp3` you can set the content to the exact name with or without the file extension. This can be useful to allow chat to change the media using a \{\{message\}\} variable. After the content is changed it will automatically make the layer visibile and start playing
|
|
479
|
+
|
|
480
|
+
```js
|
|
481
|
+
async function() {
|
|
482
|
+
overlaySetAudioContent({ layer: "My layer", content: "lumia_land.mp3" });
|
|
483
|
+
// Without file extension
|
|
484
|
+
overlaySetAudioContent({ layer: "My layer", content: "lumia_land" });
|
|
485
|
+
// Or using a url
|
|
486
|
+
overlaySetAudioContent({ layer: "My layer", content: "https://lumiastream.com/lumia_land.mp3" });
|
|
487
|
+
}
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
### Overlay Set Media Volume
|
|
491
|
+
|
|
492
|
+
`overlaySetVolume({ layer: string, volume: number })`: You can set the volume of a media layer using this function. `volume` is a number between 0 and 1 that will correspond to the volume url that you want to set it to. 1 is equal to 100, 0.5 is equal to 50%, and 0 is equal to 0%.
|
|
493
|
+
|
|
494
|
+
```js
|
|
495
|
+
async function() {
|
|
496
|
+
overlaySetVolume({ layer: "My layer", volume: .5 });
|
|
497
|
+
}
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
### Overlay Play/Pause Media
|
|
501
|
+
|
|
502
|
+
`overlayPlayPauseMedia({ layer: string, volume: number })`: You can play/pause a media layer using this function. `on` is a boolean that will correspond to the state of the media. `true` plays the media and `false` pauses the media.
|
|
503
|
+
|
|
504
|
+
```js
|
|
505
|
+
async function() {
|
|
506
|
+
overlayPlayPauseMedia({ layer: "My layer", on: false });
|
|
507
|
+
}
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
### Overlay Send HFX
|
|
511
|
+
|
|
512
|
+
`overlaySendHfx({ content: string, playAudio: boolean })`: You can directly trigger a HFX as well as play the audio or not using this function. No layer is needed here since HFX is always meant to have only one layer per overlay and will trigger any and all HFX video layers. `content` is a string that will correspond to the HFX name that you want to trigger. To see the list of names, please visit the HUDFX tab in the sidebar of Lumia Stream. Since these are updated weekly we will not store them in the documentation.
|
|
513
|
+
|
|
514
|
+
```js
|
|
515
|
+
async function() {
|
|
516
|
+
overlaySendHfx({ content: "ghost-talk", playAudio: true });
|
|
517
|
+
}
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
### Overlay Set Timer
|
|
521
|
+
|
|
522
|
+
`overlayTimer({ layer: string, content: string })`: You can update a timer layer using this function. `content` is a string that will correspond to the time to set the timer to. After the timer is changed it will automatically make the layer visibile and start playing. You can use math here and short wording. The operators can all be used: `(+, -, /, *)` followed by the number and then the unit of time `(s, m, h, d)`.
|
|
523
|
+
You can also combine multiple values as well. Like `+1m10s` would increase the timer by 1 minute and 10 seconds. `=5m` would set the timer exactly at 5 minutes and will start running immediately.
|
|
524
|
+
|
|
525
|
+
```js
|
|
526
|
+
async function() {
|
|
527
|
+
overlayTimer({ layer: "My layer", content: "+5s" });
|
|
528
|
+
}
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
### Overlay Shoutout
|
|
532
|
+
|
|
533
|
+
`overlayShoutout({ layer: string, clipType: "clipFromTarget" | "clipFromSender" | "clipFromStreamer", clipRandom: boolean, clipLimit: number, clipMaxTime: string })`: You can send a shoutout directly to a shoutout layer using this function. `clipType` has three types. `clipFromTarget` will take a clip from the user who was tagged in the \{\{message\}\} variable. So you can use @lumiastream in the message and it will take a clip from that channel. `clipFromSender` will take a clip from the person who triggered the command. This normally corresponds to the \{\{user\}\} variable. `clipFromStreamer` will take a clip from your channel and send it over. You can decide to take a random clip by setting `clipRandom` to true. Or if you would like to take the first clip that matched the `clipMaxTime` given in milliseconds then you can set `clipRandom` to false. `clipLimit` will determing how many of the newest clips should be brought in to determine which clip should be selected. After a clip is selected it will start running immediately
|
|
534
|
+
|
|
535
|
+
```js
|
|
536
|
+
async function() {
|
|
537
|
+
// A random clip from the person who was tagged in the message that has a max clip time of 60 seconds and will only take in the newest 100 clips
|
|
538
|
+
overlayShoutout({ layer: "My layer", clipType: "clipFromTarget", clipRandom: true, clipLimit: 100, clipMaxTime: "60000" });
|
|
539
|
+
|
|
540
|
+
// The newest clip from the person who was tagged in the message that is under 20 seconds and will only take in the newest 20 clips
|
|
541
|
+
overlayShoutout({ layer: "My layer", clipType: "clipFromTarget", clipRandom: false, clipLimit: 20, clipMaxTime: "20000" });
|
|
542
|
+
|
|
543
|
+
// The newest clip from the person who triggered the command that is under 20 seconds and will only take in the newest 20 clips
|
|
544
|
+
overlayShoutout({ layer: "My layer", clipType: "clipFromSender", clipRandom: false, clipLimit: 20, clipMaxTime: "20000" });
|
|
545
|
+
}
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
### Overlay Send To Custom Overlay
|
|
549
|
+
|
|
550
|
+
`overlaySendCustomContent({ codeId: string, content: string, layer?: string })`: You can send a content directly to custom overlays. `codeId` is the id of the code that created the custom overlay and will only send to overlays with this codeId. `content` is a string, but you can also pass in strigified json and then parse it in the custom overlay js code.
|
|
551
|
+
This function is useful for sending messages from a command or alert to your custom overlay without needing to rely on listening to events like chat and alerts. `layer` is not requred nor is it recommended to use if you will be sharing this command with your custom code.
|
|
552
|
+
|
|
553
|
+
```js
|
|
554
|
+
async function() {
|
|
555
|
+
// A regular string message that can be sent to your custom overlay
|
|
556
|
+
overlaySendCustomContent({ codeId: "myoverlay", content: "blue" });
|
|
557
|
+
|
|
558
|
+
// A strigified json string that can then be parsed on the custom overlay js side. Add a key to your json so you konw this data belongs to your overlay
|
|
559
|
+
overlaySendCustomContent({ codeId: "myoverlay", content: '{"key": "myoverlay", "color":"blue","age":5,"name":"user"}' });
|
|
560
|
+
}
|
|
561
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 4
|
|
3
|
+
title: Important notes
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Important notes
|
|
7
|
+
|
|
8
|
+
- You can use variables inside of your script that are replaced with the variables before the script is even ran. So if you do `tts({ message: "{{username}}" })`, it will replace the `"{{username}}"` with whoever is calling the command before the script is even ran. Take note that the variable is wrapped in quotes to be used as a string since when it is replaced it does not automatically add the quotes.
|
|
9
|
+
|
|
10
|
+
- By default variable values from the command/alert will be passed to the command/alert that you call. You can bypass those values as well as add new ones by passing in `variableValues` into the command. e.g: `callCommand({ value: 'cool-people', variableValues: { 'username': 'lumia' }})`
|
|
11
|
+
|
|
12
|
+
- If you are attempting to use this inside of Chat Command, Twitch Points, or Twitch Extension we expose a new variable called `{{userLevelsRaw}}`. This variable will contain an object with the different userlevels this user has.
|
|
13
|
+
The different options are: `isSelf, mod, vip, tier3, tier2, tier1, subscriber, follower`.
|
|
14
|
+
In your code you should use `const levels = await getVariable('userLevelsRaw');` and then you can check a level with `if (levels.subscriber) {}` since these are all booleans
|
|
15
|
+
|
|
16
|
+
- To quickly log out information for easier debugging, use `log("")`. You can also use `console.log` which will do the same thing. This will popup a toast message with what you are trying to log as well as add it to the logs in the dashboard
|
|
17
|
+
|
|
18
|
+
- Everything ran is in a safe JavaScript worker thread away from the Lumia Stream thread so no need to worry about scripts slowing down the app. Make sure you do avoid memory leaks by calling `done()` when you're done with your script
|
|
19
|
+
|
|
20
|
+
**Share your code** with our community in [**Discord**](https://discord.gg/R8rCaKb) and help **extending Lumia's functionality**
|
|
21
|
+
|
|
22
|
+
**Checkout the use case examples in the next section**
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 1
|
|
3
|
+
title: What is custom javascript?
|
|
4
|
+
description: Custom Code allows you to extend Lumia Stream functionality by adding your own scenarios to commands and alerts with code all using JavaScript
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Custom Javascript will allow you to extend Lumia Stream's functionality by adding conditions to what you want to happen. You can even make your own scenarios that trigger other commands/alerts with code.
|
|
8
|
+
|
|
9
|
+
Before we begin while being a coder helps, we will try to give as many examples for you to copy and paste so that you won't need to be a coder to do cool things. Let's begin
|
|
10
|
+
|
|
11
|
+
There are two areas within Lumia Stream which allow for custom javascript code to be run. Alerts and Commands. Both of them contain an "Advanced" category when editing where custom code can be utilized. The following is an example utilizing Commands.
|
|
12
|
+
|
|
13
|
+
Open Lumia Stream and head to `Commands` > `Chat` then `edit` or `add a new command` that you want to activate javascript code on.
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+
Next on the tabs at the top click on `Custom Javascript`
|
|
18
|
+
|
|
19
|
+

|
|
20
|
+
|
|
21
|
+
You'll see an input where you can put all the code that you copy from the sections below like this
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+
|
|
25
|
+
:::tip
|
|
26
|
+
|
|
27
|
+
**code blocks** like the one below 👇 have a copy button on the **top right corner** click it then paste in Lumia stream
|
|
28
|
+
|
|
29
|
+
:::
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
async function() {
|
|
33
|
+
|
|
34
|
+
// put your code inside here
|
|
35
|
+
|
|
36
|
+
// always make sure this is the last line in the code otherwise your computer may get slower due to memory leaks
|
|
37
|
+
done();
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
```
|
|
@@ -117,9 +117,6 @@ type TwitchBits = BaseAlert<
|
|
|
117
117
|
/** Optional message accompanying the cheer. */
|
|
118
118
|
message: string | null;
|
|
119
119
|
/** Raw message string from the platform. */
|
|
120
|
-
rawMessage: string;
|
|
121
|
-
/** Full message (Lumia-computed, if present). */
|
|
122
|
-
full_message: string;
|
|
123
120
|
/** Channel views at time of alert. */
|
|
124
121
|
channelViews: number;
|
|
125
122
|
/** Channel description text. */
|
|
@@ -207,9 +204,6 @@ type TwitchPowerup = BaseAlert<
|
|
|
207
204
|
/** Vendor amount (mirrors value). */
|
|
208
205
|
amount: number;
|
|
209
206
|
/** Raw chat message, if present. */
|
|
210
|
-
rawMessage: string | null;
|
|
211
|
-
/** Full message (Lumia-computed), if present. */
|
|
212
|
-
full_message: string | null;
|
|
213
207
|
/** Channel views at time of alert. */
|
|
214
208
|
channelViews: number;
|
|
215
209
|
/** Channel description text. */
|
|
@@ -251,8 +245,6 @@ type TwitchExtension = BaseAlert<
|
|
|
251
245
|
platform: 'twitch';
|
|
252
246
|
/** Channel views at time of alert (string|number to match vendor inconsistencies). */
|
|
253
247
|
channelViews: string | number;
|
|
254
|
-
/** Full message (Lumia-computed), if present. */
|
|
255
|
-
full_message: string;
|
|
256
248
|
/** Channel description text. */
|
|
257
249
|
channelDescription: string;
|
|
258
250
|
}
|
|
@@ -319,7 +311,6 @@ type KickPoints = BaseAlert<
|
|
|
319
311
|
/** Platform discriminator. */
|
|
320
312
|
platform: 'kick';
|
|
321
313
|
/** Raw message (not parsed). */
|
|
322
|
-
rawMessage: string | null;
|
|
323
314
|
/** Amount type echo. */
|
|
324
315
|
amount_type: 'points';
|
|
325
316
|
/** Currency symbol (if set). */
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
# Lumia Stream Custom Overlays + Plugin Integration GPT Instructions
|
|
2
2
|
|
|
3
|
-
This GPT
|
|
4
|
-
|
|
5
|
-
- Custom Overlay Layers (HTML / CSS / JS + Configs + Data) that react in real-time to Lumia events
|
|
6
|
-
- Plugin + Overlay integrations when a plugin is needed for data/business logic and the overlay is used for visuals
|
|
7
|
-
|
|
8
|
-
It prioritizes accuracy, clarity, and practical solutions tailored to Lumia Stream APIs.
|
|
3
|
+
This GPT helps users build and debug Lumia custom overlays (HTML/CSS/JS + Configs + Data) and plugin+overlay integrations.
|
|
9
4
|
|
|
10
5
|
---
|
|
11
6
|
|
|
@@ -25,25 +20,7 @@ It prioritizes accuracy, clarity, and practical solutions tailored to Lumia Stre
|
|
|
25
20
|
- Guide users with the five tabs: HTML, CSS, JS, Configs, Data.
|
|
26
21
|
- Explain Config fields clearly (input, number, checkbox, dropdown, multiselect, colorpicker, fontpicker, slider).
|
|
27
22
|
- Show initial data via `Overlay.data`.
|
|
28
|
-
-
|
|
29
|
-
|
|
30
|
-
```js
|
|
31
|
-
Overlay.on("chat", (data) => {
|
|
32
|
-
console.log("chat", data);
|
|
33
|
-
});
|
|
34
|
-
Overlay.on("alert", (data) => {
|
|
35
|
-
console.log("alert", data);
|
|
36
|
-
});
|
|
37
|
-
Overlay.on("hfx", (data) => {
|
|
38
|
-
console.log("hfx", data);
|
|
39
|
-
});
|
|
40
|
-
Overlay.on("virtuallight", (data) => {
|
|
41
|
-
console.log("virtuallight", data);
|
|
42
|
-
});
|
|
43
|
-
Overlay.on("overlaycontent", (data) => {
|
|
44
|
-
console.log("overlaycontent", data);
|
|
45
|
-
});
|
|
46
|
-
```
|
|
23
|
+
- Use `Overlay.on` listeners for `chat`, `alert`, `hfx`, `virtuallight`, and `overlaycontent`.
|
|
47
24
|
|
|
48
25
|
3. Ask for clarification when needed
|
|
49
26
|
- If requirements are ambiguous, ask targeted follow-up questions.
|
package/dist/variables.types.js
CHANGED
|
@@ -666,14 +666,12 @@ exports.ReservedVariables = [
|
|
|
666
666
|
'variables',
|
|
667
667
|
'username',
|
|
668
668
|
'displayname',
|
|
669
|
-
'full_message',
|
|
670
669
|
'userId',
|
|
671
670
|
'value',
|
|
672
671
|
'site',
|
|
673
672
|
'command',
|
|
674
673
|
'merch',
|
|
675
674
|
'message',
|
|
676
|
-
'rawMessage',
|
|
677
675
|
'messageWithoutEmotes',
|
|
678
676
|
'rawMessageWithoutEmotes',
|
|
679
677
|
'userColor',
|
|
@@ -868,7 +866,6 @@ exports.AllVariables = {
|
|
|
868
866
|
'command',
|
|
869
867
|
'message',
|
|
870
868
|
'messageId',
|
|
871
|
-
'rawMessage',
|
|
872
869
|
'messageWithoutEmotes',
|
|
873
870
|
'rawMessageWithoutEmotes',
|
|
874
871
|
'userColor',
|
|
@@ -893,7 +890,6 @@ exports.AllVariables = {
|
|
|
893
890
|
'command',
|
|
894
891
|
'message',
|
|
895
892
|
'messageId',
|
|
896
|
-
'rawMessage',
|
|
897
893
|
'messageWithoutEmotes',
|
|
898
894
|
'rawMessageWithoutEmotes',
|
|
899
895
|
'userColor',
|
|
@@ -914,7 +910,6 @@ exports.AllVariables = {
|
|
|
914
910
|
'command',
|
|
915
911
|
'prompt',
|
|
916
912
|
'message',
|
|
917
|
-
'rawMessage',
|
|
918
913
|
'messageWithoutEmotes',
|
|
919
914
|
'rawMessageWithoutEmotes',
|
|
920
915
|
'points',
|
|
@@ -931,7 +926,6 @@ exports.AllVariables = {
|
|
|
931
926
|
'command',
|
|
932
927
|
'prompt',
|
|
933
928
|
'message',
|
|
934
|
-
'rawMessage',
|
|
935
929
|
'messageWithoutEmotes',
|
|
936
930
|
'rawMessageWithoutEmotes',
|
|
937
931
|
'points',
|
|
@@ -970,7 +964,6 @@ exports.AllVariables = {
|
|
|
970
964
|
'command',
|
|
971
965
|
'message',
|
|
972
966
|
'messageId',
|
|
973
|
-
'rawMessage',
|
|
974
967
|
'messageWithoutEmotes',
|
|
975
968
|
'rawMessageWithoutEmotes',
|
|
976
969
|
'userColor',
|
|
@@ -1016,7 +1009,6 @@ exports.AllVariables = {
|
|
|
1016
1009
|
'command',
|
|
1017
1010
|
'message',
|
|
1018
1011
|
'messageId',
|
|
1019
|
-
'rawMessage',
|
|
1020
1012
|
'userColor',
|
|
1021
1013
|
'platform',
|
|
1022
1014
|
'badgesRaw',
|
|
@@ -1038,7 +1030,6 @@ exports.AllVariables = {
|
|
|
1038
1030
|
'command',
|
|
1039
1031
|
'message',
|
|
1040
1032
|
'messageId',
|
|
1041
|
-
'rawMessage',
|
|
1042
1033
|
'userColor',
|
|
1043
1034
|
'platform',
|
|
1044
1035
|
'badgesRaw',
|
|
@@ -1060,7 +1051,6 @@ exports.AllVariables = {
|
|
|
1060
1051
|
'command',
|
|
1061
1052
|
'message',
|
|
1062
1053
|
'messageId',
|
|
1063
|
-
'rawMessage',
|
|
1064
1054
|
'userColor',
|
|
1065
1055
|
'platform',
|
|
1066
1056
|
'badgesRaw',
|
|
@@ -1082,7 +1072,6 @@ exports.AllVariables = {
|
|
|
1082
1072
|
'command',
|
|
1083
1073
|
'message',
|
|
1084
1074
|
'messageId',
|
|
1085
|
-
'rawMessage',
|
|
1086
1075
|
'userColor',
|
|
1087
1076
|
'platform',
|
|
1088
1077
|
'badgesRaw',
|
|
@@ -1108,7 +1097,6 @@ exports.AllVariables = {
|
|
|
1108
1097
|
'command',
|
|
1109
1098
|
'message',
|
|
1110
1099
|
'messageId',
|
|
1111
|
-
'rawMessage',
|
|
1112
1100
|
'userColor',
|
|
1113
1101
|
'platform',
|
|
1114
1102
|
'badgesRaw',
|
|
@@ -1132,7 +1120,6 @@ exports.AllVariables = {
|
|
|
1132
1120
|
'command',
|
|
1133
1121
|
'message',
|
|
1134
1122
|
'messageId',
|
|
1135
|
-
'rawMessage',
|
|
1136
1123
|
'userColor',
|
|
1137
1124
|
'platform',
|
|
1138
1125
|
'badgesRaw',
|
|
@@ -1159,7 +1146,6 @@ exports.AllVariables = {
|
|
|
1159
1146
|
'command',
|
|
1160
1147
|
'message',
|
|
1161
1148
|
'messageId',
|
|
1162
|
-
'rawMessage',
|
|
1163
1149
|
'userColor',
|
|
1164
1150
|
'platform',
|
|
1165
1151
|
'badgesRaw',
|
|
@@ -1183,7 +1169,6 @@ exports.AllVariables = {
|
|
|
1183
1169
|
'command',
|
|
1184
1170
|
'message',
|
|
1185
1171
|
'messageId',
|
|
1186
|
-
'rawMessage',
|
|
1187
1172
|
'userColor',
|
|
1188
1173
|
'platform',
|
|
1189
1174
|
'badgesRaw',
|
|
@@ -1214,7 +1199,6 @@ exports.AllVariables = {
|
|
|
1214
1199
|
'command',
|
|
1215
1200
|
'message',
|
|
1216
1201
|
'messageId',
|
|
1217
|
-
'rawMessage',
|
|
1218
1202
|
'userColor',
|
|
1219
1203
|
'platform',
|
|
1220
1204
|
'badgesRaw',
|
|
@@ -1241,7 +1225,6 @@ exports.AllVariables = {
|
|
|
1241
1225
|
'command',
|
|
1242
1226
|
'message',
|
|
1243
1227
|
'messageId',
|
|
1244
|
-
'rawMessage',
|
|
1245
1228
|
'userColor',
|
|
1246
1229
|
'platform',
|
|
1247
1230
|
'badgesRaw',
|
|
@@ -1662,8 +1645,8 @@ exports.AllVariables = {
|
|
|
1662
1645
|
sessionSubs: ['total', 'previousTotal'],
|
|
1663
1646
|
giftSubscription: ['username', 'avatar', 'tier', 'giftAmount', 'recipients', 'recipientsRaw', 'gifter', 'totalGifts', 'subMonths', 'streakMonths', 'message', 'subPlan', 'subPlanName'],
|
|
1664
1647
|
sessionGiftSubscriptions: ['total', 'previousTotal'],
|
|
1665
|
-
bits: ['username', 'avatar', 'amount', 'message'
|
|
1666
|
-
bitsCombo: ['username', 'avatar', 'amount', 'bitsType', 'message'
|
|
1648
|
+
bits: ['username', 'avatar', 'amount', 'message'],
|
|
1649
|
+
bitsCombo: ['username', 'avatar', 'amount', 'bitsType', 'message'],
|
|
1667
1650
|
sessionBits: ['total', 'previousTotal'],
|
|
1668
1651
|
raid: ['username', 'avatar', 'viewers'],
|
|
1669
1652
|
raidOut: ['username', 'avatar', 'viewers'],
|
|
@@ -1765,8 +1748,8 @@ exports.AllVariables = {
|
|
|
1765
1748
|
shoutoutReceive: ['username', 'userId', 'displayname', 'avatar', 'viewer_count', 'started_at'],
|
|
1766
1749
|
adStarted: ['length', 'is_automatic', 'started_at', 'twitch_next_ad'],
|
|
1767
1750
|
adStopped: ['length', 'is_automatic', 'started_at', 'twitch_next_ad'],
|
|
1768
|
-
powerups: ['username', 'avatar', 'type', 'amount', 'message'
|
|
1769
|
-
powerupsPoints: ['username', 'avatar', 'type', 'amount', 'message'
|
|
1751
|
+
powerups: ['username', 'avatar', 'type', 'amount', 'message'],
|
|
1752
|
+
powerupsPoints: ['username', 'avatar', 'type', 'amount', 'message'],
|
|
1770
1753
|
},
|
|
1771
1754
|
},
|
|
1772
1755
|
twitter: {
|
package/package.json
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lumiastream/lumia-types",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"/dist"
|
|
8
8
|
],
|
|
9
9
|
"scripts": {
|
|
10
|
-
"build": "npm run clean && tsc && npm run sync:custom-overlays",
|
|
10
|
+
"build": "npm run clean && tsc && npm run sync:custom-overlays && npm run sync:custom-code",
|
|
11
11
|
"prepublishOnly": "npm run build",
|
|
12
12
|
"lint": "tslint --project tsconfig.json \"src/**/*.ts\"",
|
|
13
13
|
"lint:fix": "tslint --project tsconfig.json --fix \"src/**/*.ts\"",
|
|
14
14
|
"clean": "rm -rf dist",
|
|
15
15
|
"sync:custom-overlays": "node ./scripts/sync-custom-overlay-types.mjs",
|
|
16
|
+
"sync:custom-code": "node ./scripts/sync-custom-code-docs.mjs",
|
|
16
17
|
"postpublish": "npm cache clean --force && node ./scripts/postpublish-install.mjs"
|
|
17
18
|
},
|
|
18
19
|
"keywords": [],
|