1.0.3-b • Published 3 years ago

fz-api v1.0.3-b

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

FZApi

Asynchronous lib for managing factorio.zone mods, visitsecret, slots.

Basic example

const FZ = require('fz-api').API;

(async function(){
      let fz = new FZ(); 
      await fz.login();
      let RawData = await fz.getRawData(); 
      console.log(RawData);
      process.exit(); 
})();

Methods

Logging in

<FactorioZone>.login()
// returns Promise<void>

Getting raw data of WS

<FactorioZone>.getRawData()
/* returns Promise<{
   logs: any[];
   origins: this;
}> */

Getting slots

<FactorioZone>.getSlots()
// returns Promise<any[]>

Getting options

<FactorioZone>.getOptions()
// returns Promise<any[]>

Getting options

<FactorioZone>.getOptions()
// returns Promise<any[]>

Get client stats

<FactorioZone>.getClientStats()
/* returns Promise<{
   Secret: any;
   VisitSecret: string;
}> */

Get mods

<FactorioZone>.getMods()
/* returns Promise<any[]> */

Get versions

<FactorioZone>.getVersions()
/* returns Promise<any[]> */

Basic example of emitter.

const FZ = require('../index').API
const FZEmitter = require('../index').Emitters

(async function(){
   let fz = new FZ('')
   await fz.login()
   await FZEmitter.on('RawWSMessage', (msg) => {
      let parsed = JSON.parse(msg)
      if (parsed.line === undefined) return
      console.log(`[${new Date().toUTCString()}::MESSAGE] ${parsed.line}`)
   });
})();

Info

<FZEmitter>.on('info')
// Returns String

Raw WS message

<FZEmitter>.on('RawWSMessage')
// Returns String