I'm working on redirecting a 'wilderness' like map to a window. The redirecting is going fine as is but I really need a way to draw the background color from the styles table as well. Wondering if anyone has worked something like this out before. I might just need to go about it a different way?
Games map output for reference
https://ada-young.appspot.com/pastebin/46soiKKM
local win = "test_window"
local font = "test_font"
test_map = {}
lines = 0
function test_map_start(name, line, wildcards, styles)
test_map = {}
lines = 0
EnableTrigger("test_map_capture", true)
if not WindowInfo(win, 1) then
WindowCreate(win, 0, 0, 0, 0, 6, 0, 0)
WindowFont(win, font, "Droid Sans Mono", 9)
end
end
function test_map_capture(name, line, wildcards, styles)
lines = lines + 1
if lines <= 17 then
table.insert(test_map, styles)
end
if lines == 17 then
test_map_show()
EnableTrigger("test_map_capture", false)
end
end
function test_map_show()
WindowCreate(win, 0, 0, 300, 300, 4, 0, ColourNameToRGB("black"))
WindowRectOp(win, 1, 0, 0, 0, 0, ColourNameToRGB("red"))
WindowShow(win, true)
local font_height = WindowFontInfo(win, font, 1)
local y = font_height * 2 + 5
for i, styles in ipairs(test_map) do
local x = 5
for _, style in ipairs(styles) do
x = x+WindowText(win, font, style.text, x, y, 0, 0, style.textcolour)
end
y = y + font_height
end
end
|