Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("right")
- local func
- local params
- local funcTable
- local tArgs = {...}
- function cleanup()
- for i = 1,12 do
- turtle.select(i)
- turtle.dropDown()
- end
- end
- function place()
- turtle.select(16)
- turtle.place()
- turtle.down()
- turtle.select(15)
- turtle.place()
- turtle.select(14)
- turtle.placeDown()
- end
- function placePower()
- turtle.select(1)
- turtle.place()
- turtle.down()
- turtle.select(2)
- turtle.place()
- turtle.attack()
- end
- function removePower()
- turtle.select(2)
- turtle.dig()
- turtle.up()
- turtle.select(1)
- turtle.dig()
- turtle.forward()
- end
- function remove()
- turtle.select(14)
- turtle.digDown()
- turtle.select(15)
- turtle.dig()
- turtle.up()
- turtle.select(16)
- turtle.dig()
- end
- function fuel()
- turtle.select(13)
- turtle.placeUp()
- turtle.select(1)
- turtle.suckUp()
- turtle.dropUp(turtle.getItemCount(1) - 4)
- turtle.refuel()
- turtle.select(13)
- turtle.digUp()
- end
- function fuelBoss(powerStations)
- local numTurtles = 0
- for x,y in pairs(powerStations) do
- if type(y) ~= "table" then
- numTurtles=numTurtles+1
- end
- if type(y) == "table" then
- for w,z in pairs(y) do
- numTurtles=numTurtles+1
- end
- end
- end
- turtle.select(13)
- turtle.placeUp()
- turtle.select(1)
- turtle.suckUp()
- turtle.dropUp(turtle.getItemCount(1)-numTurtles*4)
- turtle.select(13)
- turtle.digUp()
- turtle.up()
- turtle.select(1)
- for x,y in pairs(powerStations) do
- if x==1 and y==1 then
- turtle.turnRight()
- turtle.drop(4)
- turtle.turnLeft()
- else
- for w,z in pairs(y) do
- turtle.forward()
- turtle.turnRight()
- goForward(z+1)
- turtle.turnRight()
- turtle.drop(4)
- turtle.turnRight()
- goForward(z+1)
- turtle.turnRight()
- turtle.back()
- end
- end
- end
- turtle.down()
- end
- function goForward(x)
- for i = 1,x do
- turtle.forward()
- end
- end
- function checkFuel()
- if turtle.getFuelLevel() < 600 then
- fuel()
- end
- end
- function checkStationFuel(fromID)
- if turtle.getFuelLevel() < 600 then
- rednet.send(fromID, "true")
- end
- end
- function eatFuel()
- turtle.select(3)
- turtle.refuel()
- turtle.select(1)
- end
- function cycle(time)
- place()
- if time ~= nil then
- time = tonumber(time)
- sleep(time)
- else
- sleep(25)
- end
- while turtle.getItemCount(1) > 0 do
- cleanup()
- sleep(2)
- end
- remove()
- checkFuel()
- turtle.forward()
- end
- function checkIn(fromID)
- rednet.send(fromID, tArgs[1])
- end
- function chunkLoad()
- turtle.select(16)
- turtle.digUp()
- checkFuel()
- turtle.select(16)
- turtle.forward()
- turtle.placeUp()
- end
- function explode(div,str) -- credit: http://richard.warburton.it
- if (div=='') then return false end
- local pos,arr = 0,{}
- -- for each divider found
- for st,sp in function() return string.find(str,div,pos,true) end do
- table.insert(arr,string.sub(str,pos,st-1)) -- Attach chars left of current divider
- pos = sp + 1 -- Jump past current divider
- end
- table.insert(arr,string.sub(str,pos)) -- Attach chars right of last divider
- return arr
- end
- while true do
- local id,msg,dist = rednet.receive()
- local j,v = string.gsub(msg, "_", "_")
- if v == 1 then
- funcTable = explode("_", msg)
- func = loadstring(funcTable[1].."(...)")
- params = loadstring("return "..funcTable[2])()
- setfenv(func, getfenv())
- func(params)
- else
- func = loadstring(msg.."(...)")
- setfenv(func, getfenv())
- func(params)
- end
- rednet.send(id,"Done")
- end
Advertisement
Add Comment
Please, Sign In to add comment