This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Kraethi's profile picture

Using Received Rednet Message As Argument?

Started by Kraethi, 17 October 2013 - 08:01 PM
Kraethi #1
Posted 17 October 2013 - 10:01 PM
Hey, I'm pretty new to ComputerCraft so this question will probably be quickly answered.
I essentially want a computer to run the contents of every rednet message it receives as a program. I can't figure out exactly how to do that.


rednet.open("back")
while true do
  event, id, text = os.pullEvent()
  if event == "rednet_message" then
   shell.run("text")
  end
end

This is what I came up with off the top of my head, but of course it will just try to run the program "text". How do I use the content of the message as the arguent in this program? I'd like to avoid the multitude of elseifs I'd have to use otherwise.
Lyqyd #2
Posted 17 October 2013 - 10:17 PM
Get rid of the quotes around "text".
Kraethi #3
Posted 17 October 2013 - 10:24 PM
Oh. Well, that was simple. Thanks!
campicus #4
Posted 17 October 2013 - 10:48 PM
Get rid of the quotes around "text".

This is because you are calling the variable, you are not printing the string "text".

e.g., these will print the same thing:

print("hello world")

local text = "hello world"
print(text)