Jump to content




Please Help this program.


  • You cannot reply to this topic
13 replies to this topic

#1 norway240

  • Members
  • 4 posts

Posted 02 September 2012 - 03:07 AM

So all i want this program to do is on one computer be able to send a message to a turtle and have the turtle receive that message and it will run that program. So what i have works with sending commands with no args. for example: you send the message: help. and the turtle will run the program: help. But if you send the message: help programs, then it says: No such program.. Here is the code i've written:

Client (program on the turtle) :
while true do
rednet.open("right")
x,y,z=rednet.receive()
print(y)
shell.run(y)
end

Server (program on the computer) :
while true do
write"Command: "
input = read()
rednet.open("top")
rednet.broadcast(input)
end


#2 Matrixmage

  • Members
  • 116 posts
  • LocationAt my Computer coding for the Computer in my Computer

Posted 02 September 2012 - 03:11 AM

try making x,y,z into x, y, z , I don't know if that would help, it might though, I've seen some people have problems with having their syntax like that

#3 dcleondc

  • New Members
  • 70 posts

Posted 02 September 2012 - 03:13 AM

it should be input = io.read() not input = read()

#4 Matrixmage

  • Members
  • 116 posts
  • LocationAt my Computer coding for the Computer in my Computer

Posted 02 September 2012 - 03:18 AM

I've never noticed that making a difference, don't know if that as anything to do with me using 1.3 (tekkit) rather then 1.4

#5 dcleondc

  • New Members
  • 70 posts

Posted 02 September 2012 - 03:23 AM

you can do read()? because i always use io.read()

#6 Matrixmage

  • Members
  • 116 posts
  • LocationAt my Computer coding for the Computer in my Computer

Posted 02 September 2012 - 03:38 AM

View Postdcleondc, on 02 September 2012 - 03:23 AM, said:

you can do read()? because i always use io.read()
ya, I've always used "read()" didn't know about "io.read()" until a few days ago

#7 dcleondc

  • New Members
  • 70 posts

Posted 02 September 2012 - 03:38 AM

code for console
id = 17 --replace with id of your turtle
rednet.open("right")
print("what program do you want to run?")
program = io.read()
rednet.send(id, program)
code for turtle
rednet.open("right")
while true do
    local x, y, z = rednet.recive(timeout)
    shell.run(y)
end


#8 Matrixmage

  • Members
  • 116 posts
  • LocationAt my Computer coding for the Computer in my Computer

Posted 02 September 2012 - 03:39 AM

I think that "read()" is from the OS API but I'm not sure

#9 norway240

  • Members
  • 4 posts

Posted 02 September 2012 - 04:44 AM

View Postdcleondc, on 02 September 2012 - 03:38 AM, said:

code for console
id = 17 --replace with id of your turtle
rednet.open("right")
print("what program do you want to run?")
program = io.read()
rednet.send(id, program)
code for turtle
rednet.open("right")
while true do
	local x, y, z = rednet.recive(timeout)
	shell.run(y)
end
Still does the same thing. when i type in: refuel. then it refuels but when i do: refuel all. then it says no such program.

#10 dcleondc

  • New Members
  • 70 posts

Posted 02 September 2012 - 05:12 AM

thats because refuel all is not a program, refuel is and when you type all it is a arg and you cant send args with how i did it

#11 norway240

  • Members
  • 4 posts

Posted 02 September 2012 - 05:20 AM

View Postdcleondc, on 02 September 2012 - 05:12 AM, said:

thats because refuel all is not a program, refuel is and when you type all it is a arg and you cant send args with how i did it
i know. the thing is i was wondering how you could send args. do you know how you can?

#12 dcleondc

  • New Members
  • 70 posts

Posted 02 September 2012 - 05:38 AM

console
id = 17
rednet.open("right")
print("what program do you want to run")
program = io.read()
print("what arg do you want to send")
arg = io.read()
rednet.send(id, program)
rednet.send(id, arg)
shell.run("startup")
turtle
rednet.open("right")
while true do
    local x, y, z = rednet.receive(timeout)
    local x, y, z = rednet.receive(timeout)
    shell.run(y,a)
end


#13 Zoinky

  • Members
  • 144 posts
  • LocationWellington, New Zealand

Posted 02 September 2012 - 01:30 PM

View PostBigSHinyToys, on 31 August 2012 - 10:16 AM, said:

Try this
run it on a turtle and a computer.
Spoiler

Had the same problem a little while ago. This worked :D/> All credit goes to BigSHinyToys. You can run it on both the computer and turtle.

#14 BigSHinyToys

  • Members
  • 1,001 posts

Posted 02 September 2012 - 01:37 PM

this is odd I was looking for that thread and was going to copy the code here. I was ninjaed :D/> with my own code lol XD . Any questions about the code ask and I will explain.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users