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

Replace rednet in 1.63

Started by joebodo, 14 May 2014 - 03:27 AM
joebodo #1
Posted 14 May 2014 - 05:27 AM
Not sure if others are having issues with 1.63 rednet, but here's some code to quickly crash rednet so you can install a replacement (or just leave it removed if you don't need it):


local t = rednet.isOpen
rednet.isOpen = nil    -- will cause the crash

local t2 = term.redirect
term.redirect = function()  -- this is the next method called in the bios if rednet exits
  term.redirect = t2
  rednet.isOpen = t
  print('starting shell')
  os.run(getfenv(1), '/rom/programs/shell')
end

os.queueEvent('modem_message')


You will need to run some shell or program, otherwise, the bios will exit and the computer will shutdown.
Edited on 14 May 2014 - 06:45 AM
CometWolf #2
Posted 14 May 2014 - 06:02 AM
You're overwriting a function which rednet uses with an errornous one. Might aswell just remove it, the result would be the same.
joebodo #3
Posted 14 May 2014 - 06:25 AM
You're overwriting a function which rednet uses with an errornous one. Might aswell just remove it, the result would be the same.

Oops, forgot to post the last line - which is probably causing the confusion.

Just to clarify…
I replace a method that rednet.run will eventually call with one that will cause rednet.run to crash.
I replace the method that is called in bios after rednet aborts with one that will start up a new shell.
I post a 'modem_message' event that rednet.run will process (and lead to the crash).
My second method is then called and I restore everything and start up a new shell.

I do this in order to provide my own rednet.run subsequently.
CometWolf #4
Posted 14 May 2014 - 07:27 AM
What im saying is, this

rednet.isOpen = function()
  print('a' .. t)   -- will cause the crash
end
and this

rednet.isOpen = nil
Would both cause rednet to crash, so you might aswell do the latter.
I suspect that queuing an empty modem_message might cause it to crash right off the bat anyways however.
joebodo #5
Posted 14 May 2014 - 08:48 AM
What im saying is, this

rednet.isOpen = function()
  print('a' .. t)   -- will cause the crash
end
and this

rednet.isOpen = nil
Got it … I updated the OP

I suspect that queuing an empty modem_message might cause it to crash right off the bat anyways however.

The code is pretty good at checking parameters. I don't see an obvious way to crash it by sending a message.

( how about: local t, rednet.isOpen = rednet.isOpen, nil ) :)/>
Edited on 14 May 2014 - 06:51 AM