Peripheral

Eventperipheral
Occurs every time a peripheral is attached.
Returns
  • name : string The side or network name of the peripheral that was attached.
Part of CC:Tweaked
See also Peripheral detach event
ExampleAlert on peripheral attachment
Waits for a peripheral to be attached and alerts the user what type of peripheral was attached.
Code
<nowiki>
local event, peripheral_name = os.pullEvent("peripheral")
local peripheral_type = peripheral.getType(peripheral_name)
print("A", peripheral_type, "has been attached.")
    </nowiki>
Eventperipheral_detach
Occurs every time a peripheral is detached.
Returns
  • name : string The side or network name of the peripheral that was detached.
Part of CC:Tweaked
See also Peripheral event
ExampleAlert on peripheral detachment
Waits for a peripheral to be detached and alerts the user when it occured.
Code
<nowiki>
local event, peripheral_name = os.pullEvent("peripheral_detach")
print("Peripheral", peripheral_name, "has been detached.")
    </nowiki>
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.