Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dofile("bs/wrapper")
- local params = bs.params.load("bs/files/simpletree_params")
- local hook = bs.rdnt.hook:new()
- hook.port = "simpletree"
- if params[1] == nil then
- bs.ui.clear()
- local menuparam = {{text = "Oaktree", value = "oak"}, {text = "Birchtree", value = "birch"}, {text = "Jungetree", value = "jungle"}, {}}
- local ttype = bs.ui.printMenu("Which Tree-Type do you want to farm?", menuparam)
- params.type = ttype
- repeat
- bs.ui.clear()
- print("Please put in at least 4 saplings to start with")
- bs.ui.pressenter()
- until bs.inventory.IsInInventory(params.type.."_sapling", 4)
- if ttype == "oak" then
- bs.ui.clear()
- print("Please add the block at %height% ")
- bs.ui.pressenter()
- end
- bs.ui.clear()
- print("Please setup a saplingfarmer 1 block behind this one and 2 blocks to the right")
- bs.ui.pressenter()
- if hook:connect(5) ~= 0 then
- printError("Cannot connect to saplingfarmer")
- end
- params.socketID = hook.socketID
- bs.params.save("bs/files/simpletree_params", params)
- else
- hook.socketID = params.socketID
- end
- local function growTree()
- if not bs.inventory.selectID(params.type.."_logs") then return false, "no more saplings" end
- turtle.place()
- while true do
- redstone.setOutput("down", true)
- sleep(0.05)
- redstone.setOutput("down", false)
- local inspect = turtle.inspect()
- if string.find(inspect.name, "log") <> 0 then
- return true
- end
- end
- end
- local function breakTree()
- turtle.dig()
- turtle.forward()
- local inspect = turtle.inspectUp()
- while string.find(inspect.name, "log") <> 0 do
- turtle.digUp()
- turtle.up()
- inspect = turtle.inspectUp()
- end
- turtle.digUp()
- turtle.up()
- repeat
- for I = 1, 4 do
- turtle.dig()
- turtle.turnLeft()
- end
- until not turtle.down()
- turtle.back()
- end
- local function dropLogs()
- turtle.back()
- turtle.turnLeft()
- turtle.turnLeft()
- for I = 1, 16 do
- if turtle.getItemDetail(I) ~= nil then
- local detail = turtle.getItemDetail(I)
- if string.find(detail.name, "sapling") == 0 then
- turtle.select(I)
- turtle.drop()
- end
- end
- end
- turtle.select(1)
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.forward()
- end
- while true do
- if not growTree() then printError("No saplings found") end
- hook:request("breakleaves")
- breakTree()
- if bs.inventory.getfirstFreeIndex() > 12 then
- dropLogs()
- end
- hook:request("giveItems")
- end
Add Comment
Please, Sign In to add comment