Posted 19 May 2013 - 04:54 PM
I recently posted a forum regarding the topic. One guy tried to help and this is what he came up with. The only problem is it has errors.
So basicly I want a program that has a read() function that gets user input and seprates the input in to arguments.
He came up with this code
He said run the function with cmd = { prompt() }
the only problem is the prompt() function returns errors
So basicly I want a program that has a read() function that gets user input and seprates the input in to arguments.
He came up with this code
Spoiler
local function prompt()
-- Read all of the arguments in as a single string.
local cmd = read()
-- Split all of the arguments in the string in 'cmd' by spaces.
local args = {}
-- The "[^%s]+" pattern is used to match any sequence of non-space characters
-- with a size of >= 1.
for match in string.gmatch (match, "[^%s]+") do
table.insert (args, match)
end
-- Return all of the arguments as a table.
return args
end
He said run the function with cmd = { prompt() }
the only problem is the prompt() function returns errors