Difference between revisions of "Wired Modem"
From ComputerCraft Wiki
(Created page with "{{NeedsWork|Needs correction and more examples -alekso56)}} :''This page is for the Modem blocks. For the modem API, see Modem (API)'' {{Block |name=Cable Mode...") |
Shuudoushi (Talk | contribs) m (fixed some wording and removed some un-needed bits) |
||
Line 31: | Line 31: | ||
* Access them, and start Lua. | * Access them, and start Lua. | ||
* Once Lua has started, type "[[rednet_(API)|rednet]].[[rednet.open|open]] ("<relative location to modem, e.g. left, right>")" on both computers. | * Once Lua has started, type "[[rednet_(API)|rednet]].[[rednet.open|open]] ("<relative location to modem, e.g. left, right>")" on both computers. | ||
− | * Check if there exists a connection: a dim, red | + | * Check if there exists a connection: a dim, red ring should be found around the modem, closest to the computer/peripheral it is connected to. |
− | * Type on one computer "[[rednet_(API)|rednet]].[[rednet.receive|receive]] (60)". This will make the computer freeze for 60 seconds, or until it has received a signal from the other | + | * Type on one computer "[[rednet_(API)|rednet]].[[rednet.receive|receive]] (60)". This will make the computer freeze for 60 seconds, or until it has received a signal from the other computer(s). |
* Now, type "[[rednet_(API)|rednet]].[[rednet.broadcast|broadcast]] ('<your message>')" on the other computer. This should send your message to all computers connected. | * Now, type "[[rednet_(API)|rednet]].[[rednet.broadcast|broadcast]] ('<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. | * Opening the first computer should show the message written on the second computer. | ||
== Example 2 (Modem and peripheral) == | == Example 2 (Modem and peripheral) == | ||
− | * If you want to use a modem to communicate with | + | * If you want to use a modem to communicate with a peripheral you might want to take a look at the [[Peripheral_(API)##Remote_Peripherals_using_Networking_Cables|Peripheral API]] |
==Modem as a Peripheral== | ==Modem as a Peripheral== | ||
− | To use a Modem as a peripheral, you need to either call a method directly using [[peripheral.call]](), or | + | 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 [[Rednet_(API)|Rednet API]]. |
For this example, we have a Modem connected to the top of our [[Computer]]: | For this example, we have a Modem connected to the top of our [[Computer]]: |
Revision as of 00:41, 10 April 2013
This page needs some serious TLC, stat! Please help us by cleaning it, fixing it up, or sparing it some love.
(Reason: Needs correction and more examples -alekso56)) |
- This page is for the Modem blocks. For the modem API, see Modem (API)
Cable Modem | |
Item ID | ??? |
Damage Value | ??? |
Peripheral? | Yes- Modem (API) |
Modems are blocks which can be used to transfer data between computers, using the Rednet API or the Modem API. To place a modem on a side of a computer, right-click to place the modem while sneaking. To use the modems, you need to connect the modems to each other by placing cables.
Contents
Recipes
Example (Rednet 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, type "rednet.open ("<relative location to modem, e.g. left, right>")" on both computers.
- Check if there exists a connection: a dim, red ring should be found around the modem, closest to the computer/peripheral it is connected to.
- Type on one computer "rednet.receive (60)". This will make the computer freeze for 60 seconds, or until it has received a signal from the other computer(s).
- Now, type "rednet.broadcast ('<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.
Example 2 (Modem and peripheral)
- If you want to use a modem to communicate with a peripheral you might want to take a look at the Peripheral API
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 Rednet API.
For this example, we have a Modem connected to the top of our Computer:
-- Immediately invoke a method without wrapping peripheral.call("top", "open")
-- You can also "wrap" the peripheral side to a variable: local modem = peripheral.wrap("top") modem.open("top")