Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- server = 10
- function sep(list, by)
- local newlist = {}
- while true do
- local on = nil
- local done = false
- for i = 1, #list do
- if done == false then
- if string.sub(list, i, i) == by then
- on = i
- done = true
- end
- end
- end
- if on then
- table.insert(newlist, string.sub(list, 1, on - 1))
- list = string.sub(list, on + 1)
- else
- break
- end
- end
- table.insert(newlist, list)
- return newlist
- end
- function clear()
- term.clear()
- term.setCursorPos(1, 1)
- term.setTextColor(1)
- end
- function ports()
- rednet.open("back")
- rednet.open("top")
- rednet.open("front")
- rednet.open("bottom")
- rednet.open("left")
- rednet.open("right")
- end
- function dp()
- print("Doing: dump")
- for t = 5, 16 do
- turtle.select(t)
- for i = 1, 4 do
- local cm = turtle.compareTo(i)
- if cm == true then
- turtle.drop(turtle.getItemCount(t))
- end
- end
- end
- rednet.send(server, textutils.serialize({"derp"}))
- end
- function rec()
- local idr, msgr, elr = nil
- function lop()
- local id, msg = rednet.receive()
- if id == server then
- msg = textutils.unserialize(msg)
- idr = id
- msgr = msg
- else
- lop()
- end
- end
- lop()
- repeat sleep(0) until idr and msgr
- return idr, msgr
- end
- function main()
- clear()
- ports()
- rednet.send(server, textutils.serialize({true}))
- print("Running turtle on "..tostring(os.getComputerID()))
- function lolz()
- local id, msg = rec()
- for i,v in pairs(turtle) do
- if tostring(i) == msg[1] then
- print("Doing: "..tostring(i))
- local p1, p2, p3, p4 = v(msg[2], msg[3])
- rednet.send(server, textutils.serialize({p1, p2, p3, p4}))
- end
- end
- if msg[1] == "dp" then
- dp()
- end
- lolz()
- end
- lolz()
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement