Stravides

CheckME

Nov 20th, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.91 KB | None | 0 0
  1. local ctrl = peripheral.wrap("top")
  2.  
  3. function ParseMsg(id, msg)
  4.   --if (id == 4) then
  5.     if (msg == "Query_BYTES_TOTAL") then
  6.       rednet.send(id, ctrl.getTotalBytes())
  7.     end
  8.     if (msg == "Query_BYTES_FREE") then
  9.       rednet.send(id, ctrl.getFreeBytes())
  10.     end
  11.     if (msg == "Query_BYTES_USED") then
  12.       rednet.send(id, ctrl.getUnusedBytes())
  13.     end
  14.     if (msg == "Query_SLOTS_TOTAL") then
  15.       rednet.send(id, ctrl.getTotalItemTypes())
  16.     end
  17.     if (msg == "Query_SLOTS_FREE") then
  18.       rednet.send(id, ctrl.getRemainingItemTypes())
  19.     end
  20.     if (msg == "Query_SLOTS_USED") then
  21.       rednet.send(id, ctrl.getTotalItemTypes() - ctrl.getRemainingItemTypes())
  22.     end
  23.   --end
  24. end
  25.  
  26. function ReceiveAsync()
  27.   while true do
  28.     id, msg, time = rednet.receive()
  29.     print(msg)
  30.     print(id)
  31.     ParseMsg(id, msg)
  32.   end
  33. end
  34.  
  35. rednet.open("left")
  36. ReceiveAsync()
  37. rednet.close("left")
Add Comment
Please, Sign In to add comment