Advertisement
Marlingaming

Contract record system

Nov 17th, 2022
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. local Categories = {{"property","construction","service","product"},{0.05,0.02,0.05,0.03}}
  2.  
  3. local function Clear()
  4. term.clear()
  5. term.setCursorPos(1,1)
  6. end
  7.  
  8. local function TextField()
  9. local input
  10. local TX, TY = term.getCursorPos()
  11. TY = TY - 1
  12. while true do
  13. term.setCursorPos(TX,TY)
  14. term.clearLine()
  15. term.write()
  16. local e, a, b, c = os.pullEvent("key")
  17. if a == keys.enter then break elseif e == "key" then input = read(C) end
  18. end
  19. return input
  20. end
  21.  
  22. local function OptionListSide(Y,Options)
  23. local n = 1
  24. while true do
  25. term.setCursorPos(1,Y)
  26. term.clearLine()
  27. term.write(Options[n])
  28. local a, b = os.pullEvent("key")
  29. if b == keys.a and n > 1 then n = n - 1 end
  30. if b == keys.d and n < #Options then n = n + 1 end
  31. if b == keys.enter then break end
  32. end
  33. return n
  34. end
  35.  
  36. local function Menu()
  37. Clear()
  38. print("==Contract Recorder==")
  39. print("1. Enter Company Name")
  40. local C1 = TextField()
  41. print("2. Enter Customer name/ Company")
  42. local C2 = TextField()
  43. print("3. Enter Amount")
  44. local Amount = tonumber(TextField())
  45. print("4. select Category")
  46. local Opt = OptionListSide(9,Categories[1])
  47. local Tax = Categories[2][Opt]
  48. print("processing, please wait")
  49. print("Subtotal: "..Amount)
  50. print("Tax ("..Tax.."): "..(Amount*Tax))
  51. print("total: "..(Amount+(Amount*Tax)))
  52. print("creating file")
  53. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement