daily pastebin goal
26%
SHARE
TWEET

ComputerCraft: Tofu

hevohevo Jun 5th, 2016 111 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- tofu
  2. --  豆腐建築を行うプログラムです
  3.  
  4.  
  5. -- ####### Config ###########
  6. local haba = 9
  7. local okuyuki = 7
  8. local takasa = 3
  9.  
  10.  
  11. -- ####### Functions ########
  12. function placeSomeBlocks(n)
  13.   if n<1 then
  14.     turtle.placeDown()
  15.     return
  16.   end
  17.  
  18.   for i=1,n do
  19.     turtle.forward()  -- move to next position
  20.     turtle.placeDown()  -- put a block in the ground
  21.   end
  22. end
  23.  
  24. function placeSquare2(okuyuki, haba)
  25.   for i=1,2 do
  26.     placeSomeBlocks(okuyuki - 1)
  27.     turtle.turnRight()
  28.     placeSomeBlocks(haba - 1)
  29.     turtle.turnRight()
  30.   end
  31. end
  32.  
  33. function placeSquare(nagasa)
  34.   if nagasa < 2 then
  35.     turtle.placeDown()
  36.     return
  37.   end
  38.  
  39.   for hen=1,4 do
  40.     placeSomeBlocks(nagasa-1)
  41.     turtle.turnRight()
  42.   end  
  43. end
  44.  
  45. function goToRightForward()
  46.   turtle.turnRight()
  47.   turtle.forward()
  48.   turtle.turnLeft()
  49.   turtle.forward()
  50. end
  51.  
  52. function selectNextSlot()
  53.   local n = turtle.getSelectedSlot()
  54.   if n == 16 then
  55.     n = 1
  56.   end
  57.   turtle.select(n+1)
  58. end
  59.  
  60. -- ###### Main ########
  61. turtle.select(1) -- the usual phrase
  62.  
  63. turtle.up()  -- move up
  64.  
  65. -- stack six squares
  66. for ronoji=1,takasa do
  67.   -- 1st stage is made with slot 1, 2nd stage is slot 2, ...
  68.   turtle.select(ronoji)
  69.  
  70.   -- 四角形の形にブロック配置
  71.   -- placeSquare(haba)
  72.   placeSquare2(okuyuki, haba)
  73.   turtle.up()  -- move up
  74. end
  75.  
  76.  
  77.  
  78. -- 屋根作り
  79.  
  80. while (okuyuki > 0) or (haba > 0) do
  81.   print(okuyuki, haba)
  82.   placeSquare2(okuyuki, haba)
  83.   selectNextSlot()
  84.   goToRightForward()
  85.   okuyuki = okuyuki - 2
  86.   haba = haba - 2
  87. end
  88.  
  89. redstone.setOutput("bottom",true)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top