LoadSettings, getData(), and constraint names

DrekiOrmur
He/Him

New member
From my testing in Simple-Chat I didn't see any immediate issues, but I was wanting to double check if I'm understanding JS correctly and not setting myself up for a headache I need to rebuild/workaround later.

so in loadSettings, each of the settings I see is being referenced by the 'const groupName'...
But in the later getData() it is instead referencing the ID; 'const groupName = defineSetting('Lorem Ipsum', 'testName', 'group'...

If I make it so the const groupName == id and thus can just copy+paste the loadSettings block into the getData()'s block, are there any issues/implications? Or is it just purely style/preference?

Original :: constraint name / IDModified :: constraint name == ID
slime2.widget.loadSettings('simple-chat-data.js', [
defineSetting(
[
'Simple Chat v3.0.1 by Zaytri: https://zaytri.com/',
'',
'Questions and Support: https://forums.slime2.stream/threads/20/',
].join('\n'),
'title',
'text-display',
),
animationSettings,
badgeSettings,
alignmentSettings,
disappearingSettings,
emoteSettings,
filterSettings,
pronounsSettings,
soundSettings,
textSettings,
])
slime2.widget.loadSettings('simple-chat-data.js', [
defineSetting(
[
'Simple Chat v3.0.1 by Zaytri: https://zaytri.com/',
'',
'Questions and Support: https://forums.slime2.stream/threads/20/',
].join('\n'),
'title',
'text-display',
),
animationSettings,
badgeSettings,
alignmentSettings,
disappearingSettings,
emoteSettings,
filterSettings,
pronounsSettings,
soundSettings,
textSettings,
])
const data = slime2.widget.getData()
const {
alignment,
textStyles,
animations,
disappear,
emotes,
badges,
pronouns,
sound,
} = data
const data = slime2.widget.getData()
const {

animationSettings,
badgeSettings,
alignmentSettings,
disappearingSettings,
emoteSettings,
filterSettings,
pronounsSettings,
soundSettings,
textSettings,
} = data
 

Zaytri
she/her

Glitch Witch
Admin
Developer
Streamer
JavaScript:
animationSettings,
badgeSettings,
alignmentSettings,
disappearingSettings,
emoteSettings,
filterSettings,
pronounsSettings,
soundSettings,
textSettings,

These are just variables that I used to make it easier to see and reorder the setting groups, they could've literally been named anything. Like if you go to the definition of animationSettings, it's just using defineSetting anyway. And yes, you need to use the setting ID to get the related data from getData. You're free to rename the IDs and variables in any way you want, just make sure that the IDs are unique to the group that they're in (the console will show you an error if you make that mistake).

For example, the header text itself could've been a variable itself, like this:
JavaScript:
slime2.widget.loadSettings('simple-chat-data.js', [
  header,
  animationSettings,
  badgeSettings,
  alignmentSettings,
  disappearingSettings,
  emoteSettings,
  filterSettings,
  pronounsSettings,
  soundSettings,
  textSettings,
])

const header = defineSetting(
  [
    'Simple Chat v3.0.1 by Zaytri: https://zaytri.com/',
    '',
    'Questions and Support: https://forums.slime2.stream/threads/20/',
  ].join('\n'),
  'title',
  'text-display',
)
 
Back
Top