Advertisement
MavricMC

ATM API

Apr 16th, 2022 (edited)
1,440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.82 KB | None | 0 0
  1. --ATM version 0.0.6--
  2. --Must be called api.lua--
  3.  
  4. rednet.open("modem_0")
  5.  
  6. server = 0
  7. vers = "0.0.6"
  8.  
  9. --functions--
  10. function clear(col, exit)
  11.     --add bank logo--
  12.     term.setBackgroundColor(col)
  13.     term.setTextColor(colors.yellow)
  14.     term.clear()
  15.     term.setCursorPos(1, 1)
  16.     term.write("Bank OS ".. vers)
  17.     term.setCursorPos(1, 19)
  18.     term.setTextColor(colors.lightGray)
  19.     term.write("Made By Mavric, Please Report Bugs")
  20.     term.setTextColor(colors.white)
  21.     if (exit) then
  22.         term.setBackgroundColor(colors.red)
  23.         term.setCursorPos(49, 17)
  24.         term.write("X")
  25.         term.setBackgroundColor(colors.black)
  26.     end
  27. end
  28.  
  29. function balance(account, ATM, pin)
  30.     local msg = {"bal", account, ATM, pin}
  31.     rednet.send(server, msg, "banking")
  32.     local send, mes, pro = rednet.receive("banking")
  33.     if mes[1] == "balR" then
  34.         return mes[2], mes[3]
  35.     end
  36.     return false, "oof"
  37. end
  38.  
  39. function deposit(account, amount, ATM, pin)
  40.     local msg = {"dep", account, amount, ATM, pin}
  41.     rednet.send(server, msg, "banking")
  42.     local send, mes, pro = rednet.receive("banking")
  43.     if mes[1] == "depR" then
  44.         return mes[2], mes[3]
  45.     end
  46.     return false, "oof"
  47. end
  48.  
  49. function withdraw(account, amount, ATM, pin)
  50.     local msg = {"wit", account, amount, ATM, pin}
  51.     rednet.send(server, msg, "banking")
  52.     local send, mes, pro = rednet.receive("banking")
  53.     if mes[1] == "witR" then
  54.         return mes[2], mes[3], amount
  55.     end
  56.     return false, "oof"
  57. end
  58.  
  59. function transfer(account, account2, amount, ATM, pin)
  60.     local msg = {"tra", account, account2, amount, ATM, pin}
  61.     rednet.send(server, msg, "banking")
  62.     local send, mes, pro = rednet.receive("banking")
  63.     if mes[1] == "traR" then
  64.         return mes[2], mes[3]
  65.     end
  66.     return false, "oof"
  67. end
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement