Upload files to 'Controller'
This commit is contained in:
parent
4bee1219a1
commit
c01c7f4b9e
30
Controller/wheatController.lua
Normal file
30
Controller/wheatController.lua
Normal file
@ -0,0 +1,30 @@
|
||||
function toMatrix(str)
|
||||
local matrix = {}
|
||||
assert(type(str) == "string")
|
||||
assert(str:sub(1,1) == "{", "the string must begin with a \"{\"")
|
||||
local len = str:len()
|
||||
assert(str:sub(len,len) == "}", "the string must end with a \"}\"")
|
||||
local s1, ob = str:gsub("{", "{")
|
||||
local s2, cb = str:gsub("}", "}")
|
||||
assert(ob == cb, "the string must have the same amount of opening brackets as closing brackets")
|
||||
|
||||
str = str:sub(2, len - 1)
|
||||
len = len - 2
|
||||
|
||||
if(str:sub(1,1) == "{") then
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
function toArray(str)
|
||||
local len = str:len()
|
||||
local comma = str:sub(",")
|
||||
local arr = {}
|
||||
while(type(comma)=="number") do
|
||||
arr[#arr+1] = str:sub(1, comma-1)
|
||||
str = str:sub(comma + 1, len)
|
||||
len = str:len()
|
||||
comma = str:sub(",")
|
||||
end
|
||||
return arr
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user