Advertisement
Flame-Soulis

experia tracker v2

Oct 22nd, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.04 KB | None | 0 0
  1. -- essentia reader computer FSM--
  2.  
  3. os.loadAPI("button")
  4. os.loadAPI("melStart")
  5.  
  6. m = peripheral.find("monitor")
  7. p = peripheral.find("EssentiaProvider")
  8.  
  9. local x,y,z,v
  10. local n,a
  11. local colorsToUse = {colors.green,colors.blue,colors.brown}
  12. local colorTracker, collumnTracker, rowTracker
  13. local rowOffset, collumnOffset, collumnOffset2, rowLimit, collumnLimit
  14.  
  15. --Set up some important 'local' globals (srsly lua?)
  16. collumnOffset = 18
  17. collumnOffset2 = 13     --Used for variable
  18. rowOffset = 1
  19. collumnLimit = 3
  20. rowLimit = 15
  21.  
  22.  
  23. n = -1
  24. a = 0
  25. x = 1
  26. y = 0
  27. z = y
  28. lineblank = ""
  29. aspectNum = 48
  30.  
  31. function aspectTable()
  32.  
  33.   --Grab the nonbeliever table
  34.   local tempList = {p.getAspects()}
  35.   --Now convert (I hope)
  36.   eTable = {}
  37.   local iTemp2 = 0
  38.   for iTemp=1,table.getn(tempList),2 do
  39.     iTemp2 = iTemp2 + 1
  40.     eTable[iTemp2] = {}
  41.     eTable[iTemp2].name = tempList[iTemp]
  42.     eTable[iTemp2].amount = tempList[iTemp+1]
  43.   end
  44.   --Attempt the sorting
  45.   local sort_func = function( a,b ) return a.name < b.name end
  46.   table.sort( eTable, sort_func )
  47.    
  48. end
  49.  
  50. function aspectDis()
  51.  
  52.   --Reset trackers
  53.   colorTracker = 0
  54.   collumnTracker = 0
  55.   rowTracker = 0
  56.  
  57.   --Do out first setup
  58.   --m.setTextColor(colorsToUse[colorTracker])
  59.  
  60.   for i, result in ipairs( eTable ) do
  61.     --Position the cursor
  62.     m.setCursorPos(1+(collumnOffset*collumnTracker), 1+(rowOffset*rowTracker))
  63.     m.write(result.name)
  64.     m.setCursorPos(collumnOffset2+(collumnOffset*collumnTracker), 1+(rowOffset*rowTracker))
  65.     m.write(":" .. result.amount)
  66.     --Bump down a row
  67.     rowTracker = rowTracker + 1
  68.     --If rowTracker is equal to rowLimit,
  69.     --reset and bump collumnTracker
  70.     if(rowTracker == rowLimit) then
  71.         rowTracker = 0
  72.         collumnTracker = collumnTracker + 1
  73.         --Also set the colorTracker
  74.         colorTracker = colorTracker + 10
  75.         --m.setTextColor(colorsToUse[colorTracker])
  76.     end
  77.   end
  78. end
  79.  
  80. --melStart.startup()
  81.  
  82. m.setBackgroundColor(colors.purple)
  83. m.setTextColor(colors.black)
  84. m.setTextScale(1.5)
  85.  
  86. while true do
  87.   m.clear()
  88.   aspectTable()
  89.   aspectDis()
  90.   sleep(1)
  91.  
  92. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement