@brisberg/screepsmod-lockstep
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

Lockstep (Screeps Server Mod)

Lockstep will prevents the server from ticking unless a tick is specifically requested. Suitable for unit/integration testing of scripts where you need fine grained control over tick events.

Installation

In your Screeps Server directory:

npm install @brisberg/screepsmod-lockstep

or

yarn add @brisberg/screepsmod-lockstep

Ensure that Screeps automatically added it to your mods.json file.

Usage

From another server mod:

// Respond to server locked event
pubsub.subscribe(pubsub.keys.LOCKSTEP_LOCKED, (gameTime) => {
  console.log(`Server locked at gameTime: ${gameTime}`);
})

pubsub.subscribe(pubsub.keys.TICK_STARTED, () => console.log('Tick!'));

// Request 5 ticks over pubsub
pubsub.publish(pubsub.keys.LOCKSTEP_UNLOCK, 5);

/// Output (logs/engine_main.log)
// Server locked at gameTime: 1
// Tick!
// Tick!
// Tick!
// Tick!
// Tick!
// Server locked at gameTime: 6

Development

Actions

yarn build - Builds the package, emitting .js and .d.ts files
yarn lint - Runs lint over the project source
yarn test - Runs all tests under the src/ directory
yarn publish - Bumps package version and publishes the package to Github Packages

Testing

yarn test

Utilizes a local Screeps private server with the local mod version installed. Inspect server logs in server/logs.

Note: By default, this will fail to authenticate with Steam (causing the backend process to crash and restart). If you need it to test something on the backend for some reason, you can provide your steam web token securely as an environment variable.

Create a file named screeps-testing-env at the project root. Add your secure token like so (no quotes):

// DO NOT COMMIT THIS FILE
// Configure your SteamWebApi key
STEAM_API_KEY = <Your Steam Token>

Toolchain

Uses @brisberg/typescript-pkg as a template for Toolchain configuration.

See that repo for a list of tools, documentation, and upgrade steps.

Readme

Keywords

Package Sidebar

Install

npm i @brisberg/screepsmod-lockstep

Weekly Downloads

0

Version

1.2.0

License

MIT

Unpacked Size

578 kB

Total Files

32

Last publish

Collaborators

  • brisberg