PeachGaming

Untitled

Sep 11th, 2019
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. --Signal Database to table test, making sure it worooks.
  2.  
  3. --Okay, first step, get that freaking signaldatabase
  4.  
  5. local function loadTableFile(path) -- Quiciker way to do things w o a h
  6. local handle = fs.open(path, "r")
  7. local thing = textutils.unserialise(handle.readAll())
  8. handle.close()
  9. return thing
  10. end
  11.  
  12. local signalDatabase = loadTableFile("signalDatabase")
  13. --W..we got it? Good. That's good!
  14.  
  15. function sorted_iter(t)
  16. local i = {}
  17. for k in next, t do
  18. table.insert(i, k)
  19. end
  20. table.sort(i)
  21. return function()
  22. local k = table.remove(i)
  23. if k ~= nil then
  24. return k, t[k]
  25. end
  26. end
  27. end
  28. for s, str in sorted_iter(signalDatabase) do
  29.  
  30. end
  31.  
  32. local function drawScreen()
  33. term.clear()
  34. term.setCursorPos(1,1)
  35. term.write("Table to Display")
  36. term.setCursorPos(1, 2)
  37. term.setCursorPos(1,3)
  38. local previousCoordsX
  39. local previousCoordsY
  40. for s, str in ipairs(signalDatabase) do
  41. print(v)
  42. local x, y = term.getCursorPos()
  43.  
  44. if str.type == "signal" then
  45. term.setBackgroundColor(colors.black)
  46. term.setCursorPos(x + 2, y - 1)
  47. term.write(str.name)
  48. term.setCursorPos(x, y)
  49.  
  50. paintutils.drawLine(x + 1, y, x + 8, y, colors.lime)
  51. end
  52.  
  53. if str.type == "switch" then
  54. paintutils.drawLine(x + 1, y, x + 3, y + 2, colors.lime)
  55. -- paintutils.drawLine(x + 1, y, x + 3, y, colors.lime)
  56.  
  57. end
  58.  
  59. end
  60.  
  61. end
  62.  
  63. drawScreen()
Advertisement
Add Comment
Please, Sign In to add comment