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

Rednet

Started by wolfcraft12, 24 January 2013 - 02:23 PM
wolfcraft12 #1
Posted 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.
tesla1889 #2
Posted 24 January 2013 - 03:28 PM
send the file in string form
tesla1889 #3
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)
wolfcraft12 #4
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
theoriginalbit #5
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.
NeverCast #6
Posted 24 January 2013 - 03:35 PM
Excellent.
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)
wolfcraft12 #7
Posted 24 January 2013 - 04:43 PM
Excellent.
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)
I seem to be getting an error on this with your line 3
theoriginalbit #8
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
wolfcraft12 #9
Posted 24 January 2013 - 05:01 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

I hate to ask you but do you want to come on my server and help me i am running a tekkit classic server
theoriginalbit #10
Posted 24 January 2013 - 05:02 PM
sure just PM me the details.
wolfcraft12 #11
Posted 24 January 2013 - 05:09 PM
sure just PM me the details.
its 198.15.110.115