Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- turtle must be initialized facing positive X axis
- -- variables
- local x = 0
- local y = 0
- local z = 0
- local r = 0
- -- local ws, err = http.websocket("ws://localhost:12703")
- -- useful methods
- --function confirm()
- -- ws.send("t")
- --end
- --function aborted()
- -- ws.send("f")
- --end
- function up()
- if turtle.up() then
- y = y + 1
- --confirm()
- else
- --aborted()
- end
- end
- function down()
- if turtle.down() then
- y = y - 1
- --confirm()
- else
- --aborted()
- end
- end
- function normalized(int)
- local t = int
- while (t < 0) do
- t = t + 4
- end
- while(t > 3) do
- t = t - 4
- end
- return r - int
- end
- function rotate(nr)
- local norm = normalized(nr)
- while nr ~= 0 do
- if nr > 0 then
- nr = nr - 1
- r = r - 1
- turtle.turnLeft()
- else
- nr = nr + 1
- r = r + 1
- turtle.turnRight()
- end
- end
- end
- -- actual turtle loop
- up()
- down()
- rotate(2)
- rotate(5)
- rotate(3)
- rotate(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement