Posted 05 June 2013 - 06:49 PM
Title: [LUA] shell.run -> bad argument: string expected
Hi,
I have made a program called: "paste". I want to run it with shell.run(). The problem I have with shell.run() is that it gives me an error when I give it an argument, it has to be a string but I want it to use the output of a function. the variable command is "pastebin btUYgsHK"
I think people are going to ask: "Why do you want to do it this way?"
Let me explain: I'm using miscperipherals and I want to create a fully chat controlled computer using the ChatBox. The only thing that doesn't work is this error.
Hi,
I have made a program called: "paste". I want to run it with shell.run(). The problem I have with shell.run() is that it gives me an error when I give it an argument, it has to be a string but I want it to use the output of a function. the variable command is "pastebin btUYgsHK"
function get_command(command)
local a = string.find(command," ")
if a == nil then
return false
else
return string.sub(command,0,a)
end
end
function get_argument(t)
local a = string.find(t," ")
if a == nil then
return false
else
return string.sub(command,a)
end
end
first I did:
if get_command(command) == "pastebin" then
shell.run("paste",get_argument(command))
m.write("Pastebin accepted")
end
it gave me the error: "bad argument: string expected, got function". So i tried using a variable instead.
if get_command(command) == "pastebin" then
local argument = get_argument(command)
shell.run("paste",argument)
m.write("Pastebin accepted")
end
I still get the same error as before. Is it possible what I want to do or not? and if so what am I doing wrong?I think people are going to ask: "Why do you want to do it this way?"
Let me explain: I'm using miscperipherals and I want to create a fully chat controlled computer using the ChatBox. The only thing that doesn't work is this error.