Advertisement
Guest User

turtle program

a guest
Nov 17th, 2012
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.79 KB | None | 0 0
  1. textBlocks = {
  2.  {
  3.  "     ",
  4.  "     ",
  5.  " ..  ",
  6.  ".  . ",
  7.  " .. .",
  8.  },
  9.  {
  10.  "... ",
  11.  ".  .",
  12.  "... ",
  13.  ".  .",
  14.  "... ",
  15.  },
  16.  {
  17.  " ... ",
  18.  ".   .",
  19.  ".    ",
  20.  ".   .",
  21.  " ... ",
  22.  },
  23.  {
  24.  "... ",
  25.  ".  .",
  26.  ".  .",
  27.  ".  .",
  28.  "... ",
  29.  },
  30.  {
  31.  "....",
  32.  ".   ",
  33.  "... ",
  34.  ".   ",
  35.  "....",
  36.  },
  37.  {
  38.  "....",
  39.  ".   ",
  40.  "... ",
  41.  ".   ",
  42.  ".   ",
  43.  },
  44.  {
  45.  " ....",
  46.  ".    ",
  47.  ".  ..",
  48.  ".   .",
  49.  " ... ",
  50.  },
  51.  {
  52.  ".  .",
  53.  ".  .",
  54.  "....",
  55.  ".  .",
  56.  ".  .",
  57.  },
  58.  {
  59.  " ",
  60.  ".",
  61.  " ",
  62.  ".",
  63.  ".",
  64.  },
  65.  {
  66.  ".....",
  67.  "   . ",
  68.  "   . ",
  69.  ".  . ",
  70.  " ..  ",
  71.  },
  72.  {
  73.  ".  .",
  74.  ". . ",
  75.  "..  ",
  76.  ". . ",
  77.  ".  .",
  78.  },
  79.  {
  80.  ".   ",
  81.  ".   ",
  82.  ".   ",
  83.  ".   ",
  84.  "....",
  85.  },
  86.  {
  87.  ".   .",
  88.  ".. ..",
  89.  ". . .",
  90.  ".   .",
  91.  ".   .",
  92.  },
  93.  {
  94.  ".   .",
  95.  "..  .",
  96.  ". . .",
  97.  ".  ..",
  98.  ".   .",
  99.  },
  100.  {
  101.  "    ",
  102.  "    ",
  103.  " .. ",
  104.  ".  .",
  105.  " .. ",
  106.  },
  107.  {
  108.  ".... ",
  109.  ".   .",
  110.  ".... ",
  111.  ".    ",
  112.  ".    ",
  113.  },
  114.  {
  115.  " ... ",
  116.  ".   .",
  117.  ". . .",
  118.  ".  . ",
  119.  " .. .",
  120.  },
  121.  {
  122.  ".... ",
  123.  ".   .",
  124.  "...  ",
  125.  ".  ..",
  126.  ".   .",
  127.  },
  128.  {
  129.  " ....",
  130.  ".    ",
  131.  " ... ",
  132.  "    .",
  133.  ".... ",
  134.  },
  135.  {
  136.  ".....",
  137.  "  .  ",
  138.  "  .  ",
  139.  "  .  ",
  140.  "  .  ",
  141.  },
  142.  {
  143.  ".   .",
  144.  ".   .",
  145.  ".   .",
  146.  ".   .",
  147.  " ... ",
  148.  },
  149.  {
  150.  ".   .",
  151.  ".   .",
  152.  " . . ",
  153.  " . . ",
  154.  "  .  ",
  155.  },
  156.  {
  157.  ".   .",
  158.  ".   .",
  159.  ". . .",
  160.  ".. ..",
  161.  ".   .",
  162.  },
  163.  {
  164.  ".   .",
  165.  " . . ",
  166.  "  .  ",
  167.  " . . ",
  168.  ".   .",
  169.  },
  170.  {
  171.  ".   .",
  172.  " . . ",
  173.  "  .  ",
  174.  "  .  ",
  175.  "  .  ",
  176.  },
  177.  {
  178.  ".....",
  179.  "   . ",
  180.  "  .  ",
  181.  " .   ",
  182.  ".....",
  183.  },
  184.  {
  185.  "  ",
  186.  " ",
  187.  " ",
  188.  " ",
  189.  " ",
  190.  },
  191.  {
  192.  ".",
  193.  ".",
  194.  ".",
  195.  " ",
  196.  ".",
  197.  },
  198. }
  199.  
  200. local colNum=0
  201. local x=1
  202. local y=1
  203.  
  204. function drawRow(inrow)
  205.  
  206.     colNum = string.len(inrow)
  207.     x = 1
  208.     print("starting on "..x..","..y..":"..inrow)
  209.     while x <= colNum do
  210.       slot=string.sub(inrow,x,x)
  211.       if slot == "." then
  212.         turtle.placeDown()
  213.       end
  214.  
  215.       turtle.forward()
  216.       x=x+1
  217.  
  218.     end
  219.     while x > 1 do
  220.       turtle.back()
  221.       x = x -1
  222.     end
  223.     return colNum
  224. end
  225.  
  226. function drawLetter(letter)
  227.   for i=5,1,-1 do
  228.     drawRow(letter[i])
  229.     print("Done with row")
  230.     turtle.up()
  231.     y = y + 1
  232.   end
  233.   for x = 1,colNum+1 do
  234.     turtle.forward()
  235.   end
  236.   while y > 1 do
  237.     turtle.down()
  238.     y = y - 1
  239.   end
  240. end
  241.  
  242. function drawText(text)
  243.   for a=1,string.len(text) do
  244.     val =string.byte(text,a)
  245.     if val == 32 then val=27
  246.     elseif val >= 65 and val <= 90 then
  247.       val = val - 64
  248.     elseif val >= 97 and val <= 122 then
  249.       val = val - 96
  250.     elseif val == string.byte("!") then
  251.       val=28
  252.     else
  253.       val=27
  254.     end
  255.  
  256.     drawLetter(textBlocks[val])
  257.  
  258.  
  259.  
  260.   end
  261. end
  262.  
  263. write("(kleebco) enter sjipsign text:")
  264. text = read()
  265. drawText(text)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement