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

[Question][Error] I don't see what I'm doing wrong in my code

Started by RustikGaming, 18 February 2013 - 02:34 PM
RustikGaming #1
Posted 18 February 2013 - 03:34 PM
I've been trying to get my ASCII text to print centered on a monitor but I can't even get it to print to the monitor in general at all. Here's my code.

local monitor = peripheral.wrap("right")
term.redirect(monitor)
local e,j = term.getSize()
local function printCentered(str, ypos)
  term.setCursorPos(e/2 - #str/2+1, ypos)
  term.write()
end
local function title()
term.clear()
term.setCursorPos(1,2)
mon.print(" _____ _			__ _	 _")
mon.print("/__   \ |__   ___  / _\ |__ (_)_ __ ____")
mon.print("  / /\/ '_ \ / _ \ \ \|  _ \| | '__/ _  \"")
mon.print(" / /  | | | |  __/ _\ \ | | | | |  |  __/")
mon.print(" \/   |_| |_|\___| \__/_| |_|_|_|   \___|")
end
term.restore()

Thanks for your help!!!
PixelToast #2
Posted 18 February 2013 - 03:51 PM
you dont have to use mon.* if you use term.redirect

local monitor = peripheral.wrap("right")
term.redirect(monitor)
local e,j = term.getSize()
local function printCentered(str, ypos)
  term.setCursorPos(e/2 - #str/2+1, ypos)
  term.write()
end
local function title()
term.clear()
term.setCursorPos(1,2)
print(" _____ _					 __ _	 _")
print("/__   \ |__   ___  / _\ |__ (_)_ __ ____")
print("  / /\/ '_ \ / _ \ \ \|  _ \| | '__/ _  \"")
print(" / /  | | | |  __/ _\ \ | | | | |  |  __/")
print(" \/   |_| |_|\___| \__/_| |_|_|_|   \___|")
end
term.restore()
oh and you arent running the title() function
and your print centered forgot the term.write(str)
RustikGaming #3
Posted 18 February 2013 - 04:16 PM
Thanks Pixel
Kingdaro #4
Posted 18 February 2013 - 04:48 PM
Should probably mention how there is no "monitor.print".
RustikGaming #5
Posted 18 February 2013 - 04:54 PM
Should probably mention how there is no "monitor.print".
Thanks Kingdaro, I realized that shortly after posting.