Muzze77

BANKSYSREG

Sep 28th, 2015
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.72 KB | None | 0 0
  1. -- [BANKSYSREG 1.0]
  2.  
  3. --Script Made by Muzze[Muzze77]
  4. --For install instrtuctions ask at skype / steam (xxmbaccxx)
  5.  
  6.  
  7.  
  8. shell.run("clear")
  9. os.loadAPI("ocs/apis/sensor")
  10. sen = sensor.wrap("right")
  11. function getChest()
  12. sx = sen.getTargets()
  13. for h, i in pairs(sx) do
  14.   if i.Name == "Diamond Chest" then
  15.     x = i.Position.X
  16.     y = i.Position.Y
  17.     z = i.Position.Z
  18.     df = x .. "," .. y .. "," .. z
  19.     return df  
  20.   end
  21. end
  22. end
  23. target = getChest()
  24.         sLog = fs.open("/login", "w")
  25.         sLog.writeLine(false)
  26.         sLog.close()
  27.        
  28.        
  29. p = peripheral.wrap("bottom")
  30. icoins = 30186
  31. bcoins = p.getItemIdentifierIDFor(icoins,0)
  32.  
  33. function readName()
  34. rLog2 = fs.open("/login", "r")
  35. rName = rLog2.readLine(1)
  36. rLog2.close()
  37. return rName
  38. end
  39.  
  40. function start()
  41. shell.run("clear")
  42. term.setBackgroundColor(colors.white)
  43. shell.run("clear")
  44. term.setTextColor(colors.blue)
  45.     term.setCursorPos(5,6)
  46. print("[X] Abheben  ")
  47. term.setCursorPos(5,8)
  48. print("[X] Einzahlen")
  49.  
  50. term.setCursorPos(1,1)
  51.  
  52. end
  53. start()
  54.  
  55.  
  56. function root()
  57.  
  58.  
  59. shell.run("clear")
  60. term.setBackgroundColor(colors.white)
  61. shell.run("clear")
  62. term.setTextColor(colors.blue)
  63.     term.setCursorPos(5,6)
  64. print("[X] Abheben  ")
  65. term.setCursorPos(5,8)
  66. print("[X] Einzahlen")
  67. reading()
  68. uname = readName()
  69. if uname == false then
  70. choose()
  71. else
  72.  
  73. getInts()
  74. end
  75.  
  76. end
  77.  
  78. function pos(x1, y1)
  79. term.setCursorPos(x1,y1)
  80. end
  81.  
  82. function anmelden()
  83. shell.run("clear")
  84. reading()
  85.     pos(5,6)
  86.     print("Bitte Namen eingeben:")
  87.     pos(5,8)
  88.     print("______________")
  89.     pos(7,8)
  90.     name2 = io.read()
  91.     shell.run("clear")
  92.     if fs.exists("/saves/" .. name2) == false then
  93.         pos(2,2)
  94.         print("Name existiert nicht")
  95.         sleep(2)
  96.         choose()
  97.     else
  98.         r2 = fs.open("/saves/" .. name2, "r")
  99.         baName = r2.readLine(1)
  100.         rpw2 = r2.readLine(2)
  101.         rcoin = r2.readLine(3)
  102.         r2.close()
  103.                 shell.run("clear")
  104.         pos(5,6)
  105.         print("Password eingeben")
  106.         pos(5,8)
  107.         print("______________")
  108.         pos(7,8)
  109.         pw = read("*")
  110.  
  111.         if pw == rpw2 then
  112.         sLog = fs.open("/login", "w")
  113.         sLog.writeLine(name2)
  114.         sLog.close()
  115.         getInts()
  116.         else
  117.                 pos(2,2)
  118.  
  119.  
  120.             sLog = fs.open("/login", "w")
  121.         sLog.writeLine(false)
  122.         sLog.close()
  123.        
  124.         print("Falsches Password")
  125.         sleep(2)
  126.         choose()
  127.         end
  128.     end
  129.  
  130.  
  131. end
  132.  
  133. function regis()
  134.  
  135.  
  136.     shell.run("clear")
  137.     reading()
  138.     pos(5,6)
  139.     print("Bitte Namen waehlen:")
  140.     pos(5,8)
  141.     print("______________")
  142.     pos(7,8)
  143.     name = io.read()
  144.     fs.makeDir("/saves")
  145.     if fs.exists("/saves/" .. name) == true then
  146.         pos(2,2)
  147.         print("Username exetiert bereits")
  148.         sleep(4)
  149.         choose()
  150.     else
  151.        
  152.         cIn = fs.open("/saves/" .. name, "w")
  153.         shell.run("clear")
  154.         pos(5,6)
  155.         print("Waehle dein Password")
  156.         pos(5,8)
  157.         print("______________")
  158.         pos(7,8)
  159.         pw = read("*")
  160.         cCoin = 0
  161.         cIn.writeLine(name)
  162.         cIn.writeLine(pw)
  163.         cIn.writeLine(cCoin)
  164.         cIn.close()
  165.         sLog = fs.open("/login", "w")
  166.         sLog.writeLine(name)
  167.         sLog.close()
  168.         getInts()
  169.     end
  170. end
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177. function get()
  178. reading()
  179. shell.run("clear")
  180.         rLog = fs.open("/login", "r")
  181.         rName = rLog.readLine(1)
  182.         rLog.close()
  183.    
  184.     if rName == nil or rName == false then
  185.         choose()
  186.     else
  187.     r1 = fs.open("/saves/" ..rName, "r")
  188.     bdg = r1.readLine(1)
  189.     rpw = r1.readLine(2)
  190.     coins = r1.readLine(3)
  191.     r1.close()
  192.     pre = count()
  193.     pre = tonumber(pre)
  194.         term.setCursorPos(5,10)
  195.     print("Aktuelle Coins: " .. pre)
  196.     term.setCursorPos(5,11)
  197.     print("Wie viele abheben? ")
  198.     term.setCursorPos(24,11)
  199.     e = io.read()
  200.     e = tonumber(e)
  201.     pre = tonumber(pre)
  202.     coins = tonumber(coins)
  203.     if e < pre and coins < pre then
  204.    
  205.     if e > coins then
  206.         term.setCursorPos(2,2)
  207.         print("Nicht genug auf deinem Konto")
  208.         sleep(4)
  209.         term.clearLine(2)
  210.         getInts()
  211.     else
  212.     p.makeRequest(bcoins,e)
  213.     term.setCursorPos(2,2)
  214.     term.clearLine(2)
  215.     print(e .. " Coints abgehoben")
  216.     s1 = fs.open("/saves/" .. rName, "w")
  217.     s1.writeLine(name)
  218.     s1.writeLine(rpw)
  219.     s1.writeLine(coins - e)
  220.     s1.close()
  221.     end
  222.    
  223.     else
  224.         term.setCursorPos(2,2)
  225.         print("Nicht genug im Lager")
  226.         sleep(4)
  227.         term.clearLine(2)
  228.         getInts()
  229.     end
  230. sleep(4)
  231. root() 
  232. end
  233.  
  234. end
  235. function give()
  236. shell.run("clear")
  237. reading()
  238. name = readName()
  239. --loadInts
  240. r1 = fs.open("/saves/" ..name, "r")
  241.     bdg = r1.readLine(1)
  242.     rpw = r1.readLine(2)
  243.     coins = r1.readLine(3)
  244.     r1.close()
  245.  if name == nil then
  246.  
  247.  else
  248.  
  249.  term.setCursorPos(2,2)
  250.   print("Bitte einwerfen wird gezaehlt")
  251.  
  252.    
  253.    
  254.     size2 = count()
  255.     term.setCursorPos(5,10)
  256.     print("Aktuell Coins: " .. size2)
  257.     evt = os.pullEvent("redstone")
  258.     if rs.getInput("top") == true then
  259.    
  260.     term.clearLine(2)
  261.     pos(2,2)
  262.     print("Enter drücken zum fortfahren")
  263.     evt, key = os.pullEvent("key")
  264.     if key == 28 then
  265.     shell.run("clear")
  266.     size3 = count()
  267.     term.setCursorPos(5,11)
  268.     print("Gemessene Coins: " .. size3)
  269.     gem = size3-size2
  270.     term.setCursorPos(5,12)
  271.      print("Differenz: " .. gem)
  272.      s1 = fs.open("/saves/" .. name, "w")
  273.     s1.writeLine(name)
  274.     s1.writeLine(rpw)
  275.     s1.writeLine(coins + gem)
  276.     s1.close()
  277.    
  278.     sleep(4)
  279.     root()
  280.     else
  281.         getInts()
  282.     end
  283.     end
  284.    
  285. end
  286. end
  287.  
  288.  
  289.  
  290. function count()
  291. a = 0
  292. s = sen.getTargetDetails(target)
  293. for v, k in pairs(s.Slots) do
  294. if k.Name == "Industrial Credit" then
  295.  
  296.   f = k.Size
  297.   f = tonumber(f)
  298.  
  299.   if a == 0 then
  300.     a = f
  301.   else
  302.     a = a + f
  303.   end
  304.  
  305.   end
  306. end
  307.  
  308.     return  a
  309.    
  310. end
  311.  
  312.  
  313. function getInts()
  314.  
  315. rLog2 = fs.open("/login", "r")
  316. rName = rLog2.readLine(1)
  317. rLog2.close()
  318.  
  319. shell.run("clear")
  320.    
  321.     rn = fs.open("/saves/" .. rName, "r")
  322.     abc = rn.readLine(1)
  323.     rpw = rn.readLine(2)
  324.     coins = rn.readLine(3)
  325.  
  326.     rn.close()
  327.    
  328. term.setBackgroundColor(colors.white)
  329. shell.run("clear")
  330. term.setTextColor(colors.blue)
  331. reading()
  332. pos(1,1)
  333. pos(5,3)
  334. print("Angemeldet als " .. rName)
  335. pos(5, 5)
  336. print("[A] Abheben")
  337. pos(5,7)
  338. print("[E] Einzahlen")
  339. pos(40,19)
  340. print("[X] Exit")
  341. pos(5,9)
  342.  
  343. print("Deine Coins: " .. coins)
  344. evt, key = os.pullEvent("char")
  345.  
  346. if key == "A" or key == "a" then
  347.     get()
  348. elseif key == "E" or key == "e" then
  349.     give()
  350. elseif key == "X" or key == "x" then
  351.    
  352.         sLog2 = fs.open("/login", "w")
  353.         sLog2.writeLine(false)
  354.         sLog2.close()
  355.         shell.run("clear")
  356.         pos(2,2)
  357.        
  358.         print("Goodbye " .. rName .. "!")
  359.         sleep(4)
  360.        
  361.         choose()
  362. end
  363.  
  364. root()
  365. end
  366.  
  367. function choose()
  368. shell.run("clear")
  369. term.setCursorPos(5,6)
  370. print("[A] Anmelden  ")
  371. term.setCursorPos(5,8)
  372. print("[R] Registrieren")
  373. evt,key = os.pullEvent("char")
  374.  
  375.  if key == "a" or key == "A" then
  376. anmelden()
  377.  elseif key == "r" or key == "R" then
  378. regis()
  379. elseif key == "x" or key == "X" then
  380.     --TESTSCRIPT
  381. end
  382.  end
  383.  
  384.  
  385.  
  386.  
  387.  
  388. function reading()
  389.  
  390.    size = count()
  391.    term.setCursorPos(5,19)
  392.    term.clearLine(19)  
  393.    print("Coins: " .. size)
  394.    sleep(0.1)
  395. end
  396.  
  397. while true do
  398.  
  399. pos(1,1)
  400.   parallel.waitForAll(choose,reading)
  401.     sleep(0.1)
  402.  
  403. end
Add Comment
Please, Sign In to add comment