1 posts
Posted 14 April 2013 - 03:15 PM
Hi all,
I have wrote a programe on my computer and was wondering how i could get my computer to broadcast the programe to multiple turtles so that they will run the command.
I have my startup programs wrote on both my turtles and my computer so that rednet is enabled when started up.
645 posts
Location
'Merica
Posted 14 April 2013 - 03:35 PM
Simple, have the sender send the pastebin code, then have the receiving
computers turtles with this.
rednet.open("right")
id, msg = rednet.recieve() -- I don't care if this way is outdated, it works
shell.run("pastebin","get",msg,"startup") -- Fill free to change "startup" to what ever, but that will be what the program will be called
EDIT: I looked it up, the turtles modem side should be right… lol not left. But make sure you are sending the pastebin code, it should look something like "VYmLLCd0", MAKE SURE TO HAVE http enabled.
1583 posts
Location
Germany
Posted 14 April 2013 - 03:37 PM
Okay, i don't know if i understand you right but i try to help you.
Your program must be on all turtles.
The startup of the turtles can be coded like this:
modemSide = ("back")
programName = ("program")
if not rednet.isOpen(modemSide) then
rednet.open(modemSide)
end
function receive()
local id, message, distance = rednet.receive()
end
receive()
if message == ("runTheProgram") then
shell.run(programName)
else
receive()
end
And the code on your computer can be coded like this:
modemSide = ("back")
arg = ("run")
write("Input:")
input = read()
if input == ( arg ) then
if not rednet.isOpen(modemSide)
rednet.open(modemSide
end
rednet.broadcast("runTheProgram")
sleep(0.5)
rednet.close(modemSide)
elseif input == ("Debug") then
return
else
print("wrong arg")
end
I hope I can help you :)/>/>
645 posts
Location
'Merica
Posted 14 April 2013 - 03:58 PM
Okay, i don't know if i understand you right but i try to help you.
Your program must be on all turtles.
The startup of the turtles can be coded like this:
modemSide = ("back")
programName = ("program")
if not rednet.isOpen(modemSide) then
rednet.open(modemSide)
end
function receive()
local id, message, distance = rednet.receive()
end
receive()
if message == ("runTheProgram") then
shell.run(programName)
else
receive()
end
And the code on your computer can be coded like this:
modemSide = ("back")
arg = ("run")
write("Input:")
input = read()
if input == ( arg ) then
if not rednet.isOpen(modemSide)
rednet.open(modemSide) -- you forgot to do ')'
end
rednet.broadcast("runTheProgram")
sleep(0.5)
rednet.close(modemSide)
elseif input == ("Debug") then
return
else
print("wrong arg")
end
I hope I can help you :)/>
Thats not what he/she was asking…………………. but on an other note, you code very sloppy, as a suggestion, space! Also no need to close the modem, if he/she wanted to control the turtle wireless, closing the modem would be extremely stupid. Also there was an error with your code, AND (not to be an asshole) don't do "write("Input: ")" because now your next "print" will be on that line. Do "term.write("")" instead, also you should have your variables be local not open, like "local arg = blah" ect. So if he/she wants to use this program from an other program, they wont have a conflict with the variables possibly being the same…. especially when a lot of people like to call the users input "input" and they usually never switch variables…
1583 posts
Location
Germany
Posted 14 April 2013 - 04:09 PM
Okay, i don't know if i understand you right but i try to hel you
Your program must be on all turtles.
The startup of the turtles can be coded like this:
modemSide = ("back")
programName = ("program")
if not rednet.isOpen(modemSide) then
rednet.open(modemSide)
end
function receive()
local id, message, distance = rednet.receive()
end
receive()
if message == ("runTheProgram") then
shell.run(programName)
else
receive()
end
And the code on your computer can be coded like this:
modemSide = ("back")
arg = ("run")
write("Input:")
input = read()
if input == ( arg ) then
if not rednet.isOpen(modemSide)
rednet.open(modemSide) -- you forgot to do ')'
end
rednet.broadcast("runTheProgram")
sleep(0.5)
rednet.close(modemSide)
elseif input == ("Debug") then
return
else
print("wrong arg")
end
I hope I can help you :)/>/>
Thats not what he/she was asking…………………. but on an other note, you code very sloppy, as a suggestion, space! Also no need to close the modem, if he/she wanted to control the turtle wireless, closing the modem would be extremely stupid. Also there was an error with your code, AND (not to be an asshole) don't do "write("Input: ")" because now your next "print" will be on that line. Do "term.write("")" instead, also you should have your variables be local not open, like "local arg = blah" ect. So if he/she wants to use this program from an other program, they wont have a conflict with the variables possibly being the same…. especially when a lot of people like to call the users input "input" and they usually never switch variables…
Okay.
Yes, my code is sloppy because I quick write it on my Smartphone. Not the best method to write (long) texts
To the variables:
See above
I'm sorry that i missunderstood he/she .
645 posts
Location
'Merica
Posted 14 April 2013 - 04:13 PM
@Freack
Don't be sorry, I know I sounded rude. But everyone makes mistakes, so you don't have to be sorry. And I also sometimes code on my Smartphone as well, and I know its a pain to make your code look nice.
173 posts
Posted 16 April 2013 - 06:49 PM
telly can you rephrase question? I can see three ways to take you question.
1. You want to tell turtles to run program you already have.
2. You want them to download pastebin program.
3. You want to download a program that is on the computer in game to your in game turtles.
If it is one of these three could you say so we know what you want or if neither of theses explain better.
645 posts
Location
'Merica
Posted 16 April 2013 - 06:58 PM
^
I already answered it, he wanted to have the turtle receive a file through rednet (which you can do that stand alone) so I made him a program that should work.
173 posts
Posted 16 April 2013 - 07:55 PM
ok i dont see where you did that ill trust you just didn't see red net file transfer mentioned and since thats what i thought he wanted i thought id bring it up.