mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-13 15:14:52 +09:00
Remove the .js suffix in require paths to make requires consistent across the project.
27 lines
870 B
JavaScript
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; |