Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("/menu")
- local protocol = "utility"
- rednet.open("back")
- local server = rednet.lookup(protocol, "portalControl")
- function open(book)
- -- term.setBackgroundColor(colors.black)
- -- term.setTextColor(colors.white)
- -- term.clear()
- -- print(book)
- rednet.send(server, tostring(book), protocol)
- --local id, response = rednet.receive(protocol)
- end
- function resetTerm()
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.setCursorPos(1, 1)
- term.clear()
- end
- rednet.send(server, "list", protocol)
- local id, response = rednet.receive(protocol)
- for i, v in pairs(response) do
- menu.addItem(tostring(v), open, i)
- end
- menu.draw()
- while true do
- local event, key = os.pullEvent("key")
- if key == 28 then
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- local item = menu.getSelectedItem()
- item["callback"](item["arg"])
- break
- elseif key == 200 then
- menu.up()
- elseif key == 208 then
- menu.down()
- elseif key == 20 then
- resetTerm()
- break
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement