Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local io = require("io")
- local serialization = require("serialization")
- local EU = require("ExtraUtilits")
- local fs = require("filesystem")
- local field, w, h, path = table.unpack({...})
- if fs.exists(path) then fs.remove(path) end
- local file = io.open(path, "a")
- file:write(serialization.serialize({w = w, h = h}) .. "\n")
- for i = 1, w do
- for j = 1, h do
- if field[i][j].symbol then
- local background = {EU.Color.Extract(field[i][j].background)}
- local foreground = {EU.Color.Extract(field[i][j].foreground)}
- local symbol = field[i][j].symbol
- local back = string.char(background[1]) .. string.char(background[2]) .. string.char(background[3])
- local fore = string.char(foreground[1]) .. string.char(foreground[2]) .. string.char(foreground[3])
- file:write(back .. fore .. symbol .. "\n")
- else
- file:write("-\n")
- end
- end
- end
- file:close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement