From 7b44e830f8605c874ed889ec91240b23b468c792 Mon Sep 17 00:00:00 2001 From: Thomas Deal Date: Wed, 19 Oct 2016 16:52:55 -0400 Subject: [PATCH 1/9] Write files only to the server by default, changeable via setFilePlayer() --- clusterio_0.0.2/control.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/clusterio_0.0.2/control.lua b/clusterio_0.0.2/control.lua index 4152db57..b72950db 100644 --- a/clusterio_0.0.2/control.lua +++ b/clusterio_0.0.2/control.lua @@ -283,7 +283,7 @@ function ExportInputList() --only write to file once as i/o is slow --it's much faster to concatenate all the lines with table.concat --instead of doing it with the .. operator - game.write_file(OUTPUT_FILE, table.concat(exportStrings), true) + game.write_file(OUTPUT_FILE, table.concat(exportStrings), true, global.write_file_player or 0) end end @@ -298,7 +298,7 @@ function ExportOutputList() --only write to file once as i/o is slow --it's much faster to concatenate all the lines with table.concat --instead of doing it with the .. operator - game.write_file(ORDER_FILE, table.concat(exportStrings), true) + game.write_file(ORDER_FILE, table.concat(exportStrings), true, global.write_file_player or 0) end end @@ -393,7 +393,7 @@ function HandleTXCombinators() if #frame > 0 then table.insert(frame,{count=game.tick,name="signal-srctick",type="virtual"}) - game.write_file(TX_BUFFER_FILE, json:encode(frame).."\n", true) + game.write_file(TX_BUFFER_FILE, json:encode(frame).."\n", true, global.write_file_player or 0) -- Loopback for testing --AddFrameToRXBuffer(frame) @@ -465,4 +465,7 @@ remote.add_interface("clusterio", end return buffer end, + setFilePlayer = function(i) + global.write_file_player = i + end }) From 09feb085ef2af5971120f2a1412f875ebc4c8417 Mon Sep 17 00:00:00 2001 From: Thomas Deal Date: Wed, 19 Oct 2016 16:54:54 -0400 Subject: [PATCH 2/9] Spelling fix --- clusterio_0.0.2/config.lua | 4 ++-- clusterio_0.0.2/control.lua | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/clusterio_0.0.2/config.lua b/clusterio_0.0.2/config.lua index e1007a8a..9d743b49 100644 --- a/clusterio_0.0.2/config.lua +++ b/clusterio_0.0.2/config.lua @@ -28,5 +28,5 @@ ORDER_FILE = "orders.txt" TX_BUFFER_FILE = "txbuffer.txt" -UPATE_RATE = 60 -CIRCUIT_UPATE_RATE = 5 +UPDATE_RATE = 60 +CIRCUIT_UPDATE_RATE = 5 diff --git a/clusterio_0.0.2/control.lua b/clusterio_0.0.2/control.lua index b72950db..a34c4474 100644 --- a/clusterio_0.0.2/control.lua +++ b/clusterio_0.0.2/control.lua @@ -104,7 +104,7 @@ script.on_event(defines.events.on_tick, function(event) -- TX Combinators must run every tick to catch single pulses HandleTXCombinators() - local todo = game.tick % UPATE_RATE + local todo = game.tick % UPDATE_RATE local onlinePlayers = GetOnlinePlayerCount() @@ -127,7 +127,7 @@ script.on_event(defines.events.on_tick, function(event) ExportOutputList() end - local rxstate = game.tick % CIRCUIT_UPATE_RATE + local rxstate = game.tick % CIRCUIT_UPDATE_RATE -- RX Combinators are set and then cleared on sequential ticks to create pulses if rxstate == 0 then SetRXCombinators() From 5e65fa5208a278d60c2004561ba76a99f0c5722c Mon Sep 17 00:00:00 2001 From: Thomas Deal Date: Wed, 19 Oct 2016 20:11:54 -0400 Subject: [PATCH 3/9] Add Inventory Combinator which reports the last inventory reported by the external code. --- clusterio_0.0.2/config.lua | 2 +- clusterio_0.0.2/control.lua | 39 +++++++++++++++++++++++++++++++++++-- clusterio_0.0.2/data.lua | 31 +++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 3 deletions(-) diff --git a/clusterio_0.0.2/config.lua b/clusterio_0.0.2/config.lua index 9d743b49..9034df28 100644 --- a/clusterio_0.0.2/config.lua +++ b/clusterio_0.0.2/config.lua @@ -21,7 +21,7 @@ OUTPUT_TANK_ICON_PATH = nil MAX_RX_BUFFER_SIZE = 40 -- slightly more than one second RX_COMBINATOR_NAME = "get-combinator" TX_COMBINATOR_NAME = "put-combinator" - +INV_COMBINATOR_NAME = "inventory-combinator" OUTPUT_FILE = "output.txt" ORDER_FILE = "orders.txt" diff --git a/clusterio_0.0.2/control.lua b/clusterio_0.0.2/control.lua index a34c4474..6e2703f3 100644 --- a/clusterio_0.0.2/control.lua +++ b/clusterio_0.0.2/control.lua @@ -47,6 +47,9 @@ function AddEntity(entity) table.insert(global.txControls, entity.get_or_create_control_behavior()) elseif entity.name == RX_COMBINATOR_NAME then table.insert(global.rxControls, entity.get_or_create_control_behavior()) + entity.operable=false + elseif entity.name == INV_COMBINATOR_NAME then + table.insert(global.invControls, entity.get_or_create_control_behavior()) entity.operable=false end end @@ -90,7 +93,7 @@ end) script.on_event(defines.events.on_tick, function(event) - + global.inputChests = global.inputChests or {} global.outputChests = global.outputChests or {} global.inputTanks = global.inputTanks or {} @@ -99,7 +102,7 @@ script.on_event(defines.events.on_tick, function(event) global.inputList = global.inputList or {} global.rxControls = global.rxControls or {} global.txControls = global.txControls or {} - + global.invControls = global.invControls or {} -- TX Combinators must run every tick to catch single pulses HandleTXCombinators() @@ -429,6 +432,32 @@ function ClearRXCombinators() end end +function UpdateInvCombinators() + -- Update all inventory Combinators + -- Prepare a frame from the last inventory report, plus any virtuals + local invframe = { + --TODO: virtual signals here, localid, possibly others + } + local items = game.item_prototypes + if global.invdata then + for name,count in pairs(invdata) do + if items[name] then + invframe[#invframe+1] = {count=count,index=#invframe+1,signal={name=name,type="item"}} + end + end + end + + for i,invControl in pairs(global.invControls) do + if invControl.valid then + invControl.parameters={parameters=invframe} + invControl.enabled=true + else + table.remove(global.invControls,i) + end + end + +end + --[[ Remote Thing ]]-- remote.add_interface("clusterio", { @@ -468,4 +497,10 @@ remote.add_interface("clusterio", setFilePlayer = function(i) global.write_file_player = i end + receiveInventory = function(jsoninvdata) + local invdata = json:decode(jsoninvdata) + -- invdata = {["iron-plates"]=1234,["copper-plates"]=5678,...} + global.invdata = invdata + UpdateInvCombinators() + end }) diff --git a/clusterio_0.0.2/data.lua b/clusterio_0.0.2/data.lua index 6a3fb83a..958c51e8 100644 --- a/clusterio_0.0.2/data.lua +++ b/clusterio_0.0.2/data.lua @@ -238,4 +238,35 @@ data:extend{ result = RX_COMBINATOR_NAME, requester_paste_multiplier = 1 }, + +-- Inventory Combinator +local inv = table.deepcopy(data.raw["constant-combinator"]["constant-combinator"]) +inv.name = INV_COMBINATOR_NAME +inv.minable.result = INV_COMBINATOR_NAME +inv.item_slot_count = 100 +data:extend{ + inv, + { + type = "item", + name = INV_COMBINATOR_NAME, + icon = inv.icon, + flags = {"goes-to-quickbar"}, + subgroup = "storage", + place_result=INV_COMBINATOR_NAME, + order = "a[items]-b["..INV_COMBINATOR_NAME.."]", + stack_size = 50, + }, + { + type = "recipe", + name = INV_COMBINATOR_NAME, + enabled = true, -- TODO do this on a tech somewhere + ingredients = + { + {"constant-combinator", 1}, + {"electronic-circuit", 3}, + {"advanced-circuit", 1} + }, + result = INV_COMBINATOR_NAME, + requester_paste_multiplier = 1 + }, } From 67e192a78f3231f43c16a85e3f561475652a6e3b Mon Sep 17 00:00:00 2001 From: Thomas Deal Date: Wed, 19 Oct 2016 20:41:10 -0400 Subject: [PATCH 4/9] More consistent handling of creation/destruction of entities. Uses entity.unit_number instead of HashPosition. Rebuilds all tables on initial install and on mod version bump. --- .../config.lua | 0 .../control.lua | 81 +++++++++--------- {clusterio_0.0.2 => clusterio_0.0.3}/data.lua | 0 .../graphics/icons/none.png | Bin .../info.json | 2 +- {clusterio_0.0.2 => clusterio_0.0.3}/json.lua | 0 .../locale/en/item-names.cfg | 0 7 files changed, 40 insertions(+), 43 deletions(-) rename {clusterio_0.0.2 => clusterio_0.0.3}/config.lua (100%) rename {clusterio_0.0.2 => clusterio_0.0.3}/control.lua (88%) rename {clusterio_0.0.2 => clusterio_0.0.3}/data.lua (100%) rename {clusterio_0.0.2 => clusterio_0.0.3}/graphics/icons/none.png (100%) rename {clusterio_0.0.2 => clusterio_0.0.3}/info.json (93%) rename {clusterio_0.0.2 => clusterio_0.0.3}/json.lua (100%) rename {clusterio_0.0.2 => clusterio_0.0.3}/locale/en/item-names.cfg (100%) diff --git a/clusterio_0.0.2/config.lua b/clusterio_0.0.3/config.lua similarity index 100% rename from clusterio_0.0.2/config.lua rename to clusterio_0.0.3/config.lua diff --git a/clusterio_0.0.2/control.lua b/clusterio_0.0.3/control.lua similarity index 88% rename from clusterio_0.0.2/control.lua rename to clusterio_0.0.3/control.lua index 6e2703f3..a317f9f0 100644 --- a/clusterio_0.0.2/control.lua +++ b/clusterio_0.0.3/control.lua @@ -1,10 +1,6 @@ require("config") local json = require("json") -function HashPosition(position) - return 40000 * (position.y) + position.x -end - function OnBuiltEntity(event) local entity = event.created_entity --only add entities that are not ghosts @@ -27,29 +23,25 @@ end function AddEntity(entity) if entity.name == INPUT_CHEST_NAME then - global.inputChests = global.inputChests or {} --add the chests to a lists if these chests so they can be interated over - global.inputChests[HashPosition(entity.position)] = entity + global.inputChests[entity.unit_number] = entity elseif entity.name == OUTPUT_CHEST_NAME then - global.outputChests = global.outputChests or {} --add the chests to a lists if these chests so they can be interated over - global.outputChests[HashPosition(entity.position)] = entity + global.outputChests[entity.unit_number] = entity elseif entity.name == INPUT_TANK_NAME then - global.inputTanks = global.inputTanks or {} --add the chests to a lists if these chests so they can be interated over - global.inputTanks[HashPosition(entity.position)] = entity + global.inputTanks[entity.unit_number] = entity elseif entity.name == OUTPUT_TANK_NAME then - global.outputTanks = global.outputTanks or {} --add the chests to a lists if these chests so they can be interated over - global.outputTanks[HashPosition(entity.position)] = entity + global.outputTanks[entity.unit_number] = entity entity.active = false elseif entity.name == TX_COMBINATOR_NAME then - table.insert(global.txControls, entity.get_or_create_control_behavior()) + global.txControls[entity.unit_number] = entity.get_or_create_control_behavior() elseif entity.name == RX_COMBINATOR_NAME then - table.insert(global.rxControls, entity.get_or_create_control_behavior()) + global.rxControls[entity.unit_number] = entity.get_or_create_control_behavior() entity.operable=false elseif entity.name == INV_COMBINATOR_NAME then - table.insert(global.invControls, entity.get_or_create_control_behavior()) + global.invControls[entity.unit_number] = entity.get_or_create_control_behavior()) entity.operable=false end end @@ -59,14 +51,20 @@ function OnKilledEntity(event) if entity.type ~= "entity-ghost" then --remove the entities from the tables as they are dead if entity.name == INPUT_CHEST_NAME then - global.inputChests[HashPosition(entity.position)] = nil + global.inputChests[entity.unit_number] = nil elseif entity.name == OUTPUT_CHEST_NAME then - global.outputChests[HashPosition(entity.position)] = nil + global.outputChests[entity.unit_number] = nil elseif entity.name == INPUT_TANK_NAME then - global.inputTanks[HashPosition(entity.position)] = nil + global.inputTanks[entity.unit_number] = nil elseif entity.name == OUTPUT_TANK_NAME then - global.outputTanks[HashPosition(entity.position)] = nil - end + global.outputTanks[entity.unit_number] = nil + elseif entity.name == TX_COMBINATOR_NAME then + global.txControls[entity.unit_number] = nil + elseif entity.name == RX_COMBINATOR_NAME then + global.rxControls[entity.unit_number] = nil + elseif entity.name == INV_COMBINATOR_NAME then + global.invControls[entity.unit_number] = nil + end end end @@ -92,18 +90,17 @@ script.on_event(defines.events.on_preplayer_mined_item, function(event) end) -script.on_event(defines.events.on_tick, function(event) - - global.inputChests = global.inputChests or {} - global.outputChests = global.outputChests or {} - global.inputTanks = global.inputTanks or {} - global.outputTanks = global.outputTanks or {} - global.outputList = global.outputList or {} - global.inputList = global.inputList or {} - global.rxControls = global.rxControls or {} - global.txControls = global.txControls or {} - global.invControls = global.invControls or {} +script.on_init(function() + Reset() +end) +script.on_configuration_changed(function(data) + if data.mod_changes and data.mod_changes["clusterio"] then + Reset() + end +end) + +script.on_event(defines.events.on_tick, function(event) -- TX Combinators must run every tick to catch single pulses HandleTXCombinators() @@ -156,13 +153,23 @@ function Reset() global.inputChests = {} global.outputChests = {} - global.inputTanks = {} + + global.inputTanks = {} global.outputTanks = {} + global.rxControls = {} + global.txControls = {} + global.invControls = {} + AddAllEntitiesOfName(INPUT_CHEST_NAME) AddAllEntitiesOfName(OUTPUT_CHEST_NAME) + AddAllEntitiesOfName(INPUT_TANK_NAME) AddAllEntitiesOfName(OUTPUT_TANK_NAME) + + AddAllEntitiesOfName(RX_COMBINATOR_NAME) + AddAllEntitiesOfName(TX_COMBINATOR_NAME) + AddAllEntitiesOfName(INV_COMBINATOR_NAME) game.print("reset") end @@ -307,7 +314,6 @@ end function RequestItemsFromStorage(itemName, itemCount) - global.itemStorage = global.itemStorage or {} --if result is nil then there is no items in storage --which means that no items can be given if global.itemStorage[itemName] == nil then @@ -322,7 +328,6 @@ function RequestItemsFromStorage(itemName, itemCount) end function GiveItemsToStorage(itemName, itemCount) - global.itemStorage = global.itemStorage or {} --if this is called for the first time for an item then the result --is nil. if that's the case then set the result to 0 so it can --be used in arithmetic operations @@ -382,8 +387,6 @@ function HandleTXCombinators() (signals[signal.signal.type][signal.signal.name] or 0) + signal.count end end - else - table.remove(global.txControls,i) end end @@ -412,8 +415,6 @@ function SetRXCombinators() if rxControl.valid then rxControl.parameters={parameters=frame} rxControl.enabled=true - else - table.remove(global.rxControls,i) end end end @@ -426,8 +427,6 @@ function ClearRXCombinators() for i,rxControl in pairs(global.rxControls) do if rxControl.valid then rxControl.enabled=false - else - table.remove(global.rxControls,i) end end end @@ -451,8 +450,6 @@ function UpdateInvCombinators() if invControl.valid then invControl.parameters={parameters=invframe} invControl.enabled=true - else - table.remove(global.invControls,i) end end diff --git a/clusterio_0.0.2/data.lua b/clusterio_0.0.3/data.lua similarity index 100% rename from clusterio_0.0.2/data.lua rename to clusterio_0.0.3/data.lua diff --git a/clusterio_0.0.2/graphics/icons/none.png b/clusterio_0.0.3/graphics/icons/none.png similarity index 100% rename from clusterio_0.0.2/graphics/icons/none.png rename to clusterio_0.0.3/graphics/icons/none.png diff --git a/clusterio_0.0.2/info.json b/clusterio_0.0.3/info.json similarity index 93% rename from clusterio_0.0.2/info.json rename to clusterio_0.0.3/info.json index e9a8572e..08fd900d 100644 --- a/clusterio_0.0.2/info.json +++ b/clusterio_0.0.3/info.json @@ -2,7 +2,7 @@ { "name": "clusterio", "title": "Clusterio", -"version": "0.0.2", +"version": "0.0.3", "date": "19-08-2016", "author": "Danielv123 & Keyboardhack & justarandomgeek", "dependencies": ["base >= 0.13"], diff --git a/clusterio_0.0.2/json.lua b/clusterio_0.0.3/json.lua similarity index 100% rename from clusterio_0.0.2/json.lua rename to clusterio_0.0.3/json.lua diff --git a/clusterio_0.0.2/locale/en/item-names.cfg b/clusterio_0.0.3/locale/en/item-names.cfg similarity index 100% rename from clusterio_0.0.2/locale/en/item-names.cfg rename to clusterio_0.0.3/locale/en/item-names.cfg From 16ec26984aaa2352d4b5381914ff3b61345e406f Mon Sep 17 00:00:00 2001 From: Thomas Deal Date: Wed, 19 Oct 2016 21:20:12 -0400 Subject: [PATCH 5/9] Typo Fixes, Uncomment virtual signals. --- clusterio_0.0.3/control.lua | 8 ++++---- clusterio_0.0.3/data.lua | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/clusterio_0.0.3/control.lua b/clusterio_0.0.3/control.lua index a317f9f0..27dba7e0 100644 --- a/clusterio_0.0.3/control.lua +++ b/clusterio_0.0.3/control.lua @@ -41,7 +41,7 @@ function AddEntity(entity) global.rxControls[entity.unit_number] = entity.get_or_create_control_behavior() entity.operable=false elseif entity.name == INV_COMBINATOR_NAME then - global.invControls[entity.unit_number] = entity.get_or_create_control_behavior()) + global.invControls[entity.unit_number] = entity.get_or_create_control_behavior() entity.operable=false end end @@ -439,7 +439,7 @@ function UpdateInvCombinators() } local items = game.item_prototypes if global.invdata then - for name,count in pairs(invdata) do + for name,count in pairs(global.invdata) do if items[name] then invframe[#invframe+1] = {count=count,index=#invframe+1,signal={name=name,type="item"}} end @@ -493,11 +493,11 @@ remote.add_interface("clusterio", end, setFilePlayer = function(i) global.write_file_player = i - end + end, receiveInventory = function(jsoninvdata) local invdata = json:decode(jsoninvdata) -- invdata = {["iron-plates"]=1234,["copper-plates"]=5678,...} global.invdata = invdata UpdateInvCombinators() - end + end, }) diff --git a/clusterio_0.0.3/data.lua b/clusterio_0.0.3/data.lua index 958c51e8..6d09fc41 100644 --- a/clusterio_0.0.3/data.lua +++ b/clusterio_0.0.3/data.lua @@ -161,20 +161,20 @@ data:extend{ subgroup = "virtual-signal-clusterio", order = "e[clusterio]-[1srctick]" }, - --[[{ + { type = "virtual-signal", name = "signal-srcid", icon = "__base__/graphics/icons/signal/signal_grey.png", subgroup = "virtual-signal-clusterio", order = "e[clusterio]-[2srcid]" - },]] - --[[{ + }, + { type = "virtual-signal", name = "signal-localid", icon = "__base__/graphics/icons/signal/signal_grey.png", subgroup = "virtual-signal-clusterio", order = "e[clusterio]-[3localid]" - },]] + }, } -- TX Combinator @@ -238,7 +238,7 @@ data:extend{ result = RX_COMBINATOR_NAME, requester_paste_multiplier = 1 }, - +} -- Inventory Combinator local inv = table.deepcopy(data.raw["constant-combinator"]["constant-combinator"]) inv.name = INV_COMBINATOR_NAME From bf2d16669d26f7c4455901b2d756130d0c542b22 Mon Sep 17 00:00:00 2001 From: Thomas Deal Date: Wed, 19 Oct 2016 21:42:09 -0400 Subject: [PATCH 6/9] Support setting world ID, and if set, output it on the Inventory Combinator, and include it in transmitted frames. --- clusterio_0.0.3/control.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/clusterio_0.0.3/control.lua b/clusterio_0.0.3/control.lua index 27dba7e0..7123317d 100644 --- a/clusterio_0.0.3/control.lua +++ b/clusterio_0.0.3/control.lua @@ -398,6 +398,9 @@ function HandleTXCombinators() end if #frame > 0 then + if global.worldID then + table.insert(frame,1,{count=global.worldID,name="signal-srcid",type="virtual"}) + end table.insert(frame,{count=game.tick,name="signal-srctick",type="virtual"}) game.write_file(TX_BUFFER_FILE, json:encode(frame).."\n", true, global.write_file_player or 0) @@ -434,8 +437,11 @@ end function UpdateInvCombinators() -- Update all inventory Combinators -- Prepare a frame from the last inventory report, plus any virtuals - local invframe = { - --TODO: virtual signals here, localid, possibly others + local invframe = {} + if global.worldID then + table.insert(invframe,{count=global.worldID,index=#invframe+1,signal={name="signal-localid",type="virtual"}}) + end + } local items = game.item_prototypes if global.invdata then @@ -500,4 +506,8 @@ remote.add_interface("clusterio", global.invdata = invdata UpdateInvCombinators() end, + setWorldID = function(newid) + global.worldID = newid + UpdateInvCombinators() + end }) From cc65d8c3c26efd716d9e5780e0040b9c1a5d7255 Mon Sep 17 00:00:00 2001 From: Thomas Deal Date: Wed, 19 Oct 2016 21:45:10 -0400 Subject: [PATCH 7/9] Locale updates --- clusterio_0.0.3/locale/en/item-names.cfg | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/clusterio_0.0.3/locale/en/item-names.cfg b/clusterio_0.0.3/locale/en/item-names.cfg index 08399bce..d7561293 100644 --- a/clusterio_0.0.3/locale/en/item-names.cfg +++ b/clusterio_0.0.3/locale/en/item-names.cfg @@ -5,6 +5,7 @@ put-tank=Put tank get-tank=Get tank put-combinator=Transmit combinator get-combinator=Receive combinator +inventory-combinator=Inventory combinator [item-name] put-chest=Put chest @@ -13,3 +14,9 @@ put-tank=Put tank get-tank=Get tank put-combinator=Transmit combinator get-combinator=Receive combinator +inventory-combinator=Inventory combinator + +[virtual-signal-name] +signal-srctick=Source World Tick +signal-srcid=Source World ID +signal-localid=Local World ID From 67e59167906c40951ba3360e1598e805cc9f8603 Mon Sep 17 00:00:00 2001 From: Thomas Deal Date: Wed, 19 Oct 2016 22:26:56 -0400 Subject: [PATCH 8/9] Remove Lost bracket --- clusterio_0.0.3/control.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/clusterio_0.0.3/control.lua b/clusterio_0.0.3/control.lua index 7123317d..ec898e09 100644 --- a/clusterio_0.0.3/control.lua +++ b/clusterio_0.0.3/control.lua @@ -442,7 +442,6 @@ function UpdateInvCombinators() table.insert(invframe,{count=global.worldID,index=#invframe+1,signal={name="signal-localid",type="virtual"}}) end - } local items = game.item_prototypes if global.invdata then for name,count in pairs(global.invdata) do From 67fef2e543c13c2d9a872fcdc90dff9de61ee5a4 Mon Sep 17 00:00:00 2001 From: Danielv123 Date: Thu, 20 Oct 2016 13:25:52 +0200 Subject: [PATCH 9/9] Resolves #30 --- client.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/client.js b/client.js index ae637ede..ef59cc74 100644 --- a/client.js +++ b/client.js @@ -107,6 +107,22 @@ setInterval(function() { } }, 3000) // COMBINATOR SIGNALS --------------------------------------------------------- +// get inventory from Master and RCON it to our slave +setInterval(function() { + needle.get(config.masterIP + ":" + config.masterPort + '/inventory', function(err, response, body){ + if(response && response.body) { + // Take the inventory we (hopefully) got and turn it into the format LUA accepts + // console.log(response.body) + var inventory = response.body; + var inventoryFrame = {}; + for(i = 0;i