StreamElements / widgets

279 stars 118 forks source link

Modify persistent DATA of the widget from JS #41

Open KarhellTwitch opened 1 year ago

KarhellTwitch commented 1 year ago

Hello, I'm actualy writing a widget i want to be customisable from Twitch chat with commands. Everything works fine (command catches, persmissions,...) But i'm facing a problem. I didn't find a way to modify widget fields data from JS (DATA tab from JS tab in editor) Exemple of what i'm trying to do:

I know JS doesn't support passing parameters by ref, so modify "obj" received will change nothing, am i right ? Each time i'll reload widget, previous data stored in DATA will be back. Is there a way to bypass my problem ? Thx !

c4ldas commented 1 year ago

You cannot change the value of DATA tab with JS. But if you just want to work with persistent data, you could use SE_API, which gives access to a database you can store key/value. You have the store.set and store.get to work on. The values are accessible from any widget, even if in a different overlay.

You can have a look at it here:

https://github.com/StreamElements/api-docs/blob/main/docs/Widgets.md#se-api