• API
• FAQ
• Tools
• Archive
daily pastebin goal
40%
SHARE
TWEET

CC: exercise5_1

hevohevo May 18th, 2016 32 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. -- exercise5_1
2. --  surround four directions with walls
3.
4. -- ####### Define a function ########
5. function placeSomeBlocks(n)
6.   for i=1,n do
7.     turtle.forward()  -- move to next position
8.     turtle.placeDown()  -- put a block in the ground
9.   end
10. end
11.
12. -- 一辺の長さが nagasa の正方形を作る
13. function makeSquare(nagasa)
14.   -- たとえば一辺7の正方形ならば、6個設置を4回繰り返す
15.   for i=1,4 do
16.     placeSomeBlocks(nagasa - 1)
17.     turtle.turnRight()
18.   end
19. end
20.
21. -- ###### Main ########
22. turtle.select(1) -- the usual phrase
23.
24. turtle.up()  -- move up
25.
26. -- stack six squares
27. for ronoji=1,6 do
28.   -- 1st stage is made with slot 1, 2nd stage is slot 2, ...
29.   turtle.select(ronoji)
30.
31.   -- 一辺7の正方形を作る
32.   makeSquare(7)
33.
34.   turtle.up()  -- move up
35. end
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.

Top