Files
factorio-clusterio/sharedPlugins/inventoryImports/index.js
T
Hornwitser ff3fc3b94b Remove .js suffix in require paths
Remove the .js suffix in require paths to make requires consistent
across the project.
2019-10-28 19:45:34 +01:00

27 lines
870 B
JavaScript

const needle = require("needle");
const isJson = require("./isJson");
const pluginConfig = require("./config");
const functions = require("./interfacingFunctions");
// poll inventories
class inventoryImports {
constructor(slaveConfig, messageInterface){
this.config = slaveConfig;
this.messageInterface = messageInterface;
messageInterface("/silent-command game.print('InventoryImports enabled')");
setInterval(function(){
// messageInterface("Polling inventories\n")
messageInterface(functions.pollInventories(pluginConfig.scriptOutputFileSubscription));
}, 10000);
}
scriptOutput(data){
if(data !== null && isJson(data)){
let inventory = JSON.parse(data);
// process inventory of players and ask master for more stuff
functions.handleInventory(inventory, this.config, this.messageInterface);
}
}
}
module.exports = inventoryImports;