0.1.8 • Published 7 years ago
screeps-js-api v0.1.8
screeps-js-api
This is a nodejs API for the game Screeps based on:
- The work of @ags131 (node-screeps-api)
- And python-screeps
It comes with absolutely no warranty (but I'm opened to pull requests).
Basic usage
const API = require("screeps-js-api");
let api = new API("email", "password");
// Get memory
api.memory.get().then((memory) => console.log(JSON.stringify(memory)));
// Execute console command
api.console.execute("console.log('Hello world!')");
// Push code to "simulation" branch
api.code.push(["file_1.js", "file_2.js", ...]);
// Print console logs every tick
api.on('/console', (data) => console.log(JSON.stringify(data)));
api.console.register();
A few technical details
The api is able to send HTTP requests and to connect to server socket for sending/recieving realtime events in the same way as the game GUI.
- All functions return a promise based on ES6 implementation.
- Api will emit events using NodeJS standard event implementation.
You can check examples in the eponym folder to get started. I don't have a real documentation as of now, but I tried to comment the code so that it should be easy to read and understand. Don't be affraid to look at src/api.js
.
Private servers
Constructor allors a third optional parameter for specifying server address:
const API = require("screeps-js-api");
let api = new API("email", "password", "http://localhost:21025");
API documentation
An API documentation generated by JSDoc is available in /doc.
If you pickup any mistake or inconsistancy, feel free to do a pull request or email me at ryanis.shadowatgmail.com.