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

API Help

Started by Creeper9207, 27 July 2015 - 08:33 AM
Creeper9207 #1
Posted 27 July 2015 - 10:33 AM
so, I was wondering if there was a way to prevent a program from doing os.reboot() or os.shutdown(), or have a confirmation dialog, also, os.pullEvent = os.pullEventRaw doesnt seem to block terminate for me
flaghacker #2
Posted 27 July 2015 - 10:47 AM
You can overwrite a function like os.shutdow
n:


local oldShutdown = os.shutdown

os.shutdown = function ()
  print ("are you sure?")
  if read () == "yes" then
    oldShutdown ()
  end
end

The pullRaw trick may not work when you're doing it inside an api, try it in your maun program. Make sure it's at the top of your program too.
Creeper9207 #3
Posted 27 July 2015 - 02:04 PM
nice! thanks