Get unlimited public & private packages + team-based management with npm Teams.Learn more »

screeps-interface

3.3.2 • Public • Published

Usage

const api = new (require('screeps-interface'))(config)
 
//promises for all endpoints
api.me()
    .then(info=> console.log(info))
    .catch(err=> console.log(err))
 
//get, set
api.code('branch')
    .then(data=> console.log(data.branch, data.modules))
api.code('branch', {'main.js': 'stringified code'})
    .then(res=> console.log('uploaded code successfully')
 
//set console
api.console('shard0', 'console.log("test")')
    .then(res=> console.log(res))
 
//get all, get specific, set all
api.memory('shard0')
    .then(data=> console.log(data.data))
api.memory('shard0', 'creeps')
    .then(data=> console.log(data.data))
api.memory('shard0', undefined, {hi: 'everything is gone now'})
    .then(res=> console.log(res))
 
api.segment('shard0')
    .then(data=> console.log(data.data))
api.segment('shard0', 0, 'abc')
    .then(res=> console.log(res))
        
//socket listening
api.sub('console', msgs=>{
    console.log(msgs)
}).catch(e=>{throw e})
api.sub('cpu', cpu=>{
    console.log(cpu)
}).catch(e=>{throw e})
api.unsub({type: 'console'}).catch(e=>{throw e})
api.disconnect() // cleans up, also promise

See wiki for details.

Configuration

{
    "username": "will be undefined if not filled. Used for private servers only",
    "password": "will be undefined if not filled. Used for private servers only",
    "token": "authentication token. Public server only",
    "private": false,
    "protocol": "https or http (public or private respectively). You can override by filling it",
    "url": "screeps.com or 127.0.0.1 (public or private respectively). You can override by filling it",
    "port": "443 or 21025 (public or private respectively). You can override by filling it"
}

Private denotes private server. Private servers need an auth mod, like auth. If false will connect to normal/public screeps server using the token, which can be obtained on the official screeps website here.

Install

npm i screeps-interface

DownloadsWeekly Downloads

20

Version

3.3.2

License

ISC

Unpacked Size

23.1 kB

Total Files

33

Last publish

Collaborators

  • avatar