This component is provided by network cards. Wireless network cards behave much like normal network cards, but additionally send the message as a wireless “packet” when a strength is set. The modem's address must be used for networking. It can be found through component.modem.address.
NOTE: The modem component only works with in-game networks. For out-of-game connections see the internet card.
Component name: modem.
Callbacks:
isWireless(): booleanmaxPacketSize(): number"foo" is a 5-byte packet; two bytes of overhead and a three byte string."currentStatus",300 is a 25-byte packet; four bytes overhead, a 13-byte string, and 8 bytes for a number.isOpen(port: number): booleanopen(port: number): booleantrue if the port was opened, false if it was already open. Note: maximum port is 65535
close([port: number]): booleansend(address: string, port: number[, ...]): booleantrue if the message was sent. This does not mean the message was received, only that it was sent. No port-sniffing for you.broadcast(port: number, ...): booleantrue if the message was sent. Note that broadcast messages are not delivered to the modem that sent the message.send.getStrength(): numbersetStrength(value: number): numbergetWakeMessage():stringsetWakeMessage(message: string, [fuzzy: boolean]):string
This component generates a signal named modem_message if a message from another network card is received.
It has the signature localAddress: string, remoteAddress: string, port: number, distance: number, ....
localAddress is the address of the modem component the message was received by.remoteAddress is the address of the network card the message was sent from.port is the port number the message was delivered to.distance is the distance to the modem that sent the message. This is only set for wireless messages. For normal messages this is always 0.... in send and broadcast).Example use:
local component = require("component") local event = require("event") local m = component.modem -- get primary modem component m.open(123) print(m.isOpen(123)) -- true -- Send some message. m.broadcast(123, "this is a test") -- Wait for a message from another network card. local _, _, from, port, _, message = event.pull("modem_message") print("Got a message from " .. from .. " on port " .. port .. ": " .. tostring(message))
| Components | 3D Printer - Abstract Bus - Access Point - Chunkloader - Computer - Crafting - Data Card - Database - Debug - Drone - Drive - EEPROM - Experience - Filesystem - Generator - Geolyzer - GPU - Hologram - Internet - Inventory Controller - Leash - Microcontroller - Modem - Motion Sensor - Navigation - Net Splitter - Piston - Redstone - Redstone in Motion - Robot - Screen - Sign - Tank Controller - Tractor Beam - Transposer - Tunnel - World Sensor | |
|---|---|---|
| Others | Component Access - Signals | |
| Cross-Mod Integration | Applied Energistics |