Shadows_Player

New Computercraft coffe machine

Jun 12th, 2022
1,042
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.13 KB | None | 0 0
  1. rednet.open("back")
  2.  
  3. -- Username
  4. local ufile = fs.open("disk/user.lua","r")
  5. local username = ufile.readLine()
  6. ufile.close()
  7.  
  8. -- Money Read
  9. local mrfile = fs.open("disk/money.lua","r")
  10. local money = mrfile.readLine()
  11. mrfile.close()
  12.  
  13. --inputredient Available
  14. -- Coffe Read
  15. local cffile = fs.open("disk/coffe.lua","r")
  16. local cff = cffile.readLine()
  17. cffile.close()
  18.  
  19. --SugarCont Read
  20. local scfile = fs.open("disk/sugar.lua","r")
  21. local sugarCont = scfile.readLine()
  22. scfile.close()
  23.  
  24. --blazeCont Read
  25. local blfile = fs.open("disk/blaze.lua","r")
  26. local BlazeCont = blfile.readLine()
  27. blfile.close()
  28.  
  29. --CreamCont Read
  30. local crfile = fs.open("disk/cream.lua","r")
  31. local CreamCont = crfile.readLine()
  32. crfile.close()
  33.  
  34. --GoldenCont Read
  35. local gofile = fs.open("disk/golden.lua","r")
  36. local GoldenCont = gofile.readLine()
  37. gofile.close()
  38.  
  39. --TearCont Read
  40. local tefile = fs.open("disk/tear.lua","r")
  41. local TearCont = tefile.readLine()
  42. tefile.close()
  43.  
  44.  
  45. if money == 0 then
  46.     print("You don't have enougth money")
  47.     sleep(2)
  48.     disk.eject("right")
  49.     os.reboot()
  50. end
  51.  
  52. function line()
  53.     term.clear()
  54.     term.setCursorPos(1,1)
  55.     term.write(string.rep("-", 51)) -- Repeat string x amount of times
  56.     term.setCursorPos(1,19)
  57.     term.write(string.rep("-", 51))
  58. end
  59.  
  60. -- Menu Zone
  61. line()
  62. term.setCursorPos(1,2)
  63. print("Username: "..username)
  64. print("Current Money: "..money.. " Euros")
  65. print("Number of inputredients remaininput: "..cff)
  66. term.setCursorPos(1,6)
  67.  
  68. if sugarCont == "0" then
  69.   print("1.Extra Sugar = 5$ (Not Avalaible)")
  70.   else
  71.   print("1.Extra Sugar = 5$ (Avalaible)")  
  72. end
  73.  
  74. if BlazeCont == "0" then
  75.   print("2.Strong = 10$ (Not Avalaible)")
  76.   else
  77.   print("2.Strong = 10$ (Avalaible)")
  78. end
  79.  
  80. if CreamCont == "0" then
  81.   print("3.Cream = 10$ (Not Avalaible)")
  82.   else
  83.   print("3.Cream = 10$ (Avalaible)")
  84. end
  85.  
  86. if GoldenCont == "0.0" then
  87.   print("4.Premium = 25$ (Not Avalaible)")
  88.   else
  89.   print("4.Premium = 25$ (Avalaible)")
  90. end
  91.  
  92. if TearCont == "0" then
  93.   print("5.Healthy = 30$ (Not Avalaible)")
  94.   else
  95.   print("5.Healthy = 30$ (Avalaible)")
  96. end
  97.  
  98. print("6. Make Coffe")
  99. print("7. Exit")
  100.  
  101. print ("Enter inputredient Selection : ")
  102. local input = read()
  103.  
  104. if input == "1" then
  105.   if tonumber(money) < 5 then
  106.   print("You don't have enougth money")
  107.   make()
  108.   sleep(2)
  109.   disk.eject("right")
  110.   os.reboot()
  111.   else
  112.  
  113.   m = money - 5.0
  114.   local wfile = fs.open("disk/money.lua","w")
  115.   wfile.write(m)
  116.   wfile.close()
  117.  
  118.   c = cff - 1.0
  119.   local cffile = fs.open("disk/coffe.lua","w")
  120.   cffile.write(c)
  121.   cffile.close()
  122.  
  123.   s = sugarCont - 1.0
  124.   local scfile = fs.open("disk/sugar.lua","w")
  125.   scfile.write(s)
  126.   scfile.close()
  127.  
  128.   rednet.broadcast("sugar","cof2")
  129.   os.reboot()
  130.   end
  131. end
  132.  
  133. if input == "2" then
  134.  if tonumber(money) < 10 then
  135.  print("You don't have enougth money")
  136.  make()
  137.  sleep(2)
  138.  disk.eject("right")
  139.  os.reboot()
  140.  else
  141.  m = money - 10.0
  142.  local wfile = fs.open("disk/money.lua","w")
  143.  wfile.write(m)
  144.  wfile.close()
  145.  
  146.  c = cff - 1.0
  147.  local cffile = fs.open("disk/coffe.lua","w")
  148.  cffile.write(c)
  149.  cffile.close()
  150.  
  151.  b = BlazeCont - 1.0
  152.  local blfile = fs.open("disk/blaze.lua","w")
  153.  blfile.write(s)
  154.  blfile.close()
  155.  
  156.  rednet.broadcast("blaze","cof2")
  157.  os.reboot()
  158.  end
  159. end
  160.  
  161. if input == "3" then
  162.  if tonumber(money) < 10 then
  163.  print("You don't have enougth money")
  164.  make()
  165.  sleep(2)
  166.  disk.eject("right")
  167.  os.reboot()
  168.  else
  169.  m = money - 10.0
  170.  local wfile = fs.open("disk/money.lua","w")
  171.  wfile.write(m)
  172.  wfile.close()
  173.  
  174.  c = cff - 1.0
  175.  local cffile = fs.open("disk/coffe.lua","w")
  176.  cffile.write(c)
  177.  cffile.close()
  178.  
  179.  cr = CreamCont - 1.0
  180.  local crfile = fs.open("disk/cream.lua","w")
  181.  crfile.write(cr)
  182.  crfile.close()
  183.  
  184.  rednet.broadcast("cream","cof2")
  185.  os.reboot()
  186.  end
  187. end
  188.  
  189. if input == "4" then
  190.  if tonumber(money) < 25 then
  191.  print("You don't have enougth money")
  192.  make()
  193.  sleep(2)
  194.  disk.eject("right")
  195.  os.reboot()
  196.  else
  197.  m = money - 25.0
  198.  local wfile = fs.open("disk/money.lua","w")
  199.  wfile.write(m)
  200.  wfile.close()
  201.  
  202.  c = cff - 1.0
  203.  local cffile = fs.open("disk/coffe.lua","w")
  204.  cffile.write(c)
  205.  cffile.close()
  206.  
  207.  g = GoldenCont - 1.0
  208.  local gofile = fs.open("disk/golden.lua","w")
  209.  gofile.write(g)
  210.  gofile.close()
  211.  
  212.  rednet.broadcast("golden","cof2")
  213.  os.reboot()
  214.  end
  215. end
  216.  
  217. if input == "5" then
  218.   if tonumber(money) < 30 then
  219.   print("You don't have enougth money")
  220.   make()
  221.   sleep(2)
  222.   disk.eject("right")
  223.   os.reboot()
  224.   else
  225.   m = money - 30.0
  226.   local wfile = fs.open("disk/money.lua","w")
  227.   wfile.write(m)
  228.   wfile.close()
  229.  
  230.   c = cff - 1.0
  231.   local cffile = fs.open("disk/coffe.lua","w")
  232.   cffile.write(c)
  233.   cffile.close()
  234.  
  235.   t = TearCont - 1.0
  236.   local tefile = fs.open("disk/tear.lua","w")
  237.   tefile.write(t)
  238.   tefile.close()
  239.  
  240.   rednet.broadcast("tear","cof2")
  241.   os.reboot()
  242.   end
  243. end
  244.  
  245.  
  246. if input == "7" then
  247.   inMainMenu = false
  248.   disk.eject("right")
  249.   os.reboot()
  250. end
  251.  
  252. if input == "6" then
  253.     rednet.broadcast("make","cof2")
  254.     if redstone.getInput("bottom") == true then
  255.      c = 6
  256.      local cffile = fs.open("disk/coffe.lua","w")
  257.      cffile.write(c)
  258.      cffile.close()
  259.      disk.eject("right")
  260.      os.reboot()
  261.      else
  262.      term.clear()
  263.      term.setCursorPos(1,1)
  264.      term.write("---------------------------------------------------")
  265.      term.setCursorPos(1,19)
  266.      term.write("---------------------------------------------------")
  267.      term.setCursorPos(15,9)
  268.      print("Brewinput Coffe")
  269.      term.setCursorPos(15,10)
  270.      sleep(3)
  271.     end
  272. end
  273.  
  274.  
  275. function make()
  276.  rednet.broadcast("make","cof2")
  277.     if redstone.getInput("bottom") == true then
  278.      c = 6
  279.      local cffile = fs.open("disk/coffe.lua","w")
  280.      cffile.write(c)
  281.      cffile.close()
  282.      disk.eject("right")
  283.      os.reboot()
  284.      else
  285.      term.clear()
  286.      term.setCursorPos(1,1)
  287.      term.write("---------------------------------------------------")
  288.      term.setCursorPos(1,19)
  289.      term.write("---------------------------------------------------")
  290.      term.setCursorPos(15,9)
  291.      print("Brewinput Coffe")
  292.      term.setCursorPos(15,10)
  293.      sleep(3)
  294.      make()
  295.     end
  296. end
  297.  
  298. if tonumber(cff) == 0 then
  299.   make()
  300. end
  301.  
  302.  
  303.  
Advertisement
Add Comment
Please, Sign In to add comment