Sorry, for posting full code, but else you wouldn't understand what I'm trying to do, but I removed some parts of it to make it shorter.
id = os.computerID()
pass = "gta"
function checkm() --Here computer opens and prints the message (I think here is the mistake)
term.restore()
file = fs.open("messages/message","r")
local text = {}
local print = file.readLine()
repeat
table.insert(text,print)
line = file.readLine()
until line == nil
file.close()
local message = text[1]
term.clear()
term.setCursorPos(1,1)
print("Message "..message) --19 line with the error.
end
function message() --Here user writes the message which gets saved into the computer.This seems to work fine, because everything gets really saved.
term.clear()
term.setCursorPos(1,1)
print("Monitor can't work, while accessing computer.")
term.restore()
term.clear()
term.setCursorPos(1,1)
fs.makeDir("messages")
print("Enter your message")
write("Text:")
local text = read()
local file = fs.open("messages/message","w")
file.writeLine(text)
file.close()
term.clear()
term.setCursorPos(1,1)
print("Message written")
end
mon = peripheral.wrap("left")
term.redirect(mon)
term.clear()
term.setCursorPos(1,1)
while true do
local time = os.time()
time = textutils.formatTime(time, true)
print[[
1.Access Computer.
2.Shutdown.
3.Leave a message.
4.Check messages.]]
term.setCursorPos(1,10) print("Computer ID:"..id.."") term.setCursorPos(26,10) print("Time "..time)
os.startTimer(0.5) event, param1, param2 = os.pullEvent() if event == "char" and param1 == "1" then access() elseif event == "char" and param1 == "2" then shutdown() elseif event == "char" and param1 == "3" then message() elseif event == "char" and param1 == "4" then checkm() end
term.clear()
term.setCursorPos(1,1)
end