Advertisement
Dima99

lib

Nov 14th, 2015
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.76 KB | None | 0 0
  1. function read(path)
  2.  local h = fs.open(path, "r")
  3.  local line
  4.  local relay = true
  5.  local table = {path}
  6.  local i = 2
  7.  while relay do
  8.   line = h.readLine()
  9.   if line ~= nil then
  10.    table[i] = line
  11.    i = i + 1
  12.    else relay = false
  13.   end
  14.  end
  15.  h.close()
  16.  return table
  17. end
  18.  
  19. function string(table)
  20.  local string = ""
  21.  for i = 1, #table do
  22.   string = string..table[i].."\n"
  23.  end
  24.  return string
  25. end
  26.  
  27. function unstring(tempFileName, string)
  28.  local name = ""
  29.  local h = fs.open(tempFileName, "w")
  30.  local text = ""
  31.  h.writeLine(string)
  32.  h.close()
  33.  local f = fs.open(tempFileName, "r")
  34.  name = f.readLine()
  35.  f.close()
  36.  fs.delete(tempFileName)
  37.  text = string.gsub(string, name.."\n", "")
  38.  local d = fs.open(name, "w")
  39.  d.writeLine(text)
  40.  d.close()
  41. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement