print("Create bitmap here: (space denotes transparent cell, empty row ends bitmap)") local bitmap = {} local height, width while true do local str = io.read() if #str == 0 then break end local i = #bitmap + 1 bitmap[i] = {} string.gsub(str, ".", function (s) table.insert(bitmap[i], s) end) width = width and math.max(width, #str) or #str end height = #bitmap local palette = {} print("Create palette entries here: (character, red, green, blue)") print("e.g.: $ 216 192 240") while true do local ch, r, g, b = string.match(io.read(), "^(.) ([0-9]+) ([0-9]+) ([0-9]+)") if not ch or ch == " " then break end r = math.min(255, math.max(0, tonumber(r))) g = math.min(255, math.max(0, tonumber(g))) b = math.min(255, math.max(0, tonumber(b))) palette[ch] = string.format("#%02X%02X%02X", r, g, b) end print("Save the BBcode sprite to:") local f = io.open(io.read(), "w") if not f then print("Invalid filename!") else f:write("[size=150]") for _, row in ipairs(bitmap) do local str = "" local ch = row[1] local len = 0 for i, v in ipairs(row) do if v == ch then len = len + 1 else str = str .. string.format("[color=%s]%s[/color]", palette[ch] or "transparent", string.rep("\xE2\x96\x88", len * 2)) ch = v len = 1 end end if palette[ch] then str = str .. string.format("[color=%s]%s[/color]", palette[ch] or "transparent", string.rep("\xE2\x96\x88", len * 2)) end f:write(str, "\n") end f:write("[/size]") f:close() print("Saved.") end os.execute("pause")