Skip to content

Instantly share code, notes, and snippets.

@Der-Eddy
Created April 7, 2015 17:06
Show Gist options
  • Save Der-Eddy/30f9ee770dd1e954ec09 to your computer and use it in GitHub Desktop.
Save Der-Eddy/30f9ee770dd1e954ec09 to your computer and use it in GitHub Desktop.
Minecraft Industrialcraft Storage Monitor (OpenCCSensors)
local monitor = peripheral.wrap("right")
local w, h = monitor.getSize()
local modem = peripheral.wrap("left")
modem.open(100)
local function padLeft(str, w)
return string.rep(" ", w - #str)..str
end
function round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end
function bar(l, name, object, color)
local p = (w-12) * object.Stored / object.Capacity
monitor.setCursorPos(2,l)
monitor.setTextColour(color)
monitor.write(name)
monitor.setBackgroundColour(color)
monitor.write(string.rep(" ", p))
monitor.setBackgroundColour(colours.black)
monitor.setTextColour(colours.white)
monitor.setCursorPos(w-3,l)
monitor.write(round(object.StoredPercentage,0).."%")
end
while true do
local event, side, cha1, cha2, message = os.pullEvent("modem_message")
monitor.clear()
monitor.setCursorPos(2,2)
monitor.setTextColour(colours.blue)
monitor.write("MFSU: -- not found --")
bar(4, "MFE: ", message.mfe, colours.orange)
bar(6, "CESU: ", message.cesu, colours.brown)
end
os.loadAPI("ocs/apis/sensor")
local Sensor = sensor.wrap("right")
local modem = peripheral.wrap("left")
while true do
local CESU = Sensor.getTargetDetails("4,-1,0")
local MFE = Sensor.getTargetDetails("4,1,4")
local Table = {}
Table.cesu = CESU
Table.mfe = MFE
--sprint(CESU)
--modem.transmit(100,101,CESU)
--sprint(MFE)
--modem.transmit(110,101,MFE)
modem.transmit(100,101,Table)
os.sleep(1)
end
function sprint(object)
print(object.Name..": "..object.Stored.."/"..object.Capacity.." ("..object.StoredPercentage..")")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment