This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Tertius_'s profile picture

Unable to write to a remote monitor

Started by Tertius_, 02 January 2016 - 01:52 PM
Tertius_ #1
Posted 02 January 2016 - 02:52 PM
I am attempting to write to a remote advanced monitor (not directly on the side of the advanced computer). Every time I receive this error .temp:10: attempt to index ? (a nil value)

The code I am using is

local mon1 = peripheral.wrap("monitor_5")
mon1.write("Test:")

I ran this program to verify the monitor name:

local periList=peripheral.getNames()
for i = 1, #perList do
print("I have a " ..peripheral.getType(perList).." attached as \"..perList.."\".")
end

This program verified the name of the monitor as "monitor_5". I receive a similar error when I try to write to the monitor directly from lua>

Is there a problem with my code (this is how I keep seeing it done on all the videos and forums) or is the problem in ComputerCraft?

Thanks
Tertius_
Lyqyd #2
Posted 02 January 2016 - 05:09 PM
Moved to Ask a Pro.
HPWebcamAble #3
Posted 02 January 2016 - 06:46 PM
I am attempting to write to a remote advanced monitor (not directly on the side of the advanced computer). Every time I receive this error .temp:10: attempt to index ? (a nil value)

So just to make sure, you are trying to run this code:

local mon1 = peripheral.wrap("monitor_5")
mon1.write("Test:")

And you get an error on line 10…?
When the code is only two lines…?

And yes, that should work just fine, if the monitor is connected to the computer and it's wired modem is turned on (the one touching the monitor)

Since the file is called .temp, I assume you are using the 'run' feature of the edit program. Try saving and exiting, then run it from the command line.