Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function os.pullEvent() --- disable ctrl T
- local event, p1, p2, p3, p4, p5 = os.pullEventRaw()
- local code = "0okm"
- local inputs = ""
- if event == "terminate" then
- print ("Enter Admin code")
- inputs = read()
- if inputs == code then
- exit()
- end
- sleep(2)
- end
- return event, p1, p2, p3, p4, p5
- end
- function pickEnder(enderNumber,enderChest) --enderNumber is between 0 and 4096, enderChest is the wrapped chest
- b1 = math.floor(enderNumber/ 256) -- find first colour code
- b2 = math.floor((enderNumber - (256 *b1)) / 16)
- b3 = enderNumber % 16
- error = enderChest.setColors(2^b1,2^b2,2^b3)
- return error
- end -- ends pickEnder()
- function invSort()
- for i = 1,16 do
- if turtle.getItemCount(i) > 0 and turtle.getItemCount(i) < 64 then
- turtle.select(i)
- for j = i+1,16 do
- if turtle.compareTo(j) then
- turtle.select(j)
- turtle.transferTo(i)
- turtle.select(i)
- end
- end
- end
- end
- end
- function unload()
- -- local isSeed = false
- local outPutChest = 128-- chest combo to output inv
- local isBlock
- local blockDetail
- isBlock, blockDetail = turtle.inspectUp()
- if (blockDetail.name == "EnderStorage:enderChest") then
- chest = peripheral.wrap("top")
- pickEnder(outPutChest,chest)
- end
- turtle.select(1)
- while turtle.suckUp() == true do
- end
- end
- function isTurn()
- signalBlock = {right = "minecraft:log", left = "chisel:redstone_block", up = "minecraft:cobblestone", down = "minecraft:netherrack", chest = "EnderStorage:enderChest"} -- this table holds values for the signal block the turtle uses to decide what way to turn
- local isBlock = true
- local infoBlock -- checks if and what type of block is in front of it
- while (isBlock == true) do
- isBlock, infoBlock = turtle.inspect()
- if (isBlock == true) then
- if (infoBlock.name == signalBlock.left) then
- turtle.turnLeft()
- unload()
- elseif (infoBlock.name == signalBlock.right) then
- turtle.turnRight()
- unload()
- elseif (infoBlock.name == signalBlock.up) then
- turtle.up()
- elseif (infoBlock.name == signalBlock.down) then
- turtle.down()
- elseif (infoBlock.name == signalBlock.chest) then
- unload()
- turtle.turnLeft()
- -- else
- -- print("path blocked. remove object and hit enter")
- -- read()
- end
- end
- end
- end
- function menu ()
- while true do
- local keyPress
- term.clear()
- term.setCursorPos(1,1)
- print("press p to pause")
- keyPress = read()
- if keyPress == "p" then
- isPause = true
- term.clear()
- term.setCursorPos(1,1)
- while isPause == true do
- print("press r to resume, e to edit")
- keyPress = read()
- if keyPress == "r" then
- hasSeeds = true
- isPause = false
- elseif keyPress == "e" then
- --edit()
- print("edit no worko")
- end
- end
- end
- end
- end
- function forward()
- local isObject
- local isFound = false
- local objId
- print("Do I turn?")
- isTurn()
- -- turtle.select(1)
- while isFound == false do
- isObject, objId = turtle.inspectDown()
- if isObject == false then
- turtle.forward()
- isTurn()
- else
- if objId.name == "Botania:specialFlower" then
- isFound = true
- --turtle.forward()
- isTurn()
- else
- turtle.forward()
- isTurn()
- end
- end
- end
- end
- function dropItem()
- local itemsCount = 0
- local slot = turtle.getSelectedSlot()
- local count = 0
- local isFound = false
- while isFound == false do
- itemsCount = turtle.getItemCount(slot)
- if itemsCount > 0 then
- isFound = true
- turtle.select(slot)
- else
- slot = slot + 1
- if slot == 17 then
- slot = 1
- end
- end
- end
- turtle.dropDown(1)
- end
- function go() -- main farm function
- while true do
- print("Forward")
- forward()
- print("dropping")
- dropItem()
- turtle.forward()
- while (isPause) do
- sleep(1)
- end
- end
- end
- local isPause = false
- parallel.waitForAll(menu, go)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement