Difference between revisions of "Disk (event)"

From ComputerCraft Wiki
Jump to: navigation, search
(Changed example description to match new example code)
(Slightly better description updated for network cables, also better coding habits)
Line 1: Line 1:
 
{{Event
 
{{Event
 
|name=disk
 
|name=disk
|desc=Fired when a disk is inserted into any connected (directly adjacent to) disk drive.
+
|desc=Fired when a disk is inserted into any disk drive connected to the computer locally or remotely (over peripheral cables).
|return1=The [[String_(type)|String]] value of the side of the disk drive.
+
|return1=The [[String_(type)|String]] value of the side/name of the disk drive.
 
}}
 
}}
 
{{Example
 
{{Example
Line 8: Line 8:
 
|code=
 
|code=
 
  while true do
 
  while true do
   event, side = os.pullEvent("disk")
+
   local event, side = os.pullEvent("disk")
 
   if event == "disk" then
 
   if event == "disk" then
 
     print("Disk has been inserted")
 
     print("Disk has been inserted")

Revision as of 09:59, 28 October 2013



Grid Modem.png  Event disk
Fired when a disk is inserted into any disk drive connected to the computer locally or remotely (over peripheral cables).
Returned Object 1 The String value of the side/name of the disk drive.


Grid paper.png  Example
Print a message when a disk is inserted into a connected disk drive.
Code
while true do
  local event, side = os.pullEvent("disk")
  if event == "disk" then
    print("Disk has been inserted")
  end
end
Output Notification once the disk has been inserted.