Difference between revisions of "Peripheral (event)"
From ComputerCraft Wiki
(Created event page) |
m (slight wording tweak) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | |||
− | |||
{{Event | {{Event | ||
|name=peripheral | |name=peripheral | ||
− | |desc=Fired when a peripheral is connected | + | |desc=Fired when a peripheral is connected to the computer locally or remotely (over Network Cables). |
− | |return1= | + | |return1=A [[String_(type)|string]] of the side/name of the connected peripheral. |
+ | }} | ||
+ | {{Example | ||
+ | |desc=Prints the type of peripheral and the side of the peripheral when attached | ||
+ | |code= | ||
+ | while true do | ||
+ | local event, side = os.pullEvent("peripheral") | ||
+ | print("A "..peripheral.getType(side).." has been attached on the "..side) | ||
+ | end | ||
+ | }} | ||
+ | {{Example | ||
+ | |desc=Prints if a modem is attached to the computer. | ||
+ | |code= | ||
+ | while true do | ||
+ | local event, side = os.pullEvent("peripheral") | ||
+ | if peripheral.getType(side) == "modem" then | ||
+ | print("A modem has been attached!") | ||
+ | end | ||
+ | end | ||
}} | }} |
Latest revision as of 11:19, 25 March 2014
Event peripheral | |
Fired when a peripheral is connected to the computer locally or remotely (over Network Cables). | |
Returned Object 1 | A string of the side/name of the connected peripheral. |