233 posts
Location
Cleveland, Ohio
Posted 03 April 2013 - 02:47 PM
this is my code -
http://pastebin.com/sFrM5je4it is printing all weird
|
how? this V
Spoiler
can someone tell me WHY this is happening and how to fix it? (maybe a fixed code?) thanks!!
-LuaEclipser
2217 posts
Location
3232235883
Posted 03 April 2013 - 04:26 PM
because the string contains backslashes (the escape operator), replace all instances of "\" with "\\" in the strings
233 posts
Location
Cleveland, Ohio
Posted 03 April 2013 - 04:33 PM
because the string contains backslashes (the escape operator), replace all instances of "\" with "\\" in the strings
D: that ruins the ASCII art D: any other way?
8543 posts
Posted 03 April 2013 - 07:40 PM
No, the point is that it un-ruins the ASCII art. It looks funny in the code, but prints correctly. You could also put each line in block quotes instead.
7508 posts
Location
Australia
Posted 03 April 2013 - 07:51 PM
and by block quotes he means
local someVar = [[multi-line
string where
you can use \ freely]]
a example (all of the below will print a diamond to the screen)
Spoiler
single line, requires \\ to be used to display a \
asciiArt = " /\\\n / \\\n| |\n \\ /\n \\/"
print(asciiArt)
in a table, still requires \\
asciiArt = {
" /\\",
" / \\",
"| |",
" \\ /",
" \\/"
}
for _,v in ipairs(asciiArt) do
print(v)
end
using block quotes [[ ]] no \\ is needed to print \
asciiArt = [[ /\
/ \
| |
\ /
\/]]
print(asciiArt)
table using block quotes, no need to use \\ for \
asciiArt = {
[[ /\]],
[[ / \]],
[[| |]],
[[ \ /]],
[[ \/]]
}
for _,v in ipairs(asciiArt) do
print(v)
end
Edited on 03 April 2013 - 05:52 PM