Difference between revisions of "Modem.isOpen"

From ComputerCraft Wiki
Jump to: navigation, search
(Created page with "{{Function |name=modem.isOpen |args=int channel |api=Modem |addon=ComputerCraft |desc=Checks whether or not a certain channel is open. |examples= {{Example |de...")
 
 
(8 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 
{{Function
 
{{Function
|name=modem.isOpen
+
|name=''modem''.isOpen
|args=[[Int (type)|int]] channel
+
|args={{type|number}} channel
 +
|returns={{type|boolean}} is channel open?
 
|api=Modem
 
|api=Modem
 
|addon=ComputerCraft
 
|addon=ComputerCraft
Line 7: Line 8:
 
|examples=
 
|examples=
 
{{Example
 
{{Example
|desc=Checks whether the computer is listening on this channel.  
+
|desc=Checks whether the computer is listening on channel 5.  
|code=modem.isOpen(1)
+
|code= local modem = [[peripheral.wrap]]("top")
 +
 +
if '''modem.isOpen(5)''' then
 +
  print("The computer is listening on channel 5.")
 +
else
 +
  print("The computer is not listening on channel 5.")
 +
end
 +
|output=Whether or not channel 5 is open.
 
}}
 
}}
 
}}
 
}}
 +
 +
[[Category:API_Functions]]

Latest revision as of 17:48, 10 April 2014

Grid Redstone.png  Function modem.isOpen
Checks whether or not a certain channel is open.
Syntax modem.isOpen(number channel)
Returns boolean is channel open?
Part of ComputerCraft
API Modem

Examples

Grid paper.png  Example
Checks whether the computer is listening on channel 5.
Code
local modem = peripheral.wrap("top")

if modem.isOpen(5) then
  print("The computer is listening on channel 5.")
else
  print("The computer is not listening on channel 5.")
end
Output Whether or not channel 5 is open.