Advertisement
Flame-Soulis

experia tracker v1

Oct 22nd, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.89 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 = 13
  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.   eTable = {p.getAspects()}
  34.    
  35. end
  36.  
  37. function aspectDis()
  38.  
  39.   --Reset trackers
  40.   colorTracker = 0
  41.   collumnTracker = 0
  42.   rowTracker = 0
  43.  
  44.   --Do out first setup
  45.   --m.setTextColor(colorsToUse[colorTracker])
  46.  
  47.   for i=1,96,2 do
  48.     --Check if the table value is not nil
  49.     if(eTable[i] == nil) then break end
  50.     --Position the cursor
  51.     m.setCursorPos(1+(collumnOffset*collumnTracker), 1+(rowOffset*rowTracker))
  52.     m.write(eTable[i])
  53.     m.setCursorPos(collumnOffset2+(collumnOffset*collumnTracker), 1+(rowOffset*rowTracker))
  54.     m.write(":" .. eTable[i+1])
  55.     --Bump down a row
  56.     rowTracker = rowTracker + 1
  57.     --If rowTracker is equal to rowLimit,
  58.     --reset and bump collumnTracker
  59.     if(rowTracker == rowLimit) then
  60.         rowTracker = 0
  61.         collumnTracker = collumnTracker + 1
  62.         --Also set the colorTracker
  63.         colorTracker = colorTracker + 10
  64.         --m.setTextColor(colorsToUse[colorTracker])
  65.     end
  66.   end
  67. end
  68.  
  69. function clearLine()
  70.   throwaway,line = m.getCursorPos()
  71.   m.write(lineblank)
  72.   m.setCursorPos(1,line)
  73. end
  74.  
  75. melStart.startup()
  76.  
  77. termx,termy = m.getSize()
  78. for i = 1,termy do
  79.   lineblank = lineblank.." "
  80. end
  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