Advertisement
Marlingaming

Restaurant Tablet Menu

Nov 19th, 2022 (edited)
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2.  
  3. local function GetOptions()
  4. local file = fs.open("Items.txt","r")
  5. local Data = textutils.unserialize(file.readAll())
  6. file.close()
  7. return Data
  8. end
  9.  
  10. local function Menu()
  11. local Options = GetOptions()
  12. term.clear()
  13. term.setCursorPos(1,1)
  14. print("=====Menu=====")
  15. local Orders = {}
  16. for i = 1, #Options do
  17. Orders[i] = 0
  18. end
  19. Options[#Options + 1] = "save"
  20. local n = 1
  21. while true do
  22. for i = 1, #Options do
  23. term.setCursorPos(1,i + 1)
  24. term.clearLine()
  25. if n == i and Options[i] == "save" then term.write(">> save") elseif Options[i] == "save" then term.write("save") elseif n == i then term.write(">> ["..Orders[i].."] "..Options[i]) else term.write("["..Orders[i].."] "..Options[i]) end
  26. end
  27. local a, b = os.pullEvent("key")
  28. if b == keys.w and n > 1 then n = n - 1 end
  29. if b == keys.s and n < #Options then n = n + 1 end
  30. if b == keys.enter and Options[n] == "save" then break elseif b == keys.enter then Orders[n] = Orders[n] + 1 end
  31. end
  32. local Doc = fs.open("CustomerOrder.txt","w")
  33. Doc.write(textutils.serialize(Orders))
  34. Doc.close()
  35. term.clear()
  36. term.setCursorPos(1,1)
  37. print("please please tablet in Drive")
  38. repeat until 1 == 0
  39. end
  40.  
  41. Menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement