Advertisement
Muzze77

[A104] GSINFO-Hundskrippl

Apr 16th, 2017
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.91 KB | None | 0 0
  1. shell.run("clear")
  2. mon = peripheral.wrap("back")
  3.  
  4.  
  5. gs = {}
  6.  
  7. gs["small"] = {}
  8. gs["small"]["size"] = "2x2"
  9. gs["small"]["amount"] = 0
  10.  
  11. gs["middle"] = {}
  12. gs["middle"]["size"] = "2x3"
  13. gs["middle"]["amount"] = 0
  14.  
  15. gs["big"] = {}
  16. gs["big"]["size"] = "3x3"
  17. gs["big"]["amount"] = 0
  18.  
  19. if fs.exists("gs") == false then
  20.     cFile = fs.open("gs","w")
  21.     cFile.writeLine(textutils.serialize(gs))
  22.     cFile.close()
  23. else
  24.     rFile = fs.open("gs","r")
  25.     gs = textutils.unserialize(rFile.readLine())
  26.     rFile.close()
  27. end
  28.  
  29. function save(gTab)
  30. sFile = fs.open("gs","w")
  31. gTab = textutils.serialize(gTab)
  32. sFile.writeLine(gTab)
  33. sFile.close()
  34. end
  35.  
  36. function cbut(cx,cy,text,bcol,tcol)
  37. if bcol == nil then
  38. bcol = colors.black
  39. end
  40. if tcol == nil then
  41. tcol = colors.white
  42. end
  43. mon.setCursorPos(cx,cy)
  44. mon.setBackgroundColor(bcol)
  45. mon.setTextColor(tcol)
  46. mon.write(text)
  47. mon.setBackgroundColor(colors.black)
  48. mon.setTextColor(colors.white)
  49. end
  50. gx,gy = mon.getSize()
  51. mon.setBackgroundColor(colors.black)
  52. mon.clear()
  53.  
  54. function range()
  55. cbut(4,2,"Ultra City Grundstuecke",colors.black,colors.red)
  56. cbut(4,3," Grössen    :   Anzahl ",colors.black,colors.white)
  57. cbut(6,5," " .. gs.small.size.. " ",colors.red,colors.white)
  58. cbut(20,5," " .. gs.small.amount.. "    ",colors.red,colors.white)
  59. cbut(6,7," " .. gs.middle.size.. " ",colors.blue,colors.white)
  60. cbut(20,7," " .. gs.middle.amount.. "    ",colors.blue,colors.white)
  61. cbut(6,9," " .. gs.big.size.. " ", colors.orange,colors.white)
  62. cbut(20,9," " .. gs.big.amount.. "    ", colors.orange,colors.white)
  63. end
  64.  
  65.  
  66.  
  67. function editCon()
  68. cbut(20,5,"<",colors.white,colors.black)
  69. cbut(20,7,"<",colors.white,colors.black)
  70. cbut(20,9,"<",colors.white,colors.black)
  71. cbut(24,5,">",colors.white,colors.black)
  72. cbut(24,7,">",colors.white,colors.black)
  73. cbut(24,9,">",colors.white,colors.black)
  74. cbut(gx,gy,"S",colors.green,colors.black)
  75.  
  76. evt ,side, x,y = os.pullEvent("monitor_touch")
  77.         if x == 20 then
  78.         if y == 5 then
  79.             if gs.small.amount < 0 then
  80.             gs.small.amount = 0
  81.             else
  82.             gs.small.amount = gs.small.amount - 1
  83.             end
  84.         elseif y == 7 then
  85.             if gs.middle.amount < 0 then
  86.             gs.middle.amount = 0
  87.             else
  88.             gs.middle.amount = gs.middle.amount - 1
  89.             end
  90.         elseif y == 9 then
  91.             if gs.big.amount < 0 then
  92.             gs.big.amount = 0
  93.             else
  94.             gs.big.amount = gs.big.amount - 1
  95.             end
  96.         end
  97.         save(gs)
  98.     elseif x == 24 then
  99.         if y == 5 then
  100.             gs.small.amount = gs.small.amount + 1
  101.         elseif y == 7 then
  102.             gs.middle.amount = gs.middle.amount + 1
  103.         elseif y == 9 then
  104.             gs.big.amount = gs.middle.amount + 1
  105.        
  106.         end
  107.         save(gs)
  108.     elseif x == gx and y == gy then
  109.         start()
  110.     else
  111.         range()
  112.         editCon()
  113.     end
  114.     range()
  115.     editCon()
  116. end
  117.  
  118.  
  119. function start()
  120.  
  121. mon.setBackgroundColor(colors.black)
  122. mon.clear()
  123. range()
  124. evt , side , x, y = os.pullEvent("monitor_touch")
  125.     if x == gx or x == gx - 1 and gy == 1 then
  126.         editCon()
  127.     else
  128.         start()
  129.     end
  130.  
  131.  
  132. end
  133.  
  134.  
  135. while true do
  136. start()
  137. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement