Posted 12 May 2013 - 12:12 AM
I was making a kind of console program. I wanted an on a read() to store everything into arguments.
So, basically I want it to get input from the user and store it to command and extra arguments.
I have some of the program done but I need help with the arguments.
I know there are errors but mainly i just want to finish the the function prompt().
prompt is supposed to get input and store it to arguments with the first being the command to execute
I can handle the errors myself that is not the problem.
So, basically I want it to get input from the user and store it to command and extra arguments.
I have some of the program done but I need help with the arguments.
function dir(dir)
shell.run("cd", dir)
return dir
end
function prompt(...)
cmd = read()
for i = 1, #arg do
return arg[i]
end
end
dir = dir("system")
while true do
cmd = prompt()
for com, arg in pairs(cmd) do
if com == "exit" then
shell.run("cd", "/")
break
end
if run == "run" then
shell.run(arg)
end
end
end
I know there are errors but mainly i just want to finish the the function prompt().
prompt is supposed to get input and store it to arguments with the first being the command to execute
I can handle the errors myself that is not the problem.