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

Run a floppy disk during a while loop?

Started by oyasunadev, 05 November 2012 - 11:48 AM
oyasunadev #1
Posted 05 November 2012 - 12:48 PM
Okay, so lets say I have a computer that has a while loop that asks for a password. So I don't want to destroy that computer, but I want to run code from a disk while the other program is up, without having to reboot the computer. Is this possible? Some kind of virus?
Mitchfizz05 #2
Posted 25 November 2012 - 09:23 PM
I think you would need to look into the parallel API; I don't know much about the parallel API though.
JoshhT #3
Posted 25 November 2012 - 09:33 PM
You might want to look into the disk API.

Something like this.


driveSide = "left"
while true do
  if disk.isPresent(driveSide) and disk.hasData(driveSide) then
    os.run({}, "program on disk")
    sleep(1)
    disk.eject(driveSide)
  end
sleep(2)
end
Laserman34170 #4
Posted 26 November 2012 - 05:31 AM
Use the parallel API.http://computercraft.info/wiki/index.php?title=Parallel

function disk()
  -- do the disk running stuff here
end


function pass()
  -- do the pass stuff here
end

while true do
  parallel.waitForAny(disk, pass)
end
ChunLing #5
Posted 26 November 2012 - 07:05 AM
Isn't the whole point of having a password loop to prevent the computer from doing anything until the password is entered?