Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to convert string to table?

Asked by 7 years ago

I'm making a LuaC engine, and it utilizes PCall, but I need the string converted to a table.

01plr.Chatted:connect(function(msg)
02        local function compile(...)
03        local func,err = pcall(...)
04        if (func) then
05            sc("LuaC script executed",BrickColor.Green().Color)
06        else
07            sc(err,BrickColor.Red().Color)
08        end
09        end
10        compile(msg)
11end)

1 answer

Log in to vote
0
Answered by
Tomstah 401 Moderation Voter
7 years ago
01Standard.ArrayToString = function(Array)
02    local String = ""
03    for i, v in ipairs(Array) do
04        String = String..tostring(v)
05    end
06    return String
07end
08 
09Standard.StringToArray = function(String)
10    local Array = {}
11    for i = 1, String:len() do
12        table.insert(Array, String:sub(i,i))
13    end
14    return Array
15end

Since I already know what you're doing, here you go! You should see that it works fine.

Ad

Answer this question