Alkerss

Multiplayer TreeFarm

Jun 22nd, 2014
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.76 KB | None | 0 0
  1. -- Request for Project: Always revert back to previous selected slot after changing it
  2.  
  3. x=14
  4. z=16
  5. CounterTrees = 0
  6.  
  7. function hugoCutTree()
  8.     CounterTrees = CounterTrees + 1
  9.     turtle.dig()
  10.     turtle.forward()
  11.     turtle.digDown()
  12.     PlaceDownSafe(1)
  13.     local counter = 0
  14.     while turtle.detectUp() do
  15.         turtle.digUp()
  16.         if turtle.up() then counter = counter + 1 end
  17.     end
  18.     while counter > 0 do
  19.         if turtle.down() then counter = counter - 1 end
  20.     end
  21. end
  22.  
  23. function PlaceDownSafe( Min )
  24.     if turtle.getItemCount( 16 ) > Min then
  25.         turtle.placeDown()
  26.         return true
  27.     else
  28.         return false
  29.     end
  30. end
  31.  
  32. function TreeTile()
  33.         turtle.forward()
  34.         turtle.suckDown()
  35. end
  36. function CobbleTile()
  37.     if turtle.detect() then hugoCutTree() else turtle.forward(); PlaceDownSafe(1) end
  38.     turtle.suckDown()
  39. end
  40.  
  41. function Tile()
  42.     if TileSwitch == true then
  43.         TreeTile()
  44.         TileSwitch = false
  45.     else
  46.         CobbleTile()
  47.         TileSwitch = true
  48.     end
  49. end
  50.  
  51. while true do
  52.     --print("Let me chop chop trees!")
  53.     --os.pullEvent("char")
  54.     --print("CHOP CHOP nom nom nom....")
  55.     TileSwitch = false
  56.     turtle.up()
  57.     turtle.turnLeft()
  58.     turtle.select(16) -- Careful!
  59.     Tile()
  60.    
  61.     for i=1,z do
  62.         for j=1,x do Tile() end
  63.  
  64.         if i < z then
  65.             if i%2 == 0 then turtle.turnLeft() else turtle.turnRight() end
  66.             Tile()
  67.             if i%2 == 0 then turtle.turnLeft() else turtle.turnRight() end
  68.         else
  69.             Tile()
  70.             if i%2 == 1 then turtle.turnLeft() else turtle.turnRight() end
  71.             for j=1,z-1 do Tile() end      
  72.         end
  73.     end
  74.  
  75.     turtle.down()
  76.     turtle.turnLeft()
  77.     turtle.turnLeft()
  78.     for i=1,15 do
  79.         turtle.select(i)
  80.         turtle.dropDown()
  81.     end
  82.     turtle.select(16)
  83.     term.clear()
  84.     print("Finished, Master, chopped ", CounterTrees, " trees :)")
  85.     CounterTrees = 0
  86.     print()
  87. end
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94. function ReadChest( _Side, ... )
  95. end
Advertisement
Add Comment
Please, Sign In to add comment