Repository navigation
script properties_us
English · 中文
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.
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.
| 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: 1000Higher 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: lib/init.js, lib/constants.jsPath 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: create, jeiThe 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: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.
Scripts of one type load in this order:
- By
priority, highest first. - Among files with the same priority,
afteradjusts the order. - 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')-
Python scripts do not support script properties.
# priority:in a.pyfile 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
- 首页 / Home · 中文 · EN
- 平台与兼容性 / Platforms and compatibility · 中文 · EN
- 快速开始 / Quick start · 中文 · EN
- 配置参考 / Configuration · 中文 · EN
- 常见问题 / FAQ · 中文 · EN
- 脚本基础 / 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
- 版本化脚本包 / 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