Advertisement
HangMan23

Untitled

Mar 23rd, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.92 KB | None | 0 0
  1. local io = require("io")
  2. local serialization = require("serialization")
  3. local EU = require("ExtraUtilits")
  4. local fs =  require("filesystem")
  5.  
  6. local field, w, h, path = table.unpack({...})
  7.  
  8. if fs.exists(path) then fs.remove(path) end
  9.  
  10. local file = io.open(path, "a")
  11.  
  12. file:write(serialization.serialize({w = w, h = h}) .. "\n")
  13.  
  14. for i = 1, w do
  15.  
  16.   for j = 1, h do
  17.  
  18.     if field[i][j].symbol then
  19.  
  20.       local background = {EU.Color.Extract(field[i][j].background)}
  21.       local foreground = {EU.Color.Extract(field[i][j].foreground)}
  22.       local symbol = field[i][j].symbol
  23.  
  24.       local back = string.char(background[1]) .. string.char(background[2]) .. string.char(background[3])
  25.       local fore = string.char(foreground[1]) .. string.char(foreground[2]) .. string.char(foreground[3])
  26.  
  27.       file:write(back .. fore .. symbol .. "\n")
  28.  
  29.     else
  30.  
  31.       file:write("-\n")
  32.  
  33.     end
  34.  
  35.   end
  36.  
  37. end
  38.  
  39. file:close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement