Difference between revisions of "Disk (event)"

From ComputerCraft Wiki
Jump to: navigation, search
(Added example.)
(added links and some cleanup)
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{NeedsWork|A demonstration on the use and handling of this event would be beneficial. ''[[User:AfterLifeLochie|AfterLifeLochie]] 16:13, 30 November 2012 (MSK)''}}
 
 
 
{{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 [[Floppy Disk]] is inserted into any [[Disk Drive]] connected to the computer locally or remotely (over Network 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
|desc=Play any music disk put into a connected disk drive, and print the title.
+
|desc=Print a message when a disk is inserted into a connected disk drive.
 
|code=
 
|code=
 
  while true do
 
  while true do
   event, side = os.pullEvent("disk")
+
   local event, side = os.pullEvent()
   if disk.hasAudio(side) then
+
   if event == "disk" then
    disk.playAudio(side)
+
     print("Disk was inserted: "..side)
     print("Playing music disk: ", disk.getAudioTitle(side))
+
 
   end
 
   end
 
  end
 
  end
|output=The title of any music disk put into a connected disk drive.
 
 
}}
 
}}

Latest revision as of 10:06, 28 October 2013



Grid Modem.png  Event disk
Fired when a Floppy Disk is inserted into any Disk Drive connected to the computer locally or remotely (over Network 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()
  if event == "disk" then
    print("Disk was inserted: "..side)
  end
end