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

how to print something on a monitor then go down a line?

Started by Trey2.k, 17 December 2013 - 10:53 PM
Trey2.k #1
Posted 17 December 2013 - 11:53 PM
i need to know if there is way that i can write something on a monitor the go down a line so here is the code i am working with
mon = peripheral.wrap("right")
rednet.open("left") --open to the internet
pass="test"
function listen()
while true do
ID, message = rednet.receive()
if ID == 12 then
if message == pass then
rednet.send(12, "Accepted")
mon.print("--------------------------------------------------")
mon.print(ID..": entered correct password")
mon.print("--------------------------------------------------")
else
rednet.send(12, "Wrong")
mon.write("--------------------------------------------------")
mon.write(ID..": entered wrong password"..message)
mon.write("--------------------------------------------------")
end
end
end
end
listen()
the problem is it doesn't move down a line
Bomb Bloke #2
Posted 18 December 2013 - 02:09 AM
There's no built-in function for this purpose. However, you could create your own one which writes the passed text, then checks where the cursor currently is (with mon.getCursorPos()) and then moves it to the start of the next line down (with mon.setCursorPos()).
Alice #3
Posted 18 December 2013 - 08:02 AM
Here's a good sample code:

function lineBreak() --Declare function
local x, y = term.getCursorPos() --x, y is cursor position
term.setCursorPos(1, y+1) --Set the cursor's position to y position + 1 (enter key basically) and x to 1 (start of line)
end --end function

And why are you using mon.print() first but mon.write() later?
Edited on 18 December 2013 - 07:03 AM
Trey2.k #4
Posted 18 December 2013 - 11:16 AM
Here's a good sample code:

function lineBreak() --Declare function
local x, y = term.getCursorPos() --x, y is cursor position
term.setCursorPos(1, y+1) --Set the cursor's position to y position + 1 (enter key basically) and x to 1 (start of line)
end --end function

And why are you using mon.print() first but mon.write() later?
Lol that was me testing the scruple code dosent have that… But. Thanks for your help
Lyqyd #5
Posted 18 December 2013 - 12:35 PM
Then don't say it's the code you're working with when it isn't. We need the actual code to help in most situations.
Trey2.k #6
Posted 18 December 2013 - 12:36 PM
Then don't say it's the code you're working with when it isn't. We need the actual code to help in most situations.
I see your point… It was a mistake I made I forgot to change it back after testing and didn't catch it