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

Rednet computer remote control

Started by Glotz659, 23 July 2012 - 06:29 AM
Glotz659 #1
Posted 23 July 2012 - 08:29 AM
I'm not sure if this has already been done by someone else, but here's my rednet remote controll for computers and turtles.

Features:
  • Send any command over rednet - you don't need to define them in the server code
Code:
  • Receiver:

side = "back"
password = "InsertYourPasswordHere!"
rednet.open(side)
while true do
id, msg = rednet.receive()
a = textutils.unserialize(msg)
if a[1] == password then
file = fs.open("tempfile", "a")
for i = 2, #a do
file.write(a[i])
end
file.close()
shell.run("tempfile")
fs.delete("tempfile")
end
end
  • Sender:

tCommand = {"InsertYourPasswordHere!", "Command ", "Arguments"
a = textutils.serialize(tCommand)
rednet.broadcast(a)

WARNING:
You need Spaces (" ") between the command itself and the arguments! you can either use
"Command ", "Arg1 ", "Arg2"
or
"Command", " ", "Arg1", " ", "Arg2"

And if you need Quotes inside Quotes, for example

"print('AnyOutput')"
then you need to use " to define your string and ' for a string inside your string :)/>/>

Example usages:
  • Take any wireless mining turtle, place it in front of a computer with the mining script and watch it search diamonds for you.
  • Have a computer connected to a monitor and control it via console
Changelog:


V Alpha 0.2: Added Password function!
V Alpha 0.1: first release!

Future plans:

some Functions: sendCommand(password, command) and receiveCommand(password)
Noodle #2
Posted 23 July 2012 - 10:58 AM
Ohh, I see.
BTW the string sending doesn't work since you are doing
rednet.broadcast("print("blah")")
That will send "print(" and then give an error.
Pinkishu #3
Posted 23 July 2012 - 11:49 AM
Just use loadstring/dostring?
Cranium #4
Posted 23 July 2012 - 10:01 PM
Can't you just do rednet.broadcast("print", ("blah"))? New to programming, but just starting to understand some of the syntax and lexicon (just the tip of the iceberg, mind you)
Edited on 23 July 2012 - 08:02 PM
Noodle #5
Posted 24 July 2012 - 12:14 AM
No, you can't. They work like arguments. Using "," separates the arguments, therefore not sending correctly.
Glotz659 #6
Posted 24 July 2012 - 07:54 AM
Ohh, I see.
BTW the string sending doesn't work since you are doing
rednet.broadcast("print("blah")")
That will send "print(" and then give an error.
I had that "bug", too, but here's the solution: Just use different quotes, for example ' instead of " inside the string and it will work (tested :)/>/> )

rednet.broadcast("print('Blah')")
BigSHinyToys #7
Posted 24 July 2012 - 08:30 AM
multi line quotes
example

print([[
hello there

again
]])
will produce
hello there

again
>_
I think you could use "" '' or , inside one of them and it should work fine.
eg

rednet.broadcast([[print("Blah")]])

only thing you can't put in a multi line quote is a multi line quote.
Noodle #8
Posted 24 July 2012 - 08:33 AM
^ Both of those will work
Just don't send too much, it lags the longer the string it is.
Lyqyd #9
Posted 24 July 2012 - 06:49 PM
^ Both of those will work
Just don't send too much, it lags the longer the string it is.

Have you tested that? I've sent large files back and forth in single packets with no noticeable lag whatsoever.
Noodle #10
Posted 24 July 2012 - 08:23 PM
Yes, it's not as noticeable but when other things (server) are happening it seems to lag a bit more.
Cranium #11
Posted 25 July 2012 - 09:51 PM
I have seen it. I have a pretty basic Tekkit server, and with all of the machines, pipes, reactors(yes, reactors) running, I have a hard time using some of the programs with ridiculously long strings.