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

How to read a .txt from a link (http://example.com)

Started by MrDiabli, 15 May 2016 - 09:37 PM
MrDiabli #1
Posted 15 May 2016 - 11:37 PM
Hello,

I am a very novice with computercraft and I'd like to display a .txt from an external link on a monitor but I don't know what to use.

What's more, I'd like to know why doesn't this code work?

local monitor = peripheral.wrap("right")
local txt = "Hello"

monitor.SetCursorPos(1,1)
monitor.write(txt)

Thank you
Dragon53535 #2
Posted 16 May 2016 - 12:19 AM
it's setCursorPos not SetCursorPos

Edit: Also, try HTTP api
Edited on 15 May 2016 - 10:20 PM
Nothy #3
Posted 16 May 2016 - 11:07 AM
If you want to read a file on a website, you can do this:


local url = "http://www.nothy.se/files/test.txt"
local data = http.get(url)
print(data.readAll()) --#If you want to run the file, simply write the data to a file and run it!