0

I am new to Computer Craft, and I want to get started using Wireless Modems.

local modem = peripheral.wrap("top")
local channel = 1
modem.open(channel)

I have the code above, and when I try to run the modem.open() command, it gives me a message saying "attempt to call index ? (a nil value)". I know that many people have had this error before. I have searched through questions and tutorials and followed their exact code or instructions, but none of them have worked and I cannot find any other questions with this error message showing up from this command. My modem is on top of my computer.

How can this be fixed?

Yu Hao
  • 119,891
  • 44
  • 235
  • 294
Alex
  • 13
  • 1
  • 7

1 Answers1

0

If you are using wireless modems, considering using the rednet API.

rednet.open("top")

Configures your computer for sending messages wirelessly. Go to the computercraft wiki for the full documentation

You can send messages using rednet.send() or rednet.broadcast() and receive messages through sender, message = rednet.receive()

Lee Yi
  • 517
  • 6
  • 17