Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- hard_type = {"survival","shard","perception","gurrenlagaan"}
- defences = {
- perception = {
- ["telesense"] = true,
- ["nightsight"] = true,
- ["overpowered"] = false,
- ["truesight"] = true,
- ["sexysight"] = true,
- ["oversight"] = false,
- ["majorsight"] = true,
- ["lightningballs"] = true,
- ["lovable"] = false,
- },
- shard = {
- ["shardwatch"] = true,
- ["shardawareness"] = true,
- ["shardcounterawareness"] = true,
- ["awesomeoness"] = false,
- },
- gurrenlagaan = {
- ["gorgeous"] = true,
- ["fantastic"] = true,
- ["overpowered"] = true,
- },
- survival = {
- ["not optional"] = true,
- ["sexy"] = false,
- ["gutsee"] = true,
- },
- }
- string.lpad = function(str, len, char)
- if char == nil then char = ' ' end
- return str .. string.rep(char, len - #str)
- end
- echo("asd")
- function display_defs()
- for i=1, #hard_type do
- --echo("\n"..hard_type[i])
- local tablen = parse_class(hard_type[i], defences[hard_type[i]])
- for n=1, #tablen do
- --tablen[n] = string.gsub(tablen[n], "[%#", "[<green>")
- --tablen[n] = string.gsub(tablen[n], "[%*", "[<red>")
- local str = tablen[n]
- str = string.gsub(str, "%[%#", "<grey>[<green>")
- str = string.gsub(str, "%[%*", "<grey>[<red>")
- str = string.gsub(str, "%]", "<grey>]")
- --str = string.gsub(str, "#", "<red>%]")
- cecho(str)
- end
- end
- end
- function parse_class( name, arg )
- width, height = getMainWindowSize()
- local fontSize = 11 --adjust this value to your font size settings
- local fontWidth, fontHeight = calcFontSize( fontSize )
- local main = 0.3 * width / fontWidth -- here ui_main will be a percentage of width your actual game content displays in, this calculation will figure out the number of characters in the main window (unsure if there's a faster way to do it)
- local true_offset = 20
- local main_offset = 16 - string.len(name)
- local pad = string.lpad(name,main_offset, " ")
- local str = pad.."::"
- local str = string.format( "%s%"..main_offset.."s ", name, "::" )
- local parsed = {}
- local count = 0
- local offset = string.len(str)
- str = "\n"..str
- --display(main)
- for k, v in pairs( arg ) do --display(v)
- local temp, color = "", ""
- -- calculate the future length
- temp = string.len(k) -- might have to do tostring(k)
- temp = string.len(str) + string.len(k) --display(temp)
- if temp > main then -- wrap to next line
- --str = "\n"..str -- make a carriage return to take it to the next line only after having calculated lengths
- table.insert(parsed,str)
- str = "\n"
- str = string.lpad(str, offset, " ") -- we can now do this as we don't need "Perception ::" in front of the second/third lines.
- str = str.." "
- end
- if v then color = "#" else color = "*" end
- str = str.."["..color..k.."] "
- end
- table.insert(parsed,str)
- return parsed
- end
- display_defs()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement