Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("left")
- turtleslots= {}
- function split(str, delim, maxNb)
- if string.find(str, delim) == nil then
- return { str }
- end
- if maxNb == nil or maxNb <1 then
- maxNb = 0
- end
- local result = {}
- local pat = "(.-)"..delim.."()"
- local nb = 0
- local lastPos
- for part, pos in string.gmatch(str,pat) do
- nb = nb+1
- result[nb]=part
- lastPos=pos
- if nb==maxNb then break end
- end
- if nb ~= maxNb then
- result[nb+1] = string.sub(str,lastPos)
- end
- return result
- end
- function turtleSlots(ID,slot)
- turtleslots[ID]= {}
- turtleslots[ID]["slot"]=slot
- end
- function fillSlotsData()
- turtleSlots("A1","1")
- turtleSlots("A2","2")
- turtleSlots("A3","3")
- turtleSlots("A4","4")
- turtleSlots("B1","5")
- turtleSlots("B2","6")
- turtleSlots("B3","7")
- turtleSlots("B4","8")
- turtleSlots("C1","9")
- turtleSlots("C2","10")
- turtleSlots("C3","11")
- turtleSlots("C4","12")
- turtleSlots("D1","13")
- turtleSlots("D2","14")
- turtleSlots("D3","15")
- end
- function replaceJuice()
- rs.setOutput("back",true) -- Stop the autonomous activator spitting out the bucket
- turtle.select(tonumber(Tslot))
- print("Slot selected:"..tonumber(Tslot))
- turtle.drop()
- print("Placed liquid in automn:")
- sleep(3)
- rs.setOutput("back",false) -- Make the autonomous activator spit out the bucket
- end
- fillSlotsData()
- while true do
- print("started")
- local event, id, msg = os.pullEvent("rednet_message")
- local Tab = split(msg,"|",2)
- Tslot=turtleslots[Tab[1]]["slot"]
- print("Message received:"..msg)
- print("Slot "..Tslot.." has been chosen")
- replaceJuice()
- end
Advertisement
Add Comment
Please, Sign In to add comment