FarmingTurtle/Controller/wheatController.lua
2023-01-11 18:40:59 +00:00

30 lines
822 B
Lua

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