Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function lookupIndexInStyle(index, style)
- for part in index:gmatch "[^%.]+" do
- style = style[part] or style._Default or style
- end
- return style._Default or style
- end
- local function renderText(text, style, x, y)
- local i = 1
- local cstack = { lookupIndexInStyle( "_Default", style ) }
- local tstack = { "" }
- local list = {}
- if text:sub( i, i ) == "{" then
- list[#list + 1] = { text = tstack[#tstack], colour = cstack[#cstack] }
- tstack[#tstack] = ""
- tstack[#tstack + 1] = ""
- local name = text:match( "^(%w[%.%w]*%w):", i + 1 ) or text:match( "^(%w):", i + 1 ) or "" -- error instead here?
- cstack[#cstack + 1] = lookupIndexInStyle( name, style )
- i = i + #name + 2 -- + 1 for '{' and ':'
- elseif text:sub( i, i ) == "}" then
- list[#list + 1] = { text = tstack[#tstack], colour = cstack[#cstack] }
- tstack[#tstack] = nil
- cstack[#cstack] = nil
- else
- tstack[#tstack] = tstack[#tstack] .. text:sub( i, i )
- end
- list[#list + 1] = { text = tstack[1], colour = cstack[1] }
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement