mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-25 08:23:13 +09:00
Fixed inventory combinator
This commit is contained in:
1 parent
201912fdea
commit
f9a0703725
1 file changed
+7
-3
@@ -621,8 +621,11 @@ function instanceManagement() {
|
|||||||
needle.get(config.masterIP + ":" + config.masterPort + '/api/inventory', function (err, response, body) {
|
needle.get(config.masterIP + ":" + config.masterPort + '/api/inventory', function (err, response, body) {
|
||||||
if (response && response.body) {
|
if (response && response.body) {
|
||||||
// Take the inventory we (hopefully) got and turn it into the format LUA accepts
|
// Take the inventory we (hopefully) got and turn it into the format LUA accepts
|
||||||
// console.log(response.body);
|
try {
|
||||||
var inventory = response.body;
|
var inventory = JSON.parse(response.body);
|
||||||
|
} catch (e){
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
var inventoryFrame = {};
|
var inventoryFrame = {};
|
||||||
for (let i = 0; i < inventory.length; i++) {
|
for (let i = 0; i < inventory.length; i++) {
|
||||||
inventoryFrame[inventory[i].name] = Number(inventory[i].count);
|
inventoryFrame[inventory[i].name] = Number(inventory[i].count);
|
||||||
@@ -640,7 +643,8 @@ function instanceManagement() {
|
|||||||
needle.post(config.masterIP + ":" + config.masterPort + '/api/readSignal', {
|
needle.post(config.masterIP + ":" + config.masterPort + '/api/readSignal', {
|
||||||
since: lastSignalCheck
|
since: lastSignalCheck
|
||||||
}, function (err, response, body) {
|
}, function (err, response, body) {
|
||||||
if (response && response.body && typeof response.body == "object" && response.body[0]) {
|
if (response && response.body) {
|
||||||
|
if(typeof response.body == "string") response.body = JSON.parse(response.body);
|
||||||
// Take the new combinator frames and compress them so we can use a single command
|
// Take the new combinator frames and compress them so we can use a single command
|
||||||
let frameset = [];
|
let frameset = [];
|
||||||
for (let i = 0; i < response.body.length; i++) {
|
for (let i = 0; i < response.body.length; i++) {
|
||||||
|
|||||||
Reference in new issue
Block a user