Advertisement
HugoBDesigner

Untitled

Jul 30th, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.27 KB | None | 0 0
  1. if variablesupdate then
  2. if love.filesystem.exists("mappacks/" .. mappack .. "/customvariables.txt") then
  3. local v = love.filesystem.read("mappacks/" .. mappack .. "/customvariables.txt")
  4. local v1 = v:split("\n")
  5. for i = 1, #v1 do
  6. local v2 = v1:split(" = ")
  7. local vartype = ""
  8. local vartypevalues = {}
  9. local numbers = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}
  10. local letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}
  11. local firstchar = string.sub(v2[2], 1)
  12. local secondchar = string.sub(v2[2], 2)
  13. for i = 1, #numbers do
  14. if firstchar == numbers[i] then
  15. vartype = "numeric"
  16. end
  17. end
  18. if firstchar == "{" then
  19. vartype = "table"
  20. if secondchar == "\"" then
  21. vartype = vartype .. "strings"
  22. else
  23. for i = 1, #letters do
  24. if secondchar == letters[i] then
  25. vartype = vartype .. "alphabetic"
  26. end
  27. end
  28. for i = 1, #numbers do
  29. if secondchar == numbers[i] then
  30. vartype = vartype .. "numeric"
  31. end
  32. end
  33. end
  34.  
  35. if string.sub(vartype, 1, 5) == "table" then
  36. local v3 = v2:split(", ")
  37. for i = 1, #v3 do
  38. if vartype == "tablenumeric" then
  39. vartypevalues[v3[i]] = tonumber(v3[i])
  40. elseif vartype == "tablealphabetic" then
  41. vartypevalues[v3[i]] = v3[i]
  42. else
  43. vartypevalues[v3[i]] = _G[v3[i]]
  44. end
  45. end
  46. end
  47.  
  48. if vartype == "numeric" then
  49. _G[v2[1]] = tonumber(v2[2])
  50. elseif vartype == "alphabetic" then
  51. _G[v2[1]] = v2[2]
  52. elseif string.sub(vartype, 1, 5) == "table" then
  53. _G[v2[1]] = vartypevalues
  54. end
  55. end
  56. else
  57. local v = love.filesystem.read("regularvariables.txt")
  58. local v1 = v:split("\n")
  59. for i = 1, #v1 do
  60. local v2 = v1:split(" = ")
  61. local vartype = ""
  62. local vartypevalues = {}
  63. local numbers = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}
  64. local letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}
  65. local firstchar = string.sub(v2[2], 1)
  66. local secondchar = string.sub(v2[2], 2)
  67. for i = 1, #numbers do
  68. if firstchar == numbers[i] then
  69. vartype = "numeric"
  70. end
  71. end
  72. if firstchar == "{" then
  73. vartype = "table"
  74. if secondchar == "\"" then
  75. vartype = vartype .. "strings"
  76. else
  77. for i = 1, #letters do
  78. if secondchar == letters[i] then
  79. vartype = vartype .. "alphabetic"
  80. end
  81. end
  82. for i = 1, #numbers do
  83. if secondchar == numbers[i] then
  84. vartype = vartype .. "numeric"
  85. end
  86. end
  87. end
  88.  
  89. if string.sub(vartype, 1, 5) == "table" then
  90. local v3 = v2:split(", ")
  91. for i = 1, #v3 do
  92. if vartype == "tablenumeric" then
  93. vartypevalues[v3[i]] = tonumber(v3[i])
  94. elseif vartype == "tablealphabetic" then
  95. vartypevalues[v3[i]] = v3[i]
  96. else
  97. vartypevalues[v3[i]] = _G[v3[i]]
  98. end
  99. end
  100. end
  101.  
  102. if vartype == "numeric" then
  103. _G[v2[1]] = tonumber(v2[2])
  104. elseif vartype == "alphabetic" then
  105. _G[v2[1]] = v2[2]
  106. elseif string.sub(vartype, 1, 5) == "table" then
  107. _G[v2[1]] = vartypevalues
  108. end
  109. end
  110. end
  111. variablesupdate = false
  112. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement