JCKSDocs
JCKS LibFunkcie

Settings folders and updates

How settings/, editable/ and defaults/ work, what happens on start after an update and how the V1 import is declared.

Every JCKS resource keeps the files a server owner changes in settings/ and editable/ and ships an untouched copy of them in defaults/. On start jcks_lib compares the owner's files with that copy, fills what is missing and reports the rest in the server console and in /jcks, Overview. To update, upload everything except settings/ and editable/. The steps for server owners, the console messages and the special cases are on Updating JCKS scripts.

Layout

Path What it is
settings/ Shared settings, sent to players
settings/server/ Server only settings, never sent
settings/*.json Written by the script at runtime (settings changed in game)
editable/client.lua, editable/server.lua Hooks
defaults/ Copy of settings/ and editable/ of this version plus index.json. Never edit it.

What happens on start

  1. jcks_lib loads defaults/, keeps it aside and starts the real tables empty.
  2. The owner's files load.
  3. Missing settings get their default value. Settings that exist only in the owner's file are reported as no longer used.
  4. Lists owned by the server owner (shops, recipes, zones) are never refilled. New default entries are only listed.
  5. Missing editable functions get the default function, and the console names the file to copy it from.
  6. On the server: the V1 import if needed, a .backup copy of every changed file, a check of the client editable file, then one console block and a report to the bridge.

On the first start of a new version, before any settings load, the script also writes settings/update-backup-<n>.json with every settings, editable and settings/*.json file. The last five are kept.

Nothing is printed when everything matches. If a settings file was overwritten with the defaults by mistake, the console points to <file>.backup. A missing settings file uses its defaults until you copy it back from defaults/.

Rules for settings files

  • A file starts with Config = Config or {} or ServerConfig = ServerConfig or {}, never Config = {}. The load order inside a folder is not fixed. jcks_lib recovers values wiped by Config = {} and tells the owner to fix the line.
  • A file only sets tables it creates itself.
  • Editable files define functions on ClientEditable, ServerEditable or Editable. A function missing in the owner's file runs the default one.

Manifest keys (for developers)

Key What it does
jcks_title Name in the console report
jcks_import 'old > new' V1 file copied into the new layout once. Read from this folder (V2 uploaded over V1) or from another resource with the same manifest name and a lower major version.
jcks_legacy_name Another resource name the old version used, jcks_ui for jcks_lib. Matched without a version check.
jcks_collection A table of entries owned by the server owner. Missing entries are never added back, only listed. * matches one level.
jcks_rename 'old > new' Moves a value whose setting got a new name
jcks_requires 'jcks_lib >= 1.0.0' Lowest version of another JCKS resource, one line per dependency. Checked by jcks_lib at start and by the bridge version check.
jcks_docs 'https://docs.jcksdev.xyz/jobs/v2' Base of the docs links in the console report
jcks_data 'settings/config.json' Extra file for the update backup, for servers that cannot list folders

The manifest loads the files through the update scripts of jcks_lib, in this order:

lua
shared_scripts {
    '@jcks_lib/init.lua',
    '@jcks_lib/update/core.lua',
    'defaults/settings/*.lua',
    '@jcks_lib/update/mark.lua',
    'settings/*.lua',
    '@jcks_lib/update/finish.lua',
}

client_scripts {
    '@jcks_lib/update/begin_side.lua',
    'defaults/editable/client*.lua',
    '@jcks_lib/update/mark_side.lua',
    'editable/client*.lua',
    '@jcks_lib/update/finish_side.lua',
}

server_scripts {
    '@jcks_lib/update/begin_side.lua',
    'defaults/settings/server/*.lua',
    'defaults/editable/server*.lua',
    '@jcks_lib/update/mark_side.lua',
    'settings/server/*.lua',
    'editable/server*.lua',
    '@jcks_lib/update/finish_side.lua',
    '@jcks_lib/update/report.lua',
}

All paths are globs, so a file the owner did not upload is skipped instead of stopping the resource. report.lua goes last in server_scripts. Keep settings/, editable/, defaults/ and locales/ in escrow_ignore so they stay readable. Add 'defaults/locales/*.json' to files so clients can read the texts of this version.