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

Emergancy Shutdown Floppy, Is It Possible?

Started by Pigbear, 04 August 2013 - 06:30 PM
Pigbear #1
Posted 04 August 2013 - 08:30 PM
Emergancy Shutdown Floppy disks, Are they possible to make? If so that may be pretty useful.
Lyqyd #2
Posted 04 August 2013 - 08:40 PM
What would an "emergency shutdown floppy" do?
Pigbear #3
Posted 04 August 2013 - 08:44 PM
Shut down a computer.
campicus #4
Posted 04 August 2013 - 10:13 PM
Firstly, I don't know.
Secondly, some advice before a pro gets on and gives you better info. You would need a function like:


function turnOff()
    while true do
        local event, side = os.pullEvent()
        if event == "disk" then
            os.shutdown()
        end
        sleep(1)
    end
end

Which runs parallel to whatever your program is doing in the meantime. This might work?
immibis #5
Posted 05 August 2013 - 03:04 AM
Firstly, I don't know.
Secondly, some advice before a pro gets on and gives you better info. You would need a function like:


function turnOff()
    while true do
        local event, side = os.pullEvent()
        if event == "disk" then
            os.shutdown()
        end
        sleep(1)
    end
end

Which runs parallel to whatever your program is doing in the meantime. This might work?
sleep(1) might cause you to miss a disk event if it happens in that one second after a different event.

No, you can't make a floppy that shuts down a computer when inserted, unless the computer is already running code which expects that possibility.
GopherAtl #6
Posted 05 August 2013 - 03:07 AM
immibis is correct; Just want to add that if you need to shut down a computer in a hurry, your best bet is ctrl+s, which will force a computer to shut down, whether the program wants to or not.