Advertisement
MavricMC

ATM API

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