Where can I see how many Robots are in my network?
Posted: Thu Apr 16, 2015 2:46 am
Where can I see how many Logistics Robots and Construction Robots I've got in my network, in total?
www.factorio.com
https://forums.factorio.com/
That means:Koub wrote:Mouse over a logistic chest, it will tell you how many robots in the same logistic network.
I already did that. It showed me a figure of 50, which is suspiciously round, and also far lower than what I expected.Koub wrote:Mouse over a logistic chest, it will tell you how many robots in the same logistic network.
Code: Select all
/c robots = {};
roboports = {};
logistic = 0;
construction = 0;
recurse = function(r)
id = r.position.x .. "," .. r.position.y;
if (roboports[id] or r.force.name ~= game.player.force.name) then return end;
roboports[id] = true;
logistic = logistic + r.getinventory(1).getitemcount("logistic-robot");
construction = construction + r.getinventory(1).getitemcount("construction-robot");
ids = {};
for _, robot in ipairs(game.findentitiesfiltered{area={{r.position.x-50, r.position.y-50}, {r.position.x+50, r.position.y+50}}, name="construction-robot"}) do;
id = robot.position.x .. "," .. robot.position.y;
if ((ids[id] or not robots[id]) and robot.force.name == game.player.force.name) then;
construction = construction + 1;
ids[id] = true;
robots[id] = true;
end;
end;
for _, robot in ipairs(game.findentitiesfiltered{area={{r.position.x-50, r.position.y-50}, {r.position.x+50, r.position.y+50}}, name="logistic-robot"}) do;
id = robot.position.x .. "," .. robot.position.y;
if ((ids[id] or not robots[id]) and robot.force.name == game.player.force.name) then;
logistic = logistic + 1;
ids[id] = true;
robots[id] = true;
end;
end;
for _, roboport in ipairs(game.findentitiesfiltered{area={{r.position.x-48.5, r.position.y-48.5}, {r.position.x+48.5, r.position.y+48.5}}, name="roboport"}) do;
recurse(roboport);
end;
end;
p = game.player.character.position;
roboport = game.findentitiesfiltered{area={{p.x-48.5, p.y-48.5}, {p.x+48.5, p.y+48.5}}, name="roboport"}[1];
if (roboport) then;
recurse(roboport);
game.player.print("Robots in network: Construction:" .. construction .. " Logistic:" .. logistic);
else;
game.player.print("Not in range of a roboport.");
end
Code: Select all
/c
local ls,cs="logistic-robot","construction-robot";
local log,con = game.forces.player.getentitycount(ls),game.forces.player.getentitycount(cs);
for c in game.getchunks() do
for _,port in pairs(game.findentitiesfiltered{area={{c.x*32,c.y*32},{c.x*32+32,c.y*32+32}}}) do
con=con+port.getitemcount(cs);
log=log+port.getitemcount(ls) end end
for _,p in pairs(game.players) do p.print(con..cs..", "..log..ls) end