CobraOs

addmoney

Oct 24th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. settings = {}
  2.  
  3. file = fs.open("settings", "r")
  4. istrue = true
  5. i = 0
  6. while istrue do
  7. i = i+1
  8. string1 = file.readLine()
  9. if string1==nill then
  10. istrue = false
  11. break
  12. end
  13. string2 = file.readLine()
  14. settings[i] = string2
  15. end
  16.  
  17.  
  18.  
  19. banking = function()
  20. term.setTextColor(colors.black)
  21. term.setBackgroundColor(colors.white)
  22. term.clear()
  23. local image = paintutils.loadImage("bank")
  24. paintutils.drawImage(image, 1, 1)
  25. term.setCursorPos(16, 8)
  26. term.write("Please input card")
  27. while not disk.hasData(settings[1]) do
  28. os.queueEvent("randomEvent")
  29. os.pullEvent()
  30. end
  31. term.setTextColor(colors.black)
  32. term.setBackgroundColor(colors.white)
  33. term.clear()
  34. local image = paintutils.loadImage("bank")
  35. paintutils.drawImage(image, 1, 1)
  36. term.setCursorPos(16, 8)
  37. term.write("Please enter code")
  38. code = ""
  39. for i=1, 4 do
  40. ponies=false
  41. while not ponies do
  42. local event, key = os.pullEvent("key")
  43. if key>1 and key<11 then
  44. amount = key-1
  45. ponies = true
  46. end
  47. end
  48. code = code..amount
  49. paintutils.drawImage(image, 1, 1)
  50. term.setCursorPos(16, 10)
  51. term.setBackgroundColor(colors.lightBlue)
  52. term.write(code)
  53. end
  54.  
  55. shell.run("delete", "disk/temp")
  56. shell.run("cp", "disk/money", "disk/temp")
  57.  
  58. file = fs.open("disk/temp", "r")
  59. stringcode = file.readLine()
  60. file.close()
  61. shell.run("delete", "disk/temp")
  62.  
  63. stringcode = string.sub(stringcode, 5, -5)
  64.  
  65. file = fs.open("disk/temp", "w")
  66. file.writeLine(stringcode)
  67. file.close()
  68.  
  69. shell.run("decrypt", "disk/temp", code)
  70.  
  71. file = fs.open("disk/temp", "r")
  72. stringcode = tonumber(file.readLine())
  73. file.close()
  74.  
  75.  
  76. shell.run("delete", "disk/temp")
  77.  
  78. if stringcode == nill then
  79. return "n"
  80. else
  81.  
  82. stringcode = stringcode + price
  83.  
  84. if stringcode < 0 then
  85. return "n"
  86. else
  87.  
  88. stringcode = math.random(9)..math.random(9)..math.random(9)..math.random(9)..stringcode..math.random(9)..math.random(9)..math.random(9)..math.random(9)
  89.  
  90. file = fs.open("disk/temp", "w")
  91. file.writeLine(stringcode)
  92. file.close()
  93.  
  94. shell.run("crypt", "disk/temp", code, "f")
  95.  
  96. shell.run("delete", "disk/money")
  97.  
  98. shell.run("cp", "disk/temp", "disk/money")
  99.  
  100. shell.run("delete", "disk/temp")
  101.  
  102. return "y"
  103. end
  104. end
  105. end
  106.  
  107.  
  108.  
  109. file = fs.open("money", "a")
  110. file.close()
  111.  
  112.  
  113. file = fs.open("money", "r")
  114. money = file.readLine()
  115. if money==nill then
  116. money = 0
  117. else
  118. money = tonumber(money)
  119. end
  120. file.close()
  121. shell.run("delete", "money")
  122. price = money
  123.  
  124. if banking()=="y" then
  125. term.setBackgroundColor(colors.white)
  126. term.clear()
  127. local image = paintutils.loadImage("bank-ok")
  128. term.setCursorPos(1,1)
  129. paintutils.drawImage(image, 1, 1)
  130. os.sleep(1)
  131. os.reboot()
  132. else
  133. term.setBackgroundColor(colors.white)
  134. term.clear()
  135. local image = paintutils.loadImage("bank-bad")
  136. term.setCursorPos(1,1)
  137. paintutils.drawImage(image, 1, 1)
  138. end
Add Comment
Please, Sign In to add comment