Posted 25 March 2014 - 08:19 PM
So I wrote this program to monitor my Resonant energy cell to see how much power I am drawing. The code that is below draws that bars and everything but doesn't show power. It also has an error saying that the parameter"slot" is missing.
The code:
local bridge = peripheral.wrap("right")
local net = peripheral.wrap("left")
bridge.clear()
local width = 200
local storageUnits = {
{
["id"] = "cofh_thermalexpansion_energycell_0",
["name"] = "Cell 1"
},
{
["id"] = "cofh_thermalexpansion_energycell_1",
["name"] = "Cell 2"
}
}
local offset = 0
for key, storageUnit in pairs(storageUnits) do
pxOffset = offset * 20
storageUnit["label"] = bridge.addText(4, 4 + pxOffset, storageUnit["name"], 0x000000)
storageUnit["bar"] = bridge.addBox(4, 14 + pxOffset, 0, 5, 0xCC0000, 0.9)
–storageUnit["bar"].setZIndex(2)
storageUnit["bg"] = bridge.addBox(4, 14 + pxOffset, width, 5, 0x000000, 0.5)
offset = offset + 1
end
while true do
for i=#storageUnits,1,-1 do
storageUnit = storageUnits
if net.isPresentRemote(storageUnit["id"]) then
capacity = net.callRemote(storageUnit["id"], "getMaxEnergyStored")– this is where the error saying parameter "slot" is mssing
amount = net.callRemote(storageUnit["id"], "getEnergyStored")
storageUnit["bar"].setWidth(width / capacity * amount)
else
storageUnit["bar"].delete()
storageUnit["bg"].delete()
storageUnit["label"].delete()
table.remove(storageUnits, i)
end
end
sleep(0.5)
end
Please help
The code:
local bridge = peripheral.wrap("right")
local net = peripheral.wrap("left")
bridge.clear()
local width = 200
local storageUnits = {
{
["id"] = "cofh_thermalexpansion_energycell_0",
["name"] = "Cell 1"
},
{
["id"] = "cofh_thermalexpansion_energycell_1",
["name"] = "Cell 2"
}
}
local offset = 0
for key, storageUnit in pairs(storageUnits) do
pxOffset = offset * 20
storageUnit["label"] = bridge.addText(4, 4 + pxOffset, storageUnit["name"], 0x000000)
storageUnit["bar"] = bridge.addBox(4, 14 + pxOffset, 0, 5, 0xCC0000, 0.9)
–storageUnit["bar"].setZIndex(2)
storageUnit["bg"] = bridge.addBox(4, 14 + pxOffset, width, 5, 0x000000, 0.5)
offset = offset + 1
end
while true do
for i=#storageUnits,1,-1 do
storageUnit = storageUnits
if net.isPresentRemote(storageUnit["id"]) then
capacity = net.callRemote(storageUnit["id"], "getMaxEnergyStored")– this is where the error saying parameter "slot" is mssing
amount = net.callRemote(storageUnit["id"], "getEnergyStored")
storageUnit["bar"].setWidth(width / capacity * amount)
else
storageUnit["bar"].delete()
storageUnit["bg"].delete()
storageUnit["label"].delete()
table.remove(storageUnits, i)
end
end
sleep(0.5)
end
Please help
Edited on 25 March 2014 - 08:38 PM