Skip to content

Settings

Define user-configurable settings that appear in GemShell's UI.

Setting Types

Checkbox

javascript
{
  id: 'enabled',
  type: 'checkbox',
  label: 'Enable feature',
  description: 'Tooltip text shown on hover',
  default: true
}

Text

javascript
{
  id: 'message',
  type: 'text',
  label: 'Message',
  placeholder: 'Enter text...',
  description: 'The message to display',
  default: ''
}

Textarea

javascript
{
  id: 'customCss',
  type: 'textarea',
  label: 'Custom CSS',
  placeholder: '/* Your CSS here */',
  rows: 5,
  default: ''
}

Number

javascript
{
  id: 'port',
  type: 'number',
  label: 'Port',
  min: 1,
  max: 65535,
  step: 1,
  placeholder: '8080',
  default: 8080
}

Slider / Range

javascript
{
  id: 'opacity',
  type: 'slider',  // or 'range'
  label: 'Opacity',
  min: 0,
  max: 100,
  step: 5,
  default: 80
}

Select (Dropdown)

javascript
{
  id: 'position',
  type: 'select',
  label: 'Position',
  options: ['top-left', 'top-right', 'bottom-left', 'bottom-right'],
  default: 'bottom-right'
}

Color

javascript
{
  id: 'color',
  type: 'color',
  label: 'Text color',
  default: '#ffffff'
}

Setting Properties

PropertyTypeRequiredDescription
idstringYesUnique identifier
typestringYesSetting type
labelstringYesDisplay label
defaultanyNoDefault value
descriptionstringNoTooltip text
placeholderstringNoPlaceholder text (text, textarea, number)
minnumberNoMinimum value (number, slider)
maxnumberNoMaximum value (number, slider)
stepnumberNoStep increment (number, slider)
rowsnumberNoNumber of rows (textarea)
optionsstring[]NoOptions list (select)

Accessing Settings

In script.js (Runtime)

javascript
// GEMSHELL_SETTINGS is auto-injected
const { enabled, message, opacity, position, color } = GEMSHELL_SETTINGS;

if (!enabled) return;

const el = document.getElementById('my-element');
el.style.opacity = opacity / 100;
el.style.color = color;

In template.html

html
{{#if enabled}}
<div style="opacity: {{opacity}}%; color: {{color}}">
  {{message}}
</div>
{{/if}}

In Hooks (Build-time)

javascript
onModifyAssets: async (context, settings) => {
  // settings object contains all setting values
  if (settings.enabled) {
    gemshell.log(`Message: ${settings.message}`);
  }
}

Settings Priority

Settings are merged in this order (later overrides earlier):

  1. Plugin defaults - from plugin.js
  2. Global saved settings - user changed in Manage Plugins
  3. Per-game overrides - user changed in Game Settings

Complete Example

javascript
module.exports = {
  name: 'FPS Counter',
  version: '1.0.0',
  inject: ['style.css', 'template.html', 'script.js'],
  
  settings: [
    {
      id: 'enabled',
      type: 'checkbox',
      label: 'Show FPS Counter',
      description: 'Display frames per second in-game',
      default: true
    },
    {
      id: 'position',
      type: 'select',
      label: 'Position',
      description: 'Where to show the counter',
      options: ['top-left', 'top-right', 'bottom-left', 'bottom-right'],
      default: 'top-left'
    },
    {
      id: 'opacity',
      type: 'slider',
      label: 'Opacity',
      min: 20,
      max: 100,
      step: 10,
      default: 80
    },
    {
      id: 'color',
      type: 'color',
      label: 'Text Color',
      default: '#4ade80'
    }
  ]
};