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

[Lua][Solved] Ascii Art Distortion :(

Started by Laserman34170, 11 November 2012 - 11:57 AM
Laserman34170 #1
Posted 11 November 2012 - 12:57 PM
So basically I was making a splash screen and it was working great until I ran it and all my ascii text got distorted. I can't seem to find the problem, and my code looks alright. Note: In the code below, the ascii art is disorted because of the font, that is not the problem.

Thanks, Lazerman

Code
Spoiler

term.clear()
bRun = true
term.setTextColor(colors.red)
w, h = term.getSize()
logo = {
  "  _						 ____   _____ ",
  " | |					   / __ \ / ____|",
  " | |	 __ _ _______ _ __| |  | | (___  ",
  " | |	/ _| |_  / _ \ '__| |  | |\___ \ ",
  " | |___| (_| |/ /  __/ |  | |__| |____) |",
  " |______\__,_/___\___|_|   \____/|_____/ ",
}
dimensions = {
  logoTop = h / 2 - 3,
  logoBottom = h / 2 + 3,
  loadBar = h / 2 + 4,
  loadStatus = h / 2 + 5
}
function splash()
  local logoX = w / 2 - #logo[1] / 2
  local state = 1
  local states = {
	"O o o",
	"o O o",
	"o o O"
  }
  for i=dimensions.logoTop,dimensions.logoBottom do
	term.setCursorPos(logoX, i)
  print(logo[i - dimensions.logoTop])
  end
  while bRun do
local length = w / 2 - #states[1] / 2
term.setCursorPos(length, dimensions.loadBar)
print(states[state])
if state == #states then state = 1
else state = state + 1 end
sleep(1)
  end
end
function load()
  --do stuffs
  sleep(2)
  bRun = false
end
parallel.waitForAll(splash, load)

Screenshot
Spoiler[attachment=665:2012-11-10_17.52.15.png]
Orwell #2
Posted 11 November 2012 - 01:30 PM
Check these pages out :unsure:/>/>:

Escape sequences:
https://en.wikibooks.org/wiki/Lua_Programming/How_to_Lua/escape_sequence
Multiline strings:
http://www.wellho.net/resources/ex.php4?item=u104/mlx
Espen #3
Posted 11 November 2012 - 01:34 PM
What Orwell said, but to give you the quick solution:
Replace every in your logo with
Laserman34170 #4
Posted 11 November 2012 - 01:45 PM
Thanks for the help. Guess I missed that. :unsure:/>/> Didn't think that the problem would get solved this fast.
remiX #5
Posted 11 November 2012 - 06:12 PM
Easiest way to print ascii art onto a computer is to read it from a file and then print, it never fails :unsure:/>/>