Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Declaring Variables
- local isWood
- local Length
- local pastSelect
- local Block
- local Coal
- local Sap
- local Amount
- local Wait
- local Trees = 0
- --Start
- function start()
- term.setTextColor( colors.green )
- print("Welcome to the wood chopping program.")
- term.setTextColor( colors.red )
- print("How long do you want it to be?")
- Length = tonumber( io.read() )
- term.setTextColor( colors.green )
- print("The length is", Length)
- term.setTextColor( colors.red )
- print("How long do you want it to wait before checking for trees(in seconds)?")
- Wait = tonumber( io.read() )
- term.setTextColor( colors.green )
- print("The turtle will wait", Wait, "seconds")
- term.setTextColor( colors.blue )
- print("To Do: \n 1:Place 2 chests on on top of the\n other infront of the turtle so its\n facing it")
- term.setTextColor( colors.green )
- print("Press any key to continue")
- os.pullEvent("key")
- term.setTextColor( colors.blue )
- print(" 2:Place 10 charcoal in the bottom\n chest and", (Length * 2), "saplings in the top\n chest")
- term.setTextColor( colors.green )
- print("Press any key to continue")
- os.pullEvent("key")
- term.setTextColor( colors.blue )
- print(" 3:Place", (Length * 2), "of any block if you dont\n want any large trees to grow")
- term.setTextColor( colors.green)
- print("Press any key to continue")
- os.pullEvent("key")
- term.setTextColor( colors.blue )
- print(" 4:Route all saplings to the top chest\n and part of the charcoal to the\n bottom chest")
- term.setTextColor( colors.green )
- print("Press any key to continue")
- os.pullEvent("key")
- term.setTextColor( colors.blue )
- print(" 5:Make sure there is some method to\n suck up the dropped items")
- term.setTextColor( colors.green )
- print("Press any key to continue")
- os.pullEvent("key")
- term.setTextColor( colors.blue )
- print(" 6:Make sure the space is clear for\n the turtle")
- term.setTextColor( colors.orange )
- print("Press any key to start turtle.")
- os.pullEvent("key")
- getCoal()
- fuel()
- getSap()
- turtle.turnRight()
- --Places sapplings
- turtle.select(2)
- for i = 1, Length do
- turtle.dig()
- turtle.place()
- turtle.turnRight()
- turtle.turnRight()
- turtle.dig()
- turtle.place()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- end
- turtle.turnRight()
- turtle.back()
- turtle.turnLeft()
- for i = 1, 10 do
- turtle.up()
- end
- turtle.select(3)
- --Makes the top line to stop big trees
- for i = 1, Length do
- turtle.place()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.place()
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- end
- turtle.turnRight()
- turtle.forward()
- for i = 1, 10 do
- turtle.down()
- end
- turtle.select(2)
- end
- --Main part that loops
- function main()
- for i = 1, Length do
- fuel()
- turtle.turnLeft()
- check()
- turtle.turnRight()
- turtle.turnRight()
- check()
- turtle.turnLeft()
- turtle.forward()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- for i = 1, Length do
- turtle.forward()
- end
- getCoal()
- getSap()
- turtle.turnLeft()
- turtle.turnLeft()
- sleep()
- end
- function fuel()
- if (turtle.getFuelLevel() < 100) then
- repeat
- pastSelect = turtle.getSelectedSlot()
- turtle.select(1)
- turtle.refuel(1)
- turtle.select(pastSelect)
- until turtle.getFuelLevel() >= 100
- end
- end
- function check()
- turtle.place()
- local Um, Block = turtle.inspect()
- if (Block.name == "minecraft:log") then
- Trees = Trees+1
- print("Total trees:", Trees)
- chopNplant()
- end
- end
- function getCoal()
- if (turtle.getItemCount(1) < 10) then
- pastSelect = turtle.getSelectedSlot()
- Amount = 64 - turtle.getItemCount(1)
- turtle.select(1)
- turtle.suck(Amount)
- turtle.select(pastSelect)
- end
- end
- function getSap()
- if (turtle.getItemCount(2) < Length) then
- turtle.up()
- pastSelect = turtle.getSelectedSlot()
- Amount = 64 - turtle.getItemCount(2)
- turtle.select(2)
- turtle.suck(Amount)
- turtle.select(pastSelect)
- turtle.down()
- end
- end
- function sleep()
- os.sleep(Wait)
- main()
- end
- function chopNplant()
- turtle.dig()
- turtle.place()
- pastSelect = turtle.getSelectedSlot()
- turtle.select(3)
- turtle.drop()
- turtle.select(pastSelect)
- end
- start()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement