This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
Rednet
Started by wolfcraft12, 24 January 2013 - 02:23 PMPosted 24 January 2013 - 03:23 PM
I very new to red net and I have aquired a need to learn it and I cant understand some tutorials that I have read and watched if anyone has any tips on how to tell a computer to run a certian file from anouther please tell me in the comments. Yes I do understand this probably really easy.
Posted 24 January 2013 - 03:28 PM
send the file in string form
Posted 24 January 2013 - 03:30 PM
rednet.open("side_that_the_modem_is_on")
rednet.send(id_of_computer_to_send_to, string_of_text_from_file)
then execute it using loadstring(string_to_load_into_a_function)
rednet.send(id_of_computer_to_send_to, string_of_text_from_file)
then execute it using loadstring(string_to_load_into_a_function)
Posted 24 January 2013 - 03:31 PM
I am very sorry but I am sorta new I dont understand I dnt want to send files I just want a computer to run the file already installed on a different computer
Posted 24 January 2013 - 03:33 PM
the only way is to send the file to the other computer as a rednet message. this cannot be avoided if you want one to run from another.
Posted 24 January 2013 - 03:35 PM
Excellent.
Well you need a computer that is a server.
And a client
Well you need a computer that is a server.
local whitelist = { 5, 10 } -- Computers 5 and 10 are allowed to tell this computer what to do
for i = 1, #rs.getSides() do -- yes I could use pairs, but I didn't
if peripheral.getType(rs.getSides()[i]) == "modem" then
rednet.open(rs.getSides()[i])
end
end
while true do
local id, message, distance = rednet.receive()
for i,v in pairs(whitelist) do
if v == id then -- is allowed!
shell.run(message)
end
end
end
And a client
local computer = tonumber(io.read())
local program = io.read()
rednet.open("some side that you put the modem on")
rednet.send(computer, program)
Posted 24 January 2013 - 04:43 PM
I seem to be getting an error on this with your line 3Excellent.
Well you need a computer that is a server.local whitelist = { 5, 10 } -- Computers 5 and 10 are allowed to tell this computer what to do for i = 1, #rs.getSides() do -- yes I could use pairs, but I didn't if peripheral.getType(rs.getSides()[i]) == "modem" then rednet.open(rs.getSides()[i]) end end while true do local id, message, distance = rednet.receive() for i,v in pairs(whitelist) do if v == id then -- is allowed! shell.run(message) end end end
And a clientlocal computer = tonumber(io.read()) local program = io.read() rednet.open("some side that you put the modem on") rednet.send(computer, program)
Posted 24 January 2013 - 04:45 PM
just change that whole loop (lines 2 - 6) to this
for _,v in pairs( rs.getSides() ) do
if peripheral.getType( v ) == "modem" then
rednet.open( v )
end
end
Posted 24 January 2013 - 05:01 PM
just change that whole loop (lines 2 - 6) to thisfor _,v in pairs( rs.getSides() ) do if peripheral.getType( v ) == "modem" then rednet.open( v ) end end
I hate to ask you but do you want to come on my server and help me i am running a tekkit classic server
Posted 24 January 2013 - 05:02 PM
sure just PM me the details.
Posted 24 January 2013 - 05:09 PM
its 198.15.110.115sure just PM me the details.