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

[Tutorial] Easy ASCII Art!

Started by Grim Reaper, 18 May 2012 - 03:21 AM
Grim Reaper #1
Posted 18 May 2012 - 05:21 AM
Backstory:
SpoilerOver the past few months after being introduced to ComputerCraft I have come along some very impressive GUIs in programs built by other players. I have always marveled at the accuracy and patience required to actually sit and write out the art.
My first attempts at learning ended in miserable failure, so I desperately searched for an easy fix. Unfortunately, there was none; my artistic abilities both on and off the computer were doomed to remain at that of a child.

The reality of making ASCII art is that is quite simple if you don't mind using a couple of external tools! :P/>/>

The website I have used multiple times is this one: http://patorjk.com/software/taag/
This is an ASCII Art generator that will draw the text you write into the art font specified.

Once you've selected your font and have the proper text drawn, it's time to move this artistic wonder into a program!
First create a new file in NotePad++ to avoid later Repalcement accidents with '\' that you didn't want removed!

Typically, titles and other art are stored as a function that may look something like this:

function printLogo()
   -- Print statements here
end

Once you have designed this functions framework (function header, end statement, etc.), you can simply copy over the text that was created by the generator line by line into separate print statements! Easy as pie!

Your new Logo function should look something like this:

function printLogo()
print(" _____ _____ _____ _____ ")
print("|_   _|  ___/  ___|_   _|")
print("  | | | |__ \ `--.  | |  ")
print("  | | |  __| `--. \ | |  ")
print("  | | | |___/\__/ / | |  ")
print("  \_/ \____/\____/  \_/  ")
end

Excellent! You're almost finished!

Now, you're bound to come across a scenario in which your drawing contains a slash of this fashion '\'. LUA and every programming language I know considers this an exit character usually followed by a further identifier like '\n' to end the line.

To fix this, if you use Notepad++ like me, just use the handy-dandy Ctrl+F tool! You'll be presented with a dialog box for the find feature, but you should choose the tab next to it, 'Replace'.
From the Replace tab, enter in the 'Find:' field: \
In the 'Replace With :' field, enter: \\
Finally, press replace all!

There are also some ASCII characters that ComputerCraft won't display, but instead will replace with a '?'.
The most common of which that I have found is this little bugger –> `
( I apologize for the lack of a name)

I usually replace characters like this guy with a period because I personally feel it takes away the least amount of graphical awe from your art.

Now, just move your new function into the intended file and call her whenever you'd your users' jaw to hit the floor in the amount of "effort" you put into your new ASCII Art!

~ Payment
MathManiac #2
Posted 19 May 2012 - 12:51 AM
This is awesome! Thanks!
MaryuZ #3
Posted 10 July 2012 - 02:05 AM
Soo helpfull…thx
any idea on how to make ascii art out of pictures?
Cranium #4
Posted 01 August 2012 - 10:16 PM
Soo helpfull…thx
any idea on how to make ascii art out of pictures?
http://www.glassgiant.com/ascii/
That should do what you want…
Xenthera #5
Posted 02 August 2012 - 07:21 AM
This is great! :ph34r:/>/>
Cranium #6
Posted 02 August 2012 - 04:34 PM
This is great! :ph34r:/>/>
I know, I just spent two hours at work today going through all of the fonts with various words… I love it!
Sariaz #7
Posted 23 September 2012 - 08:31 AM
Great link thanks now to figure out a way to make people with ascii for my game that ill eventually hopefully get around to :P/>/>
Doyle3694 #8
Posted 23 September 2012 - 09:56 PM
You don't even have to do the print("")'s
You can do print
[[
This
IS
TeXt
]]
:D/>
darkrising #9
Posted 15 October 2012 - 12:02 AM
You have given my an idea :)/>/> it might be cool to make an api with all ASCII characters for that "font" and put them together, example: someapi.afunction("test")
Czarified #10
Posted 10 February 2013 - 12:53 PM
Hey, thanks for the awesome tools! However when I run my program I keep getting an error. Replaced all "\" with "\\" and replaced all " ` " with " ' ".

http://pastebin.com/TbY67UBe


function printLogo()
print("  _  __									  _					  ___				   ")
print(" | |/ /	___	_ __	  _ _   __ _	__| |	___	  o O O  / __|	___		   ")
print(" | ' <	/ _ \\  | '  \\	| '_| / _' |  / _' |   / -_)	o	  | (__	/ _ \\	 _	")
print(" |_|\\_\\   \\___/  |_|_|_|  _|_|_  \\__,_|  \\__,_|   \\___|   TS__[O]  \\___|   \\___/   _(_)_  ")
print("_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""| {======|_|"""""|_|"""""|_|"""""| ")
print(""'-0-0-'"'-0-0-'"'-0-0-'"'-0-0-'"'-0-0-'"'-0-0-'"'-0-0-'./o--000'"'-0-0-'"'-0-0-'"'-0-0-' ")
end
textutils.slowWrite("Logo test in 3....2....1...")
term.clear()
printLogo()
ElvishJerricco #11
Posted 10 February 2013 - 04:03 PM
Just an FYI, you can make multi-line strings using [[ and ]].


local ascii = [[

___________              __   
\__    ___/___   _______/  |_ 
  |    |_/ __ \ /  ___/\   __\
  |    |\  ___/ \___ \  |  |  
  |____| \___  >____  > |__|  
             \/     \/                 
]]
print(ascii)


Of course this example didn't have the escape slashes fixed but that's easy.
Doyle3694 #12
Posted 15 February 2013 - 12:00 AM
Elvish, what did your comment, saying the exact same I did, add to this thread?

There are 10 posts in this thread, they are not to many to read through, read through them before posting, so stuff like your comment saying the exact same as mine did 5 months ago doesn't happen
theoriginalbit #13
Posted 15 February 2013 - 12:07 AM
Of course this example didn't have the escape slashes fixed but that's easy.
You don't need to escape when using [[ ]] anything between those is printed exactly as it is written, so \n will not make a new line but instead print \n

Elvish, what did your comment, saying the exact same I did, add to this thread?

There are 10 posts in this thread, they are not to many to read through, read through them before posting, so stuff like your comment saying the exact same as mine did 5 months ago doesn't happen
imo, and I don't mean to sound mean, but I actually like Elvish's post better, he uses better terminology, uses code tags and if i was a newbie reading his over yours it would make more sense.
Czarified #14
Posted 19 February 2013 - 02:57 PM
i can't get this work no matter how I set it up. How to you print in onto a monitor correctly? I can write something on a monitor but it's only displaying the first line of my ASCII. I'm using the [[ ]] format currently. It's printing, but it looks like it's not going to a new line. Can someone help please?
ElvishJerricco #15
Posted 19 February 2013 - 03:21 PM
i can't get this work no matter how I set it up. How to you print in onto a monitor correctly? I can write something on a monitor but it's only displaying the first line of my ASCII. I'm using the [[ ]] format currently. It's printing, but it looks like it's not going to a new line. Can someone help please?

Monitors only have a write function. This is actually different than print. Print handles new lines. Write does not. But this can be gotten around!


m = peripheral.wrap("...")
term.redirect(m)
print(ascii)

Using term.redirect makes it so that any uses of the term API get redirected to the monitor. So printing handles new lines, and gets output to the monitor.

Just be sure to use term.restore() to get the term directed back to the main screen when you're done!
Czarified #16
Posted 20 February 2013 - 04:51 PM
i can't get this work no matter how I set it up. How to you print in onto a monitor correctly? I can write something on a monitor but it's only displaying the first line of my ASCII. I'm using the [[ ]] format currently. It's printing, but it looks like it's not going to a new line. Can someone help please?

Monitors only have a write function. This is actually different than print. Print handles new lines. Write does not. But this can be gotten around!


m = peripheral.wrap("...")
term.redirect(m)
print(ascii)

Using term.redirect makes it so that any uses of the term API get redirected to the monitor. So printing handles new lines, and gets output to the monitor.

Just be sure to use term.restore() to get the term directed back to the main screen when you're done!

I ended up posting in the ask a pro section and this was the solution. Thank you for your help as well. My new logo looks great!
R167 #17
Posted 20 February 2013 - 08:40 PM
i can't get this work no matter how I set it up. How to you print in onto a monitor correctly? I can write something on a monitor but it's only displaying the first line of my ASCII. I'm using the [[ ]] format currently. It's printing, but it looks like it's not going to a new line. Can someone help please?

Monitors only have a write function. This is actually different than print. Print handles new lines. Write does not. But this can be gotten around!


m = peripheral.wrap("...")
term.redirect(m)
print(ascii)

Using term.redirect makes it so that any uses of the term API get redirected to the monitor. So printing handles new lines, and gets output to the monitor.

Just be sure to use term.restore() to get the term directed back to the main screen when you're done!
In my experience, using term.redirect() with print still doesn't work. I still have to do

write("some text") term.setCursorPos(1,term.getCursorPos()+1)
Annoying. Always make a function for that.
R167 #18
Posted 20 February 2013 - 08:42 PM
Link is broken for the website in original post area. Just FYI
Grim Reaper #19
Posted 21 February 2013 - 06:22 PM
You know, not saying that this post is almost a year old, but… It is.
theoriginalbit #20
Posted 21 February 2013 - 06:36 PM
Link is broken for the website in original post area. Just FYI
Not for me it isn't…….
R167 #21
Posted 22 February 2013 - 01:12 PM
Link is broken for the website in original post area. Just FYI
Not for me it isn't…….

Wasn't working yesterday