Skip to content

ScriptingSettings

Declared in onLoad, stored by the host, shown in the menu, saved to config.json, and changeable with /bitchos set <script> <setting> <value>.

They are host-stored rather than script-stored for one decisive reason: the value survives the script being edited. Anything living in a script's own variables resets on every reload, which is exactly when you are iterating and least want it.

function onLoad() {
    settings.bool('Alert', true, 'Shout when a bed is close.');
    settings.number('Range', 24, 4, 128, 1, 'How far to look, in blocks.');
    settings.mode('Style', 'Box', ['Box', 'Outline', 'Corners'], 'How to draw it.');
    settings.text('Message', 'bed!', 'What to shout.');
    settings.key('Toggle', 0, 'Bind.');
    settings.multi('Teams', ['Red', 'Blue', 'Green', 'Yellow'], 'Which teams count.');
    settings.color('Colour', 0xFF5BD75B, 'The colour to draw in.');
    settings.button('Open folder', function () { script.openFolder(); });

    settings.group('Advanced');        // everything after this is prefixed in the menu
    settings.bool('Verbose', false);
    settings.group('');                // stop grouping
}

Reading and writing

Two ways; they are the same value:

settings.Range              // 24
settings.get('Range')       // 24
settings.Range = 32;        // clamped to the declared range
settings.set('Range', 32);

Types come back as the JavaScript type you would expect:

declared with reads back as
bool boolean
number number
mode, text string
multi array of the selected options
key number (LWJGL key code)
color the packed 0xAARRGGBB integer

settings.ref('Range') gives the setting object itself (.min, .max, .step, .options, .type) if you need it.

Notes on three of them

color is stored as #AARRGGBB text and read back as a packed integer. The menu has no colour picker, so it renders as an editable hex field: legible, editable, readable in config.json, and settable from /bitchos set.

button is a checkbox underneath: ticking it runs your function and puts it straight back, so it flicks and springs back like a button. The host's setting system has no action type; this is the working version rather than a documented one that does nothing.

group prefixes the setting's menu name with Group ·. Your script still refers to it by the plain name.

Renaming resets

Renaming a group renames the config key, so those settings go back to their defaults once. The same thing happens if you rename a setting.