Skip to content

script properties_us

Tki_sor edited this page Nov 12, 2026 · 1 revision

English · 中文

Script properties

Script properties are special comments at the start of a script file. They control how that file loads: its order, whether it loads at all, and which mods it needs.

Syntax

Each property takes one line in the form // name: value:

// priority: 100
// modloaded: create, jei
// after: lib/init.js

console.info('hello')

Properties must be at the very start of the file. NekoJS reads from the first line down and stops at the first line that is neither a // comment nor blank. So:

  • Blank lines and ordinary // comments may appear between properties.
  • Properties after an import, a /* */ block comment or any code are not read.

A property in the wrong place, or a misspelled name such as priorty, produces no error. The property just has no effect. If the load order is wrong or disable does nothing, check these two things first.

After changing properties, reload that script type (for example /nekojs reload). Startup scripts need a game restart.

All properties

Property Value Default Effect
priority Integer 0 Higher numbers load first
after Comma-separated paths None Load after the listed files
modloaded Comma-separated mod IDs None Load only when all listed mods are present
disable Anything, may be empty Not disabled Do not load this file

priority: load order

// priority: 1000

Higher numbers load first. Negative numbers are allowed. Use it on "library" scripts that set up shared data so they run before everything else.

Startup scripts run in the same order, so registrations in a higher-priority startup script also happen first.

The value must be a single integer. Adding a note after it, as in // priority: 10 load early, makes the line invalid; put notes on their own line. An invalid value logs a NEKO-1025 warning with the file and line number, and that line is ignored.

after: load after specific files

// after: lib/init.js, lib/constants.js

Path forms:

Form Meaning
lib/init.js Relative to this script type's root, for example server_scripts/lib/init.js
./helper.js Relative to the current file's folder
lib/* Every file in the lib/ folder
server/lib/init.js Prefixed with the script type name (startup, server, client, test); same as lib/init.js
nekojs:server/lib/init.js Same again, with a nekojs: prefix

Separate several paths with commas. Backslashes \ are treated as /.

after only works between files with the same priority. When two files have different priorities, the higher priority always loads first and after is ignored silently, with nothing in the log. So if after has no effect and the log is clean, the most likely cause is that the two files have different priorities.

References to a file skipped by disable or modloaded are also ignored silently.

When a path matches no file, the log shows a NEKO-1004 warning. When several files after each other in a loop, NEKO-1004 is reported too, and those files fall back to path order.

modloaded: load only when mods are present

// modloaded: create, jei

The file loads only when create and jei are both installed. Use it for integration scripts: without the mod, the script is skipped instead of failing.

Use mod IDs, not display names. You can find a mod's ID in the mod list.

disable: turn a file off

// disable:

If the file starts with a disable line, it does not load. The text after the colon does not matter: // disable: false also disables the file, so you can use it for a reason. To enable the file again, delete the line.

How load order is decided

Scripts of one type load in this order:

  1. By priority, highest first.
  2. Among files with the same priority, after adjusts the order.
  3. Everything else in alphabetical path order.

A simple approach: use priority to split files into batches, and after to order files inside a batch.

// priority: 500
// modloaded: create
// after: lib/init.js

// This file:
// 1. Loads before files with the default priority 0
// 2. Loads only when Create is installed
// 3. Loads after lib/init.js if that file also has priority 500

console.info('Create integration initialized')

Notes

  • Python scripts do not support script properties. # priority: in a .py file is not read. See Python scripts.
  • Script packs have their own dependency order. A pack's declared prerequisites always load first; a higher priority cannot change that. See Script packs.
  • Plugins can register new script properties. See Plugin development.

See also: Script basics and Module system (splitting code with require / import).


Previous: Script API conventions · Contents · Next: Global bindings

NekoJS Wiki

中文 · English

先看这里 / Start here

  • 首页 / Home · 中文 · EN
  • 平台与兼容性 / Platforms and compatibility · 中文 · EN
  • 快速开始 / Quick start · 中文 · EN
  • 配置参考 / Configuration · 中文 · EN
  • 常见问题 / FAQ · 中文 · EN

脚本作者 / Script authors

  • 脚本基础 / Script basics · 中文 · EN
  • 脚本 API 约定 / Script API conventions · 中文 · EN
  • 脚本属性 / Script properties · 中文 · EN
  • 全局绑定 / Global bindings · 中文 · EN
  • 数据、状态与持久化 / Data, state and persistence · 中文 · EN
  • Python 脚本 / Python scripts · 中文 · EN
  • Python 特性清单 / Python feature support · 中文 · EN
  • 事件参考 / Event reference · 中文 · EN
  • AI 辅助脚本编写 / AI-assisted authoring · 中文 · EN
  • 命令 / Commands · 中文 · EN
  • 错误与日志参考 / Error and log reference · 中文 · EN
  • 客户端绘制与后处理 / Client rendering and post effects · 中文 · EN

整合包作者 / Modpack authors

  • 版本化脚本包 / Versioned script packs · 中文 · EN
  • 配方系统 / Recipe system · 中文 · EN
  • 注册新内容 / Registering new content · 中文 · EN
  • 模块系统 / Module system · 中文 · EN
  • TypeScript 与 JSX / TypeScript and JSX · 中文 · EN
  • JSX 客户端 UI / JSX client UI · 中文 · EN
  • MixinJS(实验性) / MixinJS (experimental) · 中文 · EN
  • Node.js 兼容 / Node.js compatibility · 中文 · EN

插件开发者 / Plugin developers

  • 插件开发 / Plugin development · 中文 · EN
  • 类型适配器 / Type adapters · 中文 · EN
  • 事件扩展 / Event extensions · 中文 · EN
  • 注解体系 / Annotations · 中文 · EN

项目贡献者 / Project contributors

  • 项目架构 / Project architecture · 中文 · EN
  • Probe 类型生成 / Probe type generation · 中文 · EN
  • 构建系统 / Build system · 中文 · EN

Clone this wiki locally