Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function find_peripheral(t, e)
- e = e or nil
- sides = {[1] = "front", [2] = "back", [3] = "left", [4] = "right", [5] = "top", [6] = "bottom"}
- peripheral_found = false
- for num=1, 6 do
- type = peripheral.getType(sides[num])
- if type == t then
- if e == "wireless" then
- if peripheral.call(sides[num], "isWireless") then
- return sides[num]
- end
- elseif e == "remote" then
- if not peripheral.call(sides[num], "isWireless") then
- return sides[num]
- end
- elseif e == nil then
- return sides[num]
- end
- end
- end
- print("No " .. t .. " attached to the computer")
- end
- function unload()
- turtle.select(15)
- turtle.placeUp()
- for num=1,14 do
- turtle.select(num)
- turtle.dropUp()
- end
- turtle.select(15)
- turtle.digUp()
- turtle.select(1)
- end
- function suckall()
- turtle.suckUp()
- turtle.suckDown()
- repeat
- turtle.suck()
- until turtle.suck() == false
- unload()
- end
- rednet.open(find_peripheral("modem", "wireless"))
- --names = {[1] = turtle.up(), [2] = turtle.down(), [3] = turtle.forward(), [4] = turtle.back(), [5] = turtle.turnLeft(), [6] = turtle.turnRight(), [7] = turtle.Place(), [8] = turtle.dig(), [9] = suckall()
- --, [10] = turtle.drop(), [11] = unload(), [12] = turtle.select(1), [13] = turtle.select(16), [14] = turtle.digDown()}
- while true do
- e, i, x, y = os.pullEvent()
- if e == "rednet_message" and names[x] ~= nil then
- if x == 1 then turtle.up()
- elseif x == 2 then turtle.down()
- elseif x == 3 then turtle.forward()
- elseif x == 4 then turtle.back()
- elseif x == 5 then turtle.turnLeft()
- elseif x == 6 then turtle.turnRight()
- elseif x == 7 then turtle.place()
- elseif x == 8 then turtle.dig()
- elseif x == 9 then suckall()
- elseif x == 10 then turtle.drop()
- elseif x == 11 then unload()
- elseif x == 12 then turtle.select(1)
- elseif x == 13 then turtle.select(16)
- elseif x == 14 then turtle.digDown()
- end
- end
- print(e .. " " .. x)
- end
Advertisement
Add Comment
Please, Sign In to add comment