Posted 25 January 2014 - 08:07 PM
Hello
Let me start this by saying that i honestly don't know exactly how to explain this but i will try.
I am making a ASCII number art printer (i dont know what its called but it print numbers in ASCII art)
so:
I'm making it to display the number on the screen, but im in trouble when it gets to numbers ABOVE 9. ( because then it needs two different ascii art numbers to combine and print correctly )
And thats where my problem is.
ascii table:
Then I have a function which works perfectly, IF i only type in letters below 10
function:
if i for example enter 10 in the "num" variable, then it won't do anything, except error out.
Can anyone help me unpacking a doublesymboled number ( idk if thats what higher than 9-numbers are called that )
I might be using the string.gsub or string.gmatch here, to unpack it to a table and then use a for k,v in pairs loop?
well i have no idea, how to…
Thanks in Advance
Let me start this by saying that i honestly don't know exactly how to explain this but i will try.
I am making a ASCII number art printer (i dont know what its called but it print numbers in ASCII art)
so:
I'm making it to display the number on the screen, but im in trouble when it gets to numbers ABOVE 9. ( because then it needs two different ascii art numbers to combine and print correctly )
And thats where my problem is.
ascii table:
Spoiler
local ascii={
["1"]={
[[ ]];
[[###]];
[[###]];
[[###]];
[[###]];
[[###]];
[[###]];
[[###]];
[[###]];
[[###]];
[[###]];
};
["2"]={
[[ ]];
[[#########]];
[[#########]];
[[ ##]];
[[ ##]];
[[#########]];
[[#########]];
[[## ]];
[[## ]];
[[#########]];
[[#########]];
};
["3"]={
[[ ]];
[[#########]];
[[#########]];
[[ ##]];
[[ ##]];
[[ ######]];
[[ ######]];
[[ ##]];
[[ ##]];
[[#########]];
[[#########]];
};
["4"]={
[[ ]];
[[## ##]];
[[## ##]];
[[## ##]];
[[## ##]];
[[#########]];
[[#########]];
[[ ##]];
[[ ##]];
[[ ##]];
[[ ##]];
};
["5"]={
[[ ]];
[[#########]];
[[#########]];
[[## ]];
[[## ]];
[[#########]];
[[#########]];
[[ ##]];
[[ ##]];
[[#########]];
[[#########]];
};
["6"]={
[[ ]];
[[#########]];
[[#########]];
[[## ]];
[[## ]];
[[#########]];
[[#########]];
[[## ##]];
[[## ##]];
[[#########]];
[[#########]];
};
["7"]={
[[ ]];
[[#########]];
[[#########]];
[[ ##]];
[[ ##]];
[[ ##]];
[[ ##]];
[[ ##]];
[[ ##]];
[[ ##]];
[[ ##]];
};
["8"]={
[[ ]];
[[#########]];
[[#########]];
[[## ##]];
[[## ##]];
[[#########]];
[[#########]];
[[## ##]];
[[## ##]];
[[#########]];
[[#########]];
};
["9"]={
[[ ]];
[[#########]];
[[#########]];
[[## ##]];
[[## ##]];
[[#########]];
[[#########]];
[[ ##]];
[[ ##]];
[[ ##]];
[[ ##]];
};
["0"]={
[[ ]];
[[#########]];
[[#########]];
[[## ##]];
[[## ##]];
[[## ##]];
[[## ##]];
[[## ##]];
[[## ##]];
[[#########]];
[[#########]];
};
}
function:
function printAsciiNumber(num, x)
if not num then error("NUMBER NOT SPECIFIED!",2) end
if not x then x=10 end
for k,v in pairs(ascii[num]) do
term.setCursorPos(x,k+43)
term.setTextColor(colors.blue)
write(v)
end
end
if i for example enter 10 in the "num" variable, then it won't do anything, except error out.
Can anyone help me unpacking a doublesymboled number ( idk if thats what higher than 9-numbers are called that )
I might be using the string.gsub or string.gmatch here, to unpack it to a table and then use a for k,v in pairs loop?
well i have no idea, how to…
Thanks in Advance
Edited on 26 January 2014 - 03:12 PM