Modem API

From ComputerCraft
Jump to navigation Jump to search
FunctionFunctionmodem.close
Closes a channel on a modem. A channel must be open to receive messages from it. A modem can only have 128 channels open at the same time. channel must be a number between 0 and 65535.
Syntax modem.close()
Returns nil
Part of CC:Tweaked (source)
API modem
ExampleExampleClose channel 42
Close channel 42.
Code
local modem = peripheral.find("modem")
modem.close(42)


FunctionFunctionmodem.closeAll
Closes all channels on a modem. A channel must be open to receive messages on it. A modem can only have 128 channels open at the same time.
Syntax modem.closeAll()
Returns nil
Part of CC:Tweaked (source)
API modem
ExampleExampleClose all channels
Close all channels.
Code
local modem = peripheral.find("modem")
modem.closeAll()


FunctionFunctionmodem.isOpen
Checks if a channel is open. A channel must be open to receive messages on it. A modem can only have 128 channels open at the same time. channel must be a Number between 0 and 65535.
Syntax modem.isOpen()
Returns boolean open
Part of CC:Tweaked (source)
API modem
ExampleExampleCheck if channel 42 is open
Check if channel 42 is open.
Code
local modem = peripheral.find("modem")
print(modem.isOpen(42))
Output
true


FunctionFunctionmodem.isWireless
Returns whether the modem is wireless.
Syntax modem.isWireless()
Returns boolean isWireless
Part of CC:Tweaked (source)
API modem
ExampleExampleCheck whether a modem is a wireless modem
Checks whether a modem is a wireless modem.
Code
local modem = peripheral.find("modem")
print(modem.isWireless())
Output
true


FunctionFunctionmodem.open
Opens a channel on a modem. A channel must be opened to receive messages from it. A modem can only have 128 channels open at the same time. channel must be a number between 0 and 65535.
Syntax modem.open()
Returns nil
Part of CC:Tweaked (source)
API modem
ExampleExampleOpen channel 42
Open channel 42.
Code
local modem = peripheral.find("modem")
modem.open(42)


FunctionFunctionmodem.transmit
Sends a modem message to a certain channel. If the modem is wired this will queue a modem_message event on all computers connected to the wired network that have the specified channel open. If the modem is wireless it will queue a modem_message event on all computers in range that have the specified channel open. Note Note: To send a message the channel it is being sent from does not need to be open.
Syntax modem.transmit()
Returns nil
API modem
ExampleExampleSend a message on channel 42
Sends a "Hello World" on channel 42.
Code
local modem = peripheral.find("modem")
modem.transmit(42, 43, "Hello World")