Advertisement
LDDestroier

rec.lua

May 17th, 2021
1,079
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- rec.lua
  2. local id, message, lock, name, mode
  3. local info, num, val
  4.  
  5. while true do
  6.     id, message = rednet.receive()
  7.     lock = message[4]
  8.     name = message[2] .. ".lua"
  9.  
  10.     if lock == "greenblock" then
  11.         mode = message[1]
  12.  
  13.         if (mode == "read") then
  14.             if fs.exists("Accounts/" .. name) then
  15.                 info = fs.open("Accounts/" .. name, "r")
  16.                 num = info.readLine()
  17.                 rednet.send(id, num)
  18.                 info.close()
  19.  
  20.             elseif fs.exists("Accounts/" .. name) == false then
  21.                 info = fs.open("Accounts/" .. name, "w")
  22.                 info.writeLine("0.00")
  23.                 rednet.send(id, "0.00")
  24.                 info.close()
  25.             end
  26.  
  27.         elseif mode == "write" then
  28.             val = message[3]
  29.             info = fs.open("Accounts/" .. name, "w")
  30.             info.writeLine(val)
  31.             info.close()
  32.  
  33.         end
  34.     end
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement