Advertisement
Guest User

client

a guest
Nov 23rd, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.90 KB | None | 0 0
  1. local server = 0
  2. local sides = {"top","bottom","left","right","front","back"}
  3. for i = 1,6 do
  4.   a = sides[i]
  5.   if peripheral.getType(a) == "modem" then
  6.     rednet.open(a)
  7.     break
  8.   end
  9. end
  10. while true do
  11. for i = 1,6 do
  12.   a = sides[i]
  13.   if peripheral.getType(a) == "drive" then
  14.     dr = a
  15.     drive = peripheral.wrap(a)
  16.     d = disk.getID(a)
  17.     break
  18.   end
  19. end
  20. print("Input protocol ('money','pay')")
  21. protocol = io.read()
  22. if protocol == "money" then
  23.   rednet.send(server,d,"money")
  24.   id,msg,_ = rednet.receive()
  25.   b = tostring(msg)
  26.   if b == "new" then
  27.     print("Account Created (0$)")
  28.   else
  29.     print("You have "..b.."$")
  30.   end
  31. elseif protocol == "pay" then
  32.   print("Pay to?")
  33.   to = io.read()
  34.   print("How many money?")
  35.   money = io.read()
  36.   e = #tostring(d)
  37.   f = 4-e
  38.   g = ""
  39.   for i = 1,f do
  40.     g = g.."0"
  41.   end
  42.   g = tonumber(g..d..money)
  43.   rednet.send(server,g,to)
  44. end
  45. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement