Bring in StreamElements and Streamlabs widgets
Import a StreamElements or Streamlabs custom widget, or a .lwidget package, and run it in Lightair with your chat and events, its settings in the Inspector.
In short
- Save the widget's HTML, CSS, JavaScript and fields as files in one folder.
- In the Hierarchy, click +, choose Widgets › Import a widget, and pick the folder or a
.lwidgetfile. - Lightair feeds it your chat and events in the form StreamElements or Streamlabs would, and its fields become settings in the Inspector.
In the appHierarchy › Add object › Widgets › Import a widget
A custom widget you made for StreamElements or Streamlabs, or one you got from someone else, runs in Lightair from its own files. It receives the same kinds of events it did before: chat messages, follows, subs, donations, cheers and raids, from every platform you’ve connected in Lightair.
Get the widget’s files
Section titled “Get the widget’s files”A custom widget is four pieces of code: HTML, CSS, JavaScript and its fields (the settings, as JSON). Put each in a file in one folder of its own:
| Piece | File name |
|---|---|
| HTML | ends in .html or .htm, for example widget.html |
| CSS | ends in .css, for example widget.css |
| JavaScript | ends in .js, for example widget.js |
| Fields | a .json file with “field” in its name, for example fields.json |
In StreamElements’ or Streamlabs’ custom widget editor, copy each tab into its file. Only the HTML or the JavaScript is required; leave out the pieces the widget doesn’t have.
A .lwidget file is the same four files in one zip package. Lightair reads .zip files of them
too.
Import it
Section titled “Import it”- Select the scene, then click + (Add object) at the top of the Hierarchy panel.
- Choose Widgets, then Import a widget under Your own.
- Pick the widget’s folder, or its
.lwidgetfile.
The widget is added to the scene. If Lightair can’t find the code, it says Couldn’t import that widget and why: for example, there’s no HTML or JS file in the folder.
You can also install a .lwidget as a package: drop it on the Lightair window or use File ›
Install Package…. It then appears in the widget list under From packages, ready to add to
any scene. See Packages.
How it runs
Section titled “How it runs”Lightair works out which service a widget was written for from its script: one that listens on
document (onLoad, onEventReceived) is treated as a Streamlabs widget, anything else as a
StreamElements widget. Then it gives the widget what that service would:
- StreamElements widgets get
onWidgetLoadwith their field values and this stream’s recent events,onEventReceivedwith StreamElements’ listener names (message,follower-latest,subscriber-latest,tip-latest,cheer-latest,raid-latest, and message deletions), andonSessionUpdate.SE_API.storekeeps its data in Lightair. jQuery is loaded, as it is on StreamElements. - Streamlabs widgets get
onLoadwith their field values andonEventReceivedwith chat messages and alerts. {{fieldName}}in the HTML, CSS or JavaScript is replaced with the field’s value, as on both services.
Events come from the channels named in your destinations’ Chat fields, and tips from the services connected under Settings › Connections. A widget that talks to StreamElements’ or Streamlabs’ own servers for anything else needs those services as before.
Set it up
Section titled “Set it up”Select the widget. The Inspector shows its fields as settings: text, numbers, colours, choices,
switches, pictures and sounds, and buttons (a button field sends the widget a widget-button
event). Each change reloads the widget with the new values and can be undone.
As with built-in widgets:
- Send a test offers chat messages, a message with emotes, and alerts, if the widget listens for events.
- Placeholder shows samples while you set it up, if the widget listens for events.
- Gets events from chooses the platforms it listens to.
- The link button copies its address, to use it in OBS or a browser on this computer.
See Widgets.
Change its code
Section titled “Change its code”Under CODE, the widget’s HTML, CSS, JS and Fields are in tabs you can edit; the canvas shows changes a moment after you stop typing. The buttons beside the tabs:
- Open its files in a folder: edit them in any editor, and each save shows in Lightair at once.
- Export as a .lwidget package: one file to share or use elsewhere.
- Edit in a large editor: opens the code beside the canvas.
Writing widgets for Lightair itself, with its own event bridge, is covered in Build a widget.