Single module modding
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
A mod's config is its settings: the numbers and switches a server might want different without changing the mod, like
|
||||
how fast a machine works, how far something reaches, or whether a feature is on. The mod lists them with their defaults
|
||||
in `config.json`, a server changes the ones it wants in a file of its own, and the server script reads the result as
|
||||
in `config.json`, a server changes the ones it wants in a file of its own, and the server phase reads the result as
|
||||
`ctx.config`. It's like NeoForge's server configs.
|
||||
|
||||
## `config.json`
|
||||
@@ -26,7 +26,7 @@ can change has to be in this file with its default.
|
||||
|
||||
## Reading It
|
||||
|
||||
`ctx.config` in the server script holds the settings, with the server's changes made:
|
||||
`ctx.config` in the server phase holds the settings, with the server's changes made:
|
||||
|
||||
```ts
|
||||
import type { ServerContext } from "cubi/server";
|
||||
@@ -36,17 +36,17 @@ interface Config {
|
||||
fan: { push_distance: number; pull_distance: number };
|
||||
}
|
||||
|
||||
export function setup(ctx: ServerContext) {
|
||||
export function server(ctx: ServerContext) {
|
||||
const config: Config = ctx.config;
|
||||
ctx.log(`fans push things up to ${config.fan.push_distance} blocks away`);
|
||||
}
|
||||
```
|
||||
|
||||
It's there from `setup` on, and stays the same for as long as the server runs. It's typed `any`, so give it a type of
|
||||
your own like `Config` above.
|
||||
It's there from the server phase on, and stays the same for as long as the server runs. It's typed `any`, so give it a
|
||||
type of your own like `Config` above.
|
||||
|
||||
Only the server script has it. The copy of a mod players download leaves its config out, since a server's settings
|
||||
aren't always the defaults. When players need to see one, the server sends it, like any other
|
||||
Only the server phase has it. The copy of a mod players download leaves its config out, since a server's settings aren't
|
||||
always the defaults. When players need to see one, the server sends it, like any other
|
||||
[server data](../concepts/sides.md#what-each-side-knows): in a block's [client data](../blocks/tiledata.md), an item's
|
||||
`data`, or over a [channel](../networking/index.md#mod-channels).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user