WorldResource

A world export: a JSON file, `<name>.world.json`, of content the server spawns once after resources have started, through the same APIs a script uses. List the files in the KCDS_WORLD_RESOURCES environment variable, separated like PATH. Exports belong to the server and last until it shuts down, and worldResourcesReady fires when all have loaded. The format is { level, props: [{ model, position, rotation, scale, physics, dimension }], effects: [{ effect, position, ...Vfx options }], lights: [{ position, color, intensity, radius, castShadows }], world: [LevelEdit definitions], areas: [Area.create definitions], patrolRoutes: [PatrolRoute.create definitions] }. All lists are optional, and a file with an error adds nothing.

worldResource.ready

ready

Whether all listed exports have loaded.

worldResource.all()

WorldResource.all()

All loaded exports.

worldResource.find()

WorldResource.find(name)

The export with this name, the file name without .world.json, or null.

worldResource.record

record

The export's raw record as loaded, or null.

worldResource.name

name

The export's name.

worldResource.path

path

The file it came from.

worldResource.level

level

The level it was made in.

worldResource.loaded

loaded

Whether it is loaded.

worldResource.props

props

Props it spawned that still exist, in file order.

worldResource.effects

effects

Effects it spawned that still exist.

worldResource.lights

lights

Lights it spawned that still exist.

worldResource.levelEdits

levelEdits

Its level edits still applied.

worldResource.items

items

Ground items from it that are still there, in file order. Its items list has { item, position, rotation?, amount?, name?, quality?, health?, condition?, dimension? }, working like GroundItem.spawn.

worldResource.doors

doors

Doors it created that still exist, in file order. Its doors list uses Door.spawn definitions, { model, position, rotation?, name?, locked?, lock?, canBePicked?, lockLevel?, lockKey? }, plus dimension?. The server owns them, so they last until shutdown. Level doors it removed appear in levelEdits and Door.removed instead.

worldResource.smartObjects

smartObjects

Smart objects it created that still exist, in file order. Its smartObjects list has { blueprint, position, rotation?, name?, dimension? }, working like SmartObject.spawn. Dice tables and crafting stations behave like the level's. Level stations it removed appear in levelEdits instead.

worldResource.areas

areas

Its areas that still exist.

worldResource.patrolRoutes

patrolRoutes

Its patrol routes that still exist.