Posted 29 April 2015 - 06:15 AM
I am using some delicious peripheral wrapping code provided in another post by Lyqyd
which I am using on IC2 batboxes, batbox = wrapAll("batbox") That works all fine and dandy,
I wrote a quick thing to get its energy,
Any help is of course appreciated, credit for all above code goes to LYQYD
function wrapAll(type)
local wrapped, names = {}, {}
for _, name in ipairs(peripheral.getNames()) do
if peripheral.getType(name) == type then
table.insert(names, name)
end
end
for _, fn in ipairs(peripheral.getMethods(names[1])) do
wrapped[fn] = function(...)
local returns = {}
for i = 1, #names do
returns[i] = peripheral.call(names[i], fn, ...)
end
return returns
end
end
return wrapped
end
which I am using on IC2 batboxes, batbox = wrapAll("batbox") That works all fine and dandy,
I wrote a quick thing to get its energy,
test = batbox.getEUStored()
for k,v in pairs(test) do
print(v)
end
Which outputs the energy of all 24(yes, 24 batboxes) properly. The issue is, that insane amount of info is hard to display on a monitor, so i wanted to coalesce the energy outputs of each batbox, sadly I don't know how to do so in the required for loop.Any help is of course appreciated, credit for all above code goes to LYQYD