Advertisement
Guest User

test

a guest
Jan 30th, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.36 KB | None | 0 0
  1. rednet.open("top")
  2. local sId = rednet.lookup("bank", "server")
  3. if not sId then
  4.   error("Server is not online")
  5. end
  6.  
  7. local function sMsg(msg)
  8.   rednet.send(sId, msg, "bank")
  9.  end
  10.  
  11.  local function rMsg()
  12.    local time = os.startTimer(1)
  13.    while true do
  14.      local ev, p1, p2, p3 = os.pullEvent()
  15.      if ev == "rednet_message" then
  16.        if p1 == sId and p3 == "bank" then
  17.          return p2
  18.        end
  19.      elseif ev == "timer" and p1 == time then
  20.        return false
  21.      end
  22.    end
  23.  end
  24.  
  25. local function register(user, pass)
  26.   sMsg(textutils.serialize({"register", user, pass}))
  27.   local resp = rMsg()
  28.   if not resp then
  29.     return false, "No response"
  30.   else
  31.      return resp
  32.   end
  33. end
  34.  
  35. local function transact(user, amount, recipient)
  36.   sMsg(textutils.serialize({"transact",user, amount, recipient}))
  37.   local resp = rMsg()
  38.   if not resp then
  39.     return false, "No response"
  40.   else
  41.     return resp
  42.   end
  43. end
  44.  
  45.  
  46. --print(register("jojoisawsome", "genericPassword"))
  47. --print(transact("jojoisawsome", 1, "nillogic"))
  48. while true do
  49. term.clear()
  50. term.setCursorPos(1,1)
  51. print("Username: ")
  52. term.setCursorPos(1,2)
  53. local username = string.lower(read())
  54. term.setCursorPos(1,3)
  55. print("Password: ")
  56. term.setCursorPos(1,4)
  57. local password = string.lower(read("*"))
  58. term.clear()
  59. term.setCursorPos(1,1)
  60. print(username.."'s account")
  61. term.setCu
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement