HertzDevil icon

bbcode sprite

HertzDevil | PRO | 06/24/15 09:47:29 PM UTC | 0 ⭐ | 723 👁️ | Never ⏰ | []
Lua |

1.59 KB

|

None

|

0 👍

/

0 👎

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")

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  • Syizuxtrn icon
    05/15/26 01:37:13 PM UTC
    text |

    0 B

    |

    0 👍

    /

    0 👎

    Best Pastebin.com alternatives paste sites list
     Copy and paste the link in a new browser tab and then hit enter!
     https://crazyporn.xxx/members/157354/?asgtbndr=1&play=true&spon=adworld&zone=400