Advertisement
Sir_Popsilots

test

Mar 13th, 2021
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.38 KB | None | 0 0
  1. --todo
  2. --cord system
  3. --storage system
  4. --starup code
  5. --refuel system
  6. local x,y,z = 0,0,0
  7. local rotationtable = {North={1,0},South={-1,0},West={0,1},East={0,-1}}
  8. local rotation = 0
  9. local buildlimit = 1
  10. --function gets an item name
  11. --returns the number of the slot its in and if it cant find it returns 0
  12. function FindItemSlot(Itemname)
  13.     local slotnum = 1
  14.     while slotnum<17 do
  15.         if string.find(turtle.getItemDetail(slotnum).name,Itemname) then
  16.             return slotnum
  17.         end
  18.         slotnum = slotnum + 1
  19.     end
  20.     return 0
  21. end
  22.    
  23. function Refuelcheck()
  24.     local coalslot = FindItemSlot("coal")
  25.     if coalslot==0 then
  26.         return -1
  27.     end
  28.     if turtle.getFuelLevel()<1000 then
  29.     turtle.refuel(turtle.getItemCount(coalslot)/2)
  30.     end
  31. end
  32.  
  33. function Turn(RightorLeft)
  34.     if RightorLeft=="Right" then
  35.         rotation = rotation + 90
  36.         turtle.turnRight()
  37.     end
  38.     if RightorLeft=="Left" then
  39.         rotation = rotation - 90
  40.         turtle.turnLeft()
  41.     end
  42. end
  43.  
  44. function MoveForwards()
  45.     local temp = rotationtable[math.abs(rotation)/90]
  46.     x = x + temp[1]
  47.     z = z + temp[2]
  48.     turtle.MoveForwards()
  49. end
  50.  
  51. function Setbuildlimit()
  52.     if string.find(turtle.inspectDown().name ,"torch") then
  53.         local is2ndTorchfound = false
  54.         repeat
  55.             MoveForwards()
  56.             buildlimit = buildlimit + 1
  57.             if string.find(turtle.inspectDown().name ,"torch") then
  58.                 turtle.digDown()
  59.                 is2ndTorchfound=true
  60.                 Turn("Left")
  61.                 Turn("Left")
  62.             end
  63.         until is2ndTorchfound
  64.         is2ndTorchfound = false
  65.         repeat
  66.             MoveForwards()
  67.             if string.find(turtle.inspectDown().name ,"torch") then
  68.                 turtle.digDown()
  69.                 is2ndTorchfound=true
  70.                 Turn("Left")
  71.                 Turn("Left")
  72.             end
  73.         until is2ndTorchfound
  74.     end
  75. end
  76.  
  77. function MoveVertical(UpOrDown)
  78.     if UpOrDown=="Up" then
  79.         turtle.up()
  80.         y = y - 1
  81.     end
  82.    
  83.     if UpOrDown == "Down" then
  84.         turtle.down()
  85.         y = y + 1
  86.     end
  87. end
  88.    
  89. function FreeSlotsleft()
  90.     local count = 0
  91.     local i = 1
  92.     repeat
  93.         if turtle.getItemCount(i)>0 then
  94.             count = count + 1
  95.         end
  96.         i = i + 1
  97.     until i==16
  98.     return count
  99. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement