Difference between revisions of "Wireless Modem"

From ComputerCraft Wiki
Jump to: navigation, search
(Include distance limits)
m (Recipe)
 
(34 intermediate revisions by 21 users not shown)
Line 1: Line 1:
[[File:QJrCF.png|frame|right|The recipe for a modem.]]
+
{{NeedsWork|The behaviour of Rednet has changed as of 1.5 - please consider updating this page with information. (Please don't add prerelease info!)}}
 +
:''This page is for the Modem blocks. For the modem API, see [[Modem_(API)|Modem (API)]]''
 +
{{Block
 +
|name=Modem
 +
|image=WirelessModem.png
 +
|id=ComputerCraft:CC-Peripheral
 +
|damage-value=1
 +
|is-peripheral=Yes
 +
|peripheral-api=Modem (API)
 +
}}
 +
Modems are blocks which can be used to wirelessly transfer data between [[Computer]]s and [[Turtle]]s, using the [[Rednet_(API)|Rednet API]] or the [[Modem_(API)|Modem API]].
 +
To place a modem on a side of a computer, right-click while sneaking.
  
== Description ==
+
It is also possible to turn the modem on and off by typing "[[rednet.open]]( side )" to open and "[[rednet.close]]( side )" to close.
  
'''Modems''' are blocks, which can be used to wirelessly transfer data between computers and turtle, using "rednet" commands.
+
Modems can send messages to other modems located up to 64 meters away, or 16 meters during a thunderstorm.
To place a modem on a side of your computer, sneak and then click right (sneak usually = left Shift key)!
+
As of 1.4 Modem range is increased with higher altitudes. If there is no thunderstorm, the range will always be higher than 64, and at max altitude you would have a range of 384 meters.
  
you can turn the modem on and off by typing in lua: "rednet.open ( side )" - turn on, "rednet.close ( side )" - turn off
+
In 1.4 and 1.41 there is a miscalculation that causes the range to only be 381 meters at max altitude.
  
Modems can send messages to other modems located up to 64 metres away, or 17 metres during a thunderstorm.[http://www.computercraft.info/forums2/index.php?/topic/464-wireless-distance/page__hl__distance__fromsearch__1]
+
As of the 1.5 update for ComputerCraft, Wireless Modems can send messages on specific channels.
  
== example details ==
+
See also: [[Wired Modem]], [[Ender Modem]].
* place 2 computers (or turtles) and add to them the Modem (by placing on the side while being in sneaking mode - LShift)
+
* type "lua" on both
+
* then type "rednet.open (" side where's the modem ")" on both
+
* check that the modems are redlighted a bit = turned on
+
* on the first one type "rednet.receive (60)" - 60 = time to listen in seconds, the computer will be frozen until receiving any message or runing out of time
+
* on the second one type "rednet.broadcast ("hi all")" - "hi all" = message, returns "true"
+
* and now you will see that "hi all" on the first one (the number is computerID, then the message)
+
  
for more help type "help rednet" or get it here: http://computercraft.info/wiki/index.php?title=REDNET
+
== Crafting ==
 +
{{Crafting
 +
|A1=stone |B1=stone      |C1=stone
 +
|A2=stone |B2=ender pearl |C2=stone
 +
|A3=stone |B3=stone      |C3=stone
 +
|Output=Modem
 +
}}
 +
 
 +
== Example (Modem API)==
 +
* Place 2 computers and add modems to them by clicking the right mouse button while sneaking.
 +
* Access them, and start Lua.
 +
* Once Lua has started, wrap your modem using peripheral.wrap() (something like "modem = peripheral.wrap("<side of modem>")
 +
* Type "[[modem_(API)|modem.open]] (<A modem port number, anything from 1 to 65535>)" on one computer.
 +
* Check if there exists a connection: a dim, red light should be found on the modem.
 +
* Now, type "[[modem_(API)|modem.transmit]] (<Same number as above>, <Also the same number>, 'Your message')" on the other computer. This should send your message to all computers connected.
 +
* Opening the first computer should show the message written on the second computer.
 +
 
 +
 
 +
== Modem as a Peripheral ==
 +
To use a Modem as a peripheral, you need to either call a method directly using [[peripheral.call]](), or, wrap the modem using the [[Peripheral_(API)|Peripheral API]]. Wrapped modems provide all functions listed in the [[Modem_(API)|Modem API]].
 +
 
 +
For this example, we have a Modem connected to the top of our [[Computer]], we are going to open channel 5:
 +
 
 +
''-- Immediately invoke a method without wrapping''
 +
[[peripheral.call]]( "top", "open", 5 )
 +
 
 +
''-- You can also "wrap" the peripheral side to a variable:''
 +
local modem = [[peripheral.wrap]]( "top" )
 +
[[modem.open]]( 5 )
 +
 
 +
== History ==
 +
{{History|head}}
 +
{{History|1.3|Added Wireless Modems.}}
 +
{{History|1.4|The send and receive range of wireless modems now increases with altitude, allowing long range networking from high-altitude Computers.}}
 +
{{History|1.5|Redesigned Wireless Modems; they can now send and receive on multiple channels, independent of the computer ID.}}
 +
{{History|1.51|Changed crafting recipe.}}
 +
{{History|foot}}
 +
 
 +
{{BlocksItemsList}}
 +
 
 +
[[Category:Blocks]]

Latest revision as of 06:05, 4 August 2020

This page needs some serious TLC, stat!
Please help us by cleaning it, fixing it up, or sparing it some love.
(Reason: The behaviour of Rednet has changed as of 1.5 - please consider updating this page with information. (Please don't add prerelease info!))
This page is for the Modem blocks. For the modem API, see Modem (API)
Grid workbench.png   Modem
WirelessModem.png
Item ID ComputerCraft:CC-Peripheral
Damage Value 1
Peripheral? Yes- Modem (API)

Modems are blocks which can be used to wirelessly transfer data between Computers and Turtles, using the Rednet API or the Modem API. To place a modem on a side of a computer, right-click while sneaking.

It is also possible to turn the modem on and off by typing "rednet.open( side )" to open and "rednet.close( side )" to close.

Modems can send messages to other modems located up to 64 meters away, or 16 meters during a thunderstorm. As of 1.4 Modem range is increased with higher altitudes. If there is no thunderstorm, the range will always be higher than 64, and at max altitude you would have a range of 384 meters.

In 1.4 and 1.41 there is a miscalculation that causes the range to only be 381 meters at max altitude.

As of the 1.5 update for ComputerCraft, Wireless Modems can send messages on specific channels.

See also: Wired Modem, Ender Modem.

Crafting

Empty-crafting-table.png
Grid stone.png
Grid stone.png
Grid stone.png
Grid stone.png
Grid ender pearl.png
Grid stone.png
Grid Modem.png
Grid stone.png
Grid stone.png
Grid stone.png

Example (Modem API)

  • Place 2 computers and add modems to them by clicking the right mouse button while sneaking.
  • Access them, and start Lua.
  • Once Lua has started, wrap your modem using peripheral.wrap() (something like "modem = peripheral.wrap("<side of modem>")
  • Type "modem.open (<A modem port number, anything from 1 to 65535>)" on one computer.
  • Check if there exists a connection: a dim, red light should be found on the modem.
  • Now, type "modem.transmit (<Same number as above>, <Also the same number>, 'Your message')" on the other computer. This should send your message to all computers connected.
  • Opening the first computer should show the message written on the second computer.


Modem as a Peripheral

To use a Modem as a peripheral, you need to either call a method directly using peripheral.call(), or, wrap the modem using the Peripheral API. Wrapped modems provide all functions listed in the Modem API.

For this example, we have a Modem connected to the top of our Computer, we are going to open channel 5:

-- Immediately invoke a method without wrapping
peripheral.call( "top", "open", 5 )
-- You can also "wrap" the peripheral side to a variable:
local modem = peripheral.wrap( "top" )
modem.open( 5 )

History

1.3Added Wireless Modems.
1.4The send and receive range of wireless modems now increases with altitude, allowing long range networking from high-altitude Computers.
1.5Redesigned Wireless Modems; they can now send and receive on multiple channels, independent of the computer ID.
1.51Changed crafting recipe.
Grid Redstone.pngComputerCraft Blocks and Items
Grid paper.png  Blocks
 Iso Computer.png  Computer Iso Advanced Computer.png  Advanced Computer Iso Command Computer.png  Command Computer Iso DiskDrive.png  Disk Drive
 Iso Monitor.png  Monitor Iso Advanced Monitor.png  Advanced Monitor Iso Printer.png  Printer Grid turtle.png  Turtle
 Grid Modem.png  Wireless Modem Grid Ender Modem.png  Ender Modem Grid Wired Modem.png  Wired Modem Grid Networking Cable.png  Networking Cable
Grid paper.png  Items
 Grid Pocket Computer.png  Pocket Computer Grid Advanced Pocket Computer.png  Advanced Pocket Computer Grid disk.png  Floppy Disk Grid printed page.png  Printed Page
 Grid printed pages.png  Printed Pages Grid printed book .png  Printed Book