Advertisement
Muzze77

[A103] Terminal-Hundskrippl

Mar 26th, 2017
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.87 KB | None | 0 0
  1. shell.run("clear")
  2.  
  3. list = {{"HV-Farm",0,2,2,colors.green},{"Essenfarm",0,2,4,colors.red},{"Baumfarm",0,2,6,colors.blue}}
  4. mon = peripheral.wrap("back")
  5. sbcol = colors.black
  6. stcol = colors.green
  7. gx, gy = mon.getSize()
  8.  
  9. if fs.exists("rList") == false then
  10. cFile = fs.open("rList","w")
  11. cFile.writeLine(textutils.serialize(list))
  12. cFile.close()
  13. else
  14. rFile = fs.open("rList","r")
  15. list = textutils.unserialize(rFile.readLine())
  16. rFile.close()
  17. end
  18.  
  19. function save(input)
  20. sFile = fs.open("rList","w")
  21. sFile.writeLine(textutils.serialize(input))
  22. sFile.close()
  23. end
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31. function cbut(cx,cy,text,bcol,tcol)
  32. if bcol == nil then
  33. bcol = sbcol
  34. end
  35. if tcol == nil then
  36. tcol = stcol
  37. end
  38.  
  39. mon.setCursorPos(cx,cy)
  40. mon.setBackgroundColor(bcol)
  41. mon.setTextColor(tcol)
  42. mon.write(text)
  43. mon.setBackgroundColor(sbcol)
  44. mon.setTextColor(stcol)
  45.  
  46. end
  47.  
  48.  
  49. mon.setTextScale(2)
  50.  
  51.  
  52.  
  53. mon.clear()
  54. while true do
  55. x = 2
  56. y = 2
  57.  
  58. cbut(gx-1,1,"R",colors.red,colors.black)
  59.  
  60. for i = 1, table.maxn(list),1 do
  61. if string.len(list[i][1]) <= 9 then
  62. for v = string.len(list[i][1]), 9,1 do
  63.     list[i][1] = list[i][1] .. " "
  64. end
  65. end
  66. if list[i][2] == 0 then
  67. col = colors.red
  68. elseif list[i][2] == 1 then
  69. col = colors.green
  70. end
  71. cbut(x,y," " .. list[i][1] .. " ",col,colors.black)
  72. y = y + 2
  73. end
  74.  
  75.  
  76.  
  77. evt, side, x,y = os.pullEvent("monitor_touch")
  78. if x == gx - 1 and y == 1 then
  79.     cbut(gx-1,1,"R")
  80.     sleep(1)
  81.     mon.clear()
  82.     shell.run("reboot")
  83. else
  84.     for v = 1,table.maxn(list),1 do
  85.         if x > list[v][3] and x < list[v][3]+10 and y == list[v][4] then
  86.             if list[v][2] == 1 then
  87.             rs.setBundledOutput("bottom",colors.subtract(rs.getBundledOutput("bottom"),list[v][5]))
  88.             list[v][2] = 0
  89.             elseif list[v][2] == 0 then
  90.             rs.setBundledOutput("bottom",colors.combine(rs.getBundledOutput("bottom"),list[v][5]))
  91.             list[v][2] = 1 
  92.             end
  93.         end
  94.    
  95.    
  96.     end
  97. end
  98. save(list)
  99. print(x .. ":" .. y)
  100.  
  101. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement