Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if variablesupdate then
- if love.filesystem.exists("mappacks/" .. mappack .. "/customvariables.txt") then
- local v = love.filesystem.read("mappacks/" .. mappack .. "/customvariables.txt")
- local v1 = v:split("\n")
- for i = 1, #v1 do
- local v2 = v1:split(" = ")
- local vartype = ""
- local vartypevalues = {}
- local numbers = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}
- 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'}
- local firstchar = string.sub(v2[2], 1)
- local secondchar = string.sub(v2[2], 2)
- for i = 1, #numbers do
- if firstchar == numbers[i] then
- vartype = "numeric"
- end
- end
- if firstchar == "{" then
- vartype = "table"
- if secondchar == "\"" then
- vartype = vartype .. "strings"
- else
- for i = 1, #letters do
- if secondchar == letters[i] then
- vartype = vartype .. "alphabetic"
- end
- end
- for i = 1, #numbers do
- if secondchar == numbers[i] then
- vartype = vartype .. "numeric"
- end
- end
- end
- if string.sub(vartype, 1, 5) == "table" then
- local v3 = v2:split(", ")
- for i = 1, #v3 do
- if vartype == "tablenumeric" then
- vartypevalues[v3[i]] = tonumber(v3[i])
- elseif vartype == "tablealphabetic" then
- vartypevalues[v3[i]] = v3[i]
- else
- vartypevalues[v3[i]] = _G[v3[i]]
- end
- end
- end
- if vartype == "numeric" then
- _G[v2[1]] = tonumber(v2[2])
- elseif vartype == "alphabetic" then
- _G[v2[1]] = v2[2]
- elseif string.sub(vartype, 1, 5) == "table" then
- _G[v2[1]] = vartypevalues
- end
- end
- else
- local v = love.filesystem.read("regularvariables.txt")
- local v1 = v:split("\n")
- for i = 1, #v1 do
- local v2 = v1:split(" = ")
- local vartype = ""
- local vartypevalues = {}
- local numbers = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}
- 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'}
- local firstchar = string.sub(v2[2], 1)
- local secondchar = string.sub(v2[2], 2)
- for i = 1, #numbers do
- if firstchar == numbers[i] then
- vartype = "numeric"
- end
- end
- if firstchar == "{" then
- vartype = "table"
- if secondchar == "\"" then
- vartype = vartype .. "strings"
- else
- for i = 1, #letters do
- if secondchar == letters[i] then
- vartype = vartype .. "alphabetic"
- end
- end
- for i = 1, #numbers do
- if secondchar == numbers[i] then
- vartype = vartype .. "numeric"
- end
- end
- end
- if string.sub(vartype, 1, 5) == "table" then
- local v3 = v2:split(", ")
- for i = 1, #v3 do
- if vartype == "tablenumeric" then
- vartypevalues[v3[i]] = tonumber(v3[i])
- elseif vartype == "tablealphabetic" then
- vartypevalues[v3[i]] = v3[i]
- else
- vartypevalues[v3[i]] = _G[v3[i]]
- end
- end
- end
- if vartype == "numeric" then
- _G[v2[1]] = tonumber(v2[2])
- elseif vartype == "alphabetic" then
- _G[v2[1]] = v2[2]
- elseif string.sub(vartype, 1, 5) == "table" then
- _G[v2[1]] = vartypevalues
- end
- end
- end
- variablesupdate = false
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement