MavricMC

ATM API

Apr 16th, 2022 (edited)
1,935
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.77 KB | None | 0 0
  1. --ATM version 0.0.8--
  2. --Depricated. All in main file now
  3. --Must be called api.lua--
  4.  
  5. rednet.open("modem_0")
  6.  
  7. server = 0
  8. vers = "0.0.8"
  9.  
  10. --functions--
  11. function smallLogo(x, y)
  12.     term.setBackgroundColor(colors.lightBlue)
  13.     term.setTextColor(colors.lightBlue)
  14.     term.setCursorPos(x + 2, y)
  15.     term.write(" ")
  16.     term.setCursorPos(x, y + 2)
  17.     term.write(" ")
  18.     term.setTextColor(colors.white)
  19.     term.setCursorPos(x + 1, y + 1)
  20.     term.write("M")
  21.  
  22.     term.setBackgroundColor(colors.cyan)
  23.     term.setTextColor(colors.cyan)
  24.     term.setCursorPos(x + 3, y)
  25.     term.write(" ")
  26.     term.setCursorPos(x + 1, y + 2)
  27.     term.write(" ")
  28.     term.setTextColor(colors.white)
  29.     term.setCursorPos(x + 2, y + 1)
  30.     term.write("P")
  31.  
  32.     term.setBackgroundColor(colors.blue)
  33.     term.setTextColor(colors.blue)
  34.     term.setCursorPos(x + 4, y)
  35.     term.write(" ")
  36.     term.setCursorPos(x + 2, y + 2)
  37.     term.write(" ")
  38.     term.setTextColor(colors.white)
  39.     term.setCursorPos(x + 3, y + 1)
  40.     term.write("N")
  41. end
  42.  
  43. function clear(col, exit, small)
  44.     term.setBackgroundColor(col)
  45.     term.setTextColor(colors.yellow)
  46.     term.clear()
  47.     term.setCursorPos(1, 1)
  48.     term.write("ATM ".. vers)
  49.     term.setCursorPos(1, 19)
  50.     term.setTextColor(colors.lightGray)
  51.     term.write("Made By Mavric, Please Report Bugs")
  52.     term.setTextColor(colors.white)
  53.     if (small) then
  54.         smallLogo(46, 2)
  55.     end
  56.     if (exit) then
  57.         term.setBackgroundColor(colors.red)
  58.         term.setCursorPos(49, 17)
  59.         term.write("X")
  60.         term.setBackgroundColor(colors.black)
  61.     end
  62. end
  63.  
  64. function balance(account, ATM, pin)
  65.     local msg = {"bal", account, ATM, pin}
  66.     rednet.send(server, msg, "banking")
  67.     local send, mes, pro = rednet.receive("banking")
  68.     if mes[1] == "balR" then
  69.         return mes[2], mes[3]
  70.     end
  71.     return false, "oof"
  72. end
  73.  
  74. function deposit(account, amount, ATM, pin)
  75.     local msg = {"dep", account, amount, ATM, pin}
  76.     rednet.send(server, msg, "banking")
  77.     local send, mes, pro = rednet.receive("banking")
  78.     if mes[1] == "depR" then
  79.         return mes[2], mes[3]
  80.     end
  81.     return false, "oof"
  82. end
  83.  
  84. function withdraw(account, amount, ATM, pin)
  85.     local msg = {"wit", account, amount, ATM, pin}
  86.     rednet.send(server, msg, "banking")
  87.     local send, mes, pro = rednet.receive("banking")
  88.     if mes[1] == "witR" then
  89.         return mes[2], mes[3], amount
  90.     end
  91.     return false, "oof"
  92. end
  93.  
  94. function transfer(account, account2, amount, ATM, pin)
  95.     local msg = {"tra", account, account2, amount, ATM, pin}
  96.     rednet.send(server, msg, "banking")
  97.     local send, mes, pro = rednet.receive("banking")
  98.     if mes[1] == "traR" then
  99.         return mes[2], mes[3]
  100.     end
  101.     return false, "oof"
  102. end
Advertisement
Add Comment
Please, Sign In to add comment