Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---------------------------------------
- -- 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() turtle.suck() end
- local function su() turtle.suckUp() end
- local function sd() turtle.suckDown() end
- local function Df() turtle.drop() end
- local function Du() turtle.dropUp() end
- local function Dd() turtle.dropDown() end
- local function ss(s) turtle.select(s) end
- --function to suck and drop all from chest--
- function suckAll()
- ss(1) sf() ss(2) sf() ss(3) sf() ss(4) sf() ss(5) sf() ss(6)
- sf() ss(7) sf() ss(8) sf() ss(9) sf()
- end
- function dropAll()
- ss(1) Df() ss(2) Df() ss(3) Df() ss(4) Df() ss(5) Df() ss(6)
- Df() ss(7) Df() ss(8) Df() ss(9) Df()
- end
- --
- rednet.open("left")
- rednet.broadcast(os.computerID().. " Butler is online!")
- function clear() term.clear() term.setCursorPos(1, 1) end
- local minFuelAmount = 100
- --return home upon restart--
- shell.run("goto", -58,65,-446)
- while true do
- rednet.open("left")
- clear()
- if turtle.getFuelLevel() < minFuelAmount then
- print("I am out of fuel!")
- ss(16)
- turtle.refuel(1)
- end
- print( "ID: [", os.computerID(), "]Butler is waiting for insturctions.")
- rednet.send(62, "Listening")
- local id, msg = rednet.receive(5)
- if msg == "deposit gold" then
- print("Told to deposit gold by ID:["..id.."]")
- shell.run("goto", -64,66,-444)
- suckAll()
- shell.run("goto", -67,67,-447)
- dropAll()
- shell.run("goto", -58,65,-446)
- else
- if msg == "get gold" then
- local id, msg = rednet.receive()
- amount = tonumber(msg)
- --print("Told to retrieve "..amount.." gold by ID:["..id.."]")
- shell.run("goto", -67,67,-447)
- turtle.suck(amount)
- shell.run("goto", -62,66,-444)
- dropAll()
- shell.run("goto", -58,65,-446)
- turtle.turnRight()
- else
- if msg == "deposit iron" then
- print("Told to deposit iron by ID:["..id.."]")
- shell.run("goto", -64,66,-444)
- suckAll()
- shell.run("goto", -67,66,-447)
- dropAll()
- shell.run("goto", -58,65,-446)
- else
- if msg == "get iron" then
- local id, msg = rednet.receive()
- amount = tonumber(msg)
- print("Told to retrieve "..amount.." iron by ID:["..id.."]")
- shell.run("goto", -67,66,-447)
- turtle.suck(amount)
- shell.run("goto", -62,66,-444)
- dropAll()
- shell.run("goto", -58,65,-446)
- turtle.turnRight()
- else
- if msg == "reboot" then
- os.reboot()
- else
- end
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement