Peripheral (event)

From ComputerCraft Wiki
Revision as of 16:00, 6 May 2013 by AfterLifeLochie (Talk | contribs) (Please don't remove {{NeedsWork}} without proofreading document contents.)

Jump to: navigation, search



Grid Modem.png  Event peripheral
Fired when a peripheral is connected (directly adjacent) to the computer.
Returned Object 1 The string value of the side of the connected peripheral.


Grid paper.png  Example
Prints the type of peripheral and the side of the peripheral when attached
Code
while true do
  event, side = os.pullEvent("peripheral")
  print("A "..peripheral.getType(side).." has been attached on the "..side)
end



Grid paper.png  Example
Prints if a modem is attached to the computer.
Code
while true do
 event, side = os.pullEvent("peripheral")
 if peripheral.getType(side) == "modem" then
   print("A modem has been attached!")
   break
 end
end