NielsUtrecht

base-ae

Sep 8th, 2013
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.67 KB | None | 0 0
  1. local confMainPort = 1000
  2. local confMyPort = 1002
  3. local confModemSide = "right"
  4.  
  5. local aeData = {}
  6. local itemMap = nil
  7.  
  8. if(not os.loadAPI("hydraApi")) then
  9.     error("Could not load hydraApi")
  10. end
  11.  
  12. local meTerm = hydraApi.getCraftingTerminal()
  13. local meBridge = hydraApi.getMeBridge()
  14. local modem = peripheral.wrap(confModemSide)
  15.  
  16. local function loadItemMap()
  17.     local handle = fs.open("itemmap.txt", "r")
  18.     if(handle == nil) then
  19.         itemMap = nil
  20.         return
  21.     end
  22.     itemMap = textutil.unserialize(handle.readAll())
  23.     handle.close()
  24. end
  25.  
  26. local function getItemList()
  27.     if(meBridge == nil) then
  28.         return nil
  29.     end
  30.    
  31.     local idList = meBridge.listItems()
  32.     local count = 0
  33.     local mappedList = {}
  34.     for k,v in pairs(idList) do
  35.         if(itemMap[k] ~= nil) then
  36.             count = count + 1
  37.             mappedList[itemMap[k]] = v
  38.         end
  39.     end
  40.    
  41.     if(count == 0) then
  42.         return nil
  43.     else
  44.         return mappedList
  45.     end
  46. end
  47.  
  48. loadItemMap()
  49.  
  50. while true do
  51.  
  52.     aeData["powerDrainPerTick"] = meTerm.getPowerDrainPerTick()
  53.     aeData["totalBytes"] = meTerm.getTotalBytes()
  54.     aeData["freeBytes"] = meTerm.getFreeBytes()
  55.     aeData["usedBytes"] = meTerm.getUsedBytes()
  56.     aeData["unusedItemCount"] = meTerm.getUnusedItemCount()
  57.     aeData["canHoldNewItem"] = meTerm.canHoldNewItem()
  58.     aeData["storedItemTypes"] = meTerm.getStoredItemTypes()
  59.     aeData["storedItemCount"] = meTerm.getStoredItemCount()
  60.     aeData["remainingItemCount"] = meTerm.getRemainingItemCount()
  61.     aeData["remainingItemTypes"] = meTerm.getRemainingItemTypes()
  62.     aeData["totalItemTypes"] = meTerm.getTotalItemTypes()
  63.    
  64.     aeData["itemList"] = getItemList()
  65.    
  66.     hydraApi.printTable(aeData)
  67.    
  68.     modem.transmit(confMainPort, confMyPort, aeData)
  69.  
  70.     os.sleep(2)
  71. end
Advertisement
Add Comment
Please, Sign In to add comment