Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local cSleepTime=1
- local data1, data2
- ---------------------------------------
- -- basic functions for turtle control -
- ---------------------------------------
- local function gf() while not turtle.forward() do end end
- local function gb() while not turtle.back() do end end
- local function gu() while not turtle.up() do end end
- local function gd() while not turtle.down() do end end
- local function gl() while not turtle.turnLeft() do end end
- local function gr() while not turtle.turnRight() do end end
- local function df() turtle.dig() end
- local function du() turtle.digUp() end
- local function dd() turtle.digDown() end
- local function pf() turtle.place() end
- local function pu() turtle.placeUp() end
- local function pd() turtle.placeDown() end
- local function sf() return turtle.suck() end
- local function su() return turtle.suckUp() end
- local function sd() return turtle.suckDown() end
- local function Df(n) return turtle.drop(n) end
- local function Du() return turtle.dropUp() end
- local function Dd() return turtle.dropDown() end
- local function ss(s) turtle.select(s) slotSelected=s end
- ---------------------------------------
- -- Main
- ---------------------------------------
- while true do
- ss(1)
- data1 = turtle.getItemDetail()
- print(" slot 1: "..data1.name)
- waitCounter=0
- while true do
- pu()
- data2 = turtle.getItemDetail()
- print(" slot 1: "..data2.name)
- if data1.name~=data2.name then
- -- the bucket should be filled now
- break
- else
- waitCounter=waitCounter+1
- print("No milk today, my love has gone away... I'll retry it after "..(cSleepTime+1)*waitCounter.." seconds.")
- sleep((cSleepTime+1)*waitCounter)
- if waitCounter > 30 then
- print("Error: I retried milking the cow 30 times and had no luck! Please, check set-up (cow,yogurt,bucket...).")
- return
- end
- end
- end
- print(" crafting fresh milk")
- turtle.craft() -- state 3: 1,4
- ss(2)
- waitCounter=0
- while true do
- if Dd() then
- break
- else
- waitCounter=waitCounter+1
- print("Waiting for inventory space... Waiting for ".. (cSleepTime+1)*waitCounter .. " seconds.")
- sleep((cSleepTime+1)*waitCounter)
- end
- end
- sleep(1)
- end
Add Comment
Please, Sign In to add comment