From bf2d16669d26f7c4455901b2d756130d0c542b22 Mon Sep 17 00:00:00 2001 From: Thomas Deal Date: Wed, 19 Oct 2016 21:42:09 -0400 Subject: [PATCH] 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 })