Advertisement
Guest User

test2

a guest
May 29th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.73 KB | None | 0 0
  1. cy = 0
  2. ax = 2
  3. az = 2
  4. ymax = 40
  5.  
  6. ylocs = {}
  7. ----- functions
  8. function getColour(int)
  9.   if int <= -10 then return colors.blue end
  10.   if int == -9 then return colors.purple end
  11.   if int == -8 then return colors.magenta end
  12.   if int == -7 then return colors.cyan end
  13.   if int == -6 then return colors.lightBlue end
  14.   if int == -5  then return colors.pink end
  15.   if int == -4  then return colors.yellow end
  16.   if int == -3  then return colors.lime end
  17.   if int == -2  then return colors.green end
  18.   if int == -1  then return colors.brown end
  19.   if int == 0  then return colors.red end
  20.   return colors.green
  21. end
  22.  
  23. function moveUp()
  24.   if cy ~= 0 then
  25.     turtle.up()
  26.     cy = cy + 1
  27.   end
  28. end
  29.  
  30. function moveDown()
  31.   if not turtle.detectDown() then
  32.     turtle.down()
  33.     cy = cy - 1
  34.   end
  35. end
  36.  
  37. function doStuff(xx, zz)
  38.   for yd = 1, ymax do
  39.     if turtle.detectDown() then
  40.       if ylocs[xx] == nil then
  41.         ylocs [xx] = {}
  42.       end
  43.       table.insert(ylocs[xx],xx,zz)
  44.      -- ylocs[xx] = {[zz] = cy}
  45.     else
  46.       moveDown()
  47.     end
  48.   end
  49.   for yu = cy, 0 do
  50.     moveUp()
  51.   end
  52. end
  53. ----- code
  54. term.clear()
  55. term.setCursorPos(1,1)
  56. for zz = 1, az do
  57.   for xx = 1, ax do
  58.     turtle.forward()
  59.     doStuff(xx,zz)
  60.    -- turtle.forward()
  61.   end
  62.   turtle.turnRight()
  63.   turtle.turnRight()
  64.   for xx = 1, ax do
  65.     turtle.forward()
  66.   end
  67.   turtle.turnLeft()
  68.   turtle.forward()
  69.   turtle.turnLeft()
  70. end
  71.  
  72. print(ylocs)
  73. for x2 = 1, ax do
  74.   for z2 = 1, az do
  75.     --print("works")
  76.     --print(x2)
  77.     --print("-")
  78.     --print(z2)
  79.     --print("---")
  80.     --print(ylocs[1][1])
  81.     --print(ylocs[1][2])
  82.     term.setBackgroundColor(getColour(ylocs[x2][z2]))
  83.     term.setCursorPos(z2, x2)
  84.     term.print(" ")
  85.   end
  86. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement