Advertisement
Guest User

Untitled

a guest
Feb 12th, 2014
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. hard_type = {"survival","shard","perception","gurrenlagaan"}
  2.  
  3. defences = {
  4. perception = {
  5. ["telesense"] = true,
  6. ["nightsight"] = true,
  7. ["overpowered"] = false,
  8. ["truesight"] = true,
  9. ["sexysight"] = true,
  10. ["oversight"] = false,
  11. ["majorsight"] = true,
  12. ["lightningballs"] = true,
  13. ["lovable"] = false,
  14. },
  15. shard = {
  16. ["shardwatch"] = true,
  17. ["shardawareness"] = true,
  18. ["shardcounterawareness"] = true,
  19. ["awesomeoness"] = false,
  20. },
  21. gurrenlagaan = {
  22. ["gorgeous"] = true,
  23. ["fantastic"] = true,
  24. ["overpowered"] = true,
  25. },
  26. survival = {
  27. ["not optional"] = true,
  28. ["sexy"] = false,
  29. ["gutsee"] = true,
  30. },
  31. }
  32.  
  33. string.lpad = function(str, len, char)
  34. if char == nil then char = ' ' end
  35. return str .. string.rep(char, len - #str)
  36. end
  37. echo("asd")
  38. function display_defs()
  39. for i=1, #hard_type do
  40. --echo("\n"..hard_type[i])
  41. local tablen = parse_class(hard_type[i], defences[hard_type[i]])
  42. for n=1, #tablen do
  43. --tablen[n] = string.gsub(tablen[n], "[%#", "[<green>")
  44. --tablen[n] = string.gsub(tablen[n], "[%*", "[<red>")
  45. local str = tablen[n]
  46. str = string.gsub(str, "%[%#", "<grey>[<green>")
  47. str = string.gsub(str, "%[%*", "<grey>[<red>")
  48. str = string.gsub(str, "%]", "<grey>]")
  49. --str = string.gsub(str, "#", "<red>%]")
  50. cecho(str)
  51. end
  52. end
  53. end
  54.  
  55. function parse_class( name, arg )
  56. width, height = getMainWindowSize()
  57. local fontSize = 11 --adjust this value to your font size settings
  58. local fontWidth, fontHeight = calcFontSize( fontSize )
  59. 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)
  60.  
  61. local true_offset = 20
  62. local main_offset = 16 - string.len(name)
  63. local pad = string.lpad(name,main_offset, " ")
  64. local str = pad.."::"
  65.  
  66. local str = string.format( "%s%"..main_offset.."s ", name, "::" )
  67.  
  68. local parsed = {}
  69. local count = 0
  70. local offset = string.len(str)
  71. str = "\n"..str
  72. --display(main)
  73.  
  74. for k, v in pairs( arg ) do --display(v)
  75. local temp, color = "", ""
  76. -- calculate the future length
  77. temp = string.len(k) -- might have to do tostring(k)
  78. temp = string.len(str) + string.len(k) --display(temp)
  79. if temp > main then -- wrap to next line
  80. --str = "\n"..str -- make a carriage return to take it to the next line only after having calculated lengths
  81. table.insert(parsed,str)
  82. str = "\n"
  83. str = string.lpad(str, offset, " ") -- we can now do this as we don't need "Perception ::" in front of the second/third lines.
  84. str = str.." "
  85. end
  86. if v then color = "#" else color = "*" end
  87. str = str.."["..color..k.."] "
  88.  
  89. end
  90.  
  91. table.insert(parsed,str)
  92.  
  93. return parsed
  94. end
  95.  
  96. display_defs()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement