natie3

CircleBuilder

Oct 19th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.91 KB | None | 0 0
  1. os.loadAPI("circles.lua")
  2. os.loadAPI("moveAPI.lua")
  3. chat = peripheral.wrap("left")
  4. cir = "23"
  5.  
  6. function checkItems()
  7.   currentSlot = 2
  8.   while turtle.getItemCount() < 64 and currentSlot < 17 do
  9.     turtle.select(currentSlot)
  10.     turtle.transferTo(1)
  11.     turtle.select(1)
  12.     currentSlot = currentSlot + 1
  13.   end
  14.   if currentSlot == 17 then
  15.     chat.say("I ran out of items, please bring more")
  16.     turtle.select(1)
  17.     while turtle.getItemCount() == 0 do
  18.       os.sleep(5)
  19.     end
  20.     checkItems()
  21.   end
  22. end    
  23.  
  24. function quarter(circleInput)
  25.   checkItems()
  26.   action = "r tl"
  27.   list = {}
  28.   for item in circleInput:gmatch("%S+") do
  29.     list[#list + 1] = item
  30.   end
  31.   for i = 1, #list do
  32.     cur = list[i]
  33.     if cur == "s" then
  34.       turtle.turnRight()
  35.       action = "l tr"
  36.     else
  37.       moveAPI.repeatMoves("dd pd f", tonumber(cur))
  38.       if i ~= #list then
  39.         moveAPI.move(action)
  40.       end
  41.     end
  42.   end
  43. end
  44.  
  45. function createCircle(inputCircle)
  46.   moveAPI.move("pd f")
  47.   quarter(inputCircle)
  48.   moveAPI.move("pd f")
  49.   quarter(string.reverse(inputCircle))
  50.   moveAPI.move("pd f")
  51.   quarter(inputCircle)
  52.   moveAPI.move("pd f")
  53.   quarter(string.reverse(inputCircle))
  54.   moveAPI.move("pd f")
  55. end
  56.  
  57. function createMultiple(start, sequence)
  58.   current = start
  59.   for k, amount in ipairs(sequence) do
  60.     for i = 1, amount do
  61.       createCircle(circles.mapping["" .. current])
  62.       moveAPI.move("b u")
  63.     end
  64.     current = current + 2
  65.     moveAPI.move("l tr")
  66.   end
  67. end
  68.  
  69. function sameLevel(start, sequence)
  70.   current = start
  71.   for k, amount in ipairs(sequence) do
  72.     for i = 1, amount do
  73.       createCircle(circles.mapping["" .. current])
  74.       moveAPI.move("b l tr")
  75.       current = current + 2
  76.     end
  77.     turtle.up()
  78.   end
  79. end
  80.  
  81. for i = 39, 15, -2 do
  82.   createCircle(circles.mapping["" .. i])
  83.   moveAPI.move("b r tl")
  84. end
  85.  
  86. --sameLevel(61, { 1, 2 })
  87.  
  88. --createMultiple(73, { 2, 1, 3 })
  89.  
  90. --createCircle(circles.mapping[cir])
Add Comment
Please, Sign In to add comment