Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- turtle_num = 492
- 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 button_draw(number, ypos)
- term.setCursorPos(1, ypos)
- x, button[number] = term.getCursorPos()
- if names[number] ~= nil then
- text = names[number]:upper()
- term.write(" " .. text .. " ")
- end
- end
- function select_button()
- z = 1
- button_pressed = nil
- repeat
- if names[z] ~= nil then
- if y == button[z] then
- return z
- end
- end
- z = z + 1
- until z > table.maxn(names)
- end
- names = {[1] = "up", [2] = "down", [3] = "forward", [4] = "back", [5] = "t left", [6] = "t right", [7] = "place", [8] = "dig", [9] = "suck", [10] = "drop", [11] = "unload", [12] = "inv 1", [13] = "inv 16"}
- button = {}
- rednet.open(find_peripheral(modem, wireless)
- function draw()
- term.clear()
- for num=1,table.maxn(names) do
- button_draw(num, num)
- end
- while true do
- e, i, x, y = os.pullEvent()
- num = select_button()
- if num ~= nil then
- rednet.send(turtle_num, names[num])
- end
- draw()
- end
Advertisement
Add Comment
Please, Sign In to add comment