Seems to have worked, and I was thinking about it you might be able to get more sensors attached with a wireless modem. Haven't tested that, not sure how the side would work for a wireless controller if it is even possible.
(Edit: Just checked there is no way to put a wireless modem on a controller, so the max sensors for one computer would be 5 or 4 if you want a monitor or a disk drive.)
Here's my completed code and the output.
--Adds together the values of our table down below.
function sum(values)
local sum = 0
for k,v in pairs(values) do
sum = sum + v
end
return sum
end
--Defines the patern for gathering the totals from the formated data.
local pattern = "^(%d+)%*(%a+%.?%a+)@(%d+)"
--Defines the sides of each of the controlers.
local mySide = "bottom"
local dadSide = "left"
local scrapSide = "back"
--Defines Sen as string Sensor. *All sensors in multiplayer are named Sensor, and cannot be changed*
local Sen = "Sensor"
--Defines the probe names for each type of sensor used. [3] Is searching for the third line in the array.
--mySide, and dadSide are the same type of probe. (IC2 Probe, searching for the EU data of our MFEs)
local EUProbe = sensors.getProbes(mySide, Sen)[3]
local itemProbe = sensors.getProbes(scrapSide, Sen)[3]
--Defines the targets for our readings.
--My MFE, target one is my batbox, I dont want that.
local myTarget = sensors.getAvailableTargetsforProbe(mySide, Sen, EUProbe)[2]
--My Dads only MFE in the area.
local dadTarget = sensors.getAvailableTargetsforProbe(dadSide, Sen, EUProbe)[1]
--Only chest in range.
local scrapTarget = sensors.getAvailableTargetsforProbe(scrapSide, Sen, itemProbe)[1]
--Loops for continuous data gathering and printing.
while true do
--Defines a table for gathering the values of each stack of scrap.
local ScrapCount = {}
--Gathers readings from each sensor.
local myData = sensors.getSensorReadingAsDict(mySide, Sen, myTarget, EUProbe)
local dadData = sensors.getSensorReadingAsDict(dadSide, Sen, dadTarget, EUProbe)
local scrapData = sensors.getSensorReadingAsDict(scrapSide, Sen, scrapTarget, itemProbe)
--Gathers values for the table.
for i = 1, #scrapData do
local amount, item, slot = string.match(scrapData[i], pattern)
if item == "item.itemScrap" then
table.insert(ScrapCount, amount)
end
end
--Readies the terminal for printing.
term.clear()
term.setCursorPos(1,1)
write("Available Energy:")
term.setCursorPos(1,3)
write("My MFE: "..tostring(myData.energy).." : "..tostring(myData.maxStorage))
term.setCursorPos(1,4)
write("Dad MFE: "..tostring(dadData.energy).." : "..tostring(dadData.maxStorage))
term.setCursorPos(35,1)
local total = sum(ScrapCount)
write("Scrap in Chest: "..tostring(total))
sleep(1)
end
Output:
Spoiler