Advertisement
xerpi

mapas funcs

Dec 9th, 2011
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.52 KB | None | 0 0
  1. function mapa.read(path)
  2.     local map = {};
  3.     if files.exists(path) then
  4.         file = io.open(path);
  5.         for line in file:lines() do
  6.             table.insert(map,{})
  7.             for k = 1, #line do
  8.                 table.insert(map[#map],tostring(string.sub(line,k,k)))
  9.             end
  10.         end
  11.         file:close();
  12.     end
  13.     return map;
  14. end
  15.  
  16. function mapa.save(map,path)
  17.     if files.exists(path) then
  18.         file = io.open(path,"w+");
  19.         for i =1, #map do
  20.             file:write(string.implode(map[i]).."\n");
  21.         end
  22.         file:flush();
  23.         file:close();
  24.         return true;
  25.     end
  26.     return false;
  27. end
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement