Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitor = peripheral.find("monitor")
- local id = rednet.lookup("bar", "maker")
- if id then
- print("Found my_host at computer #" .. id)
- else
- printError("Cannot find my_host")
- end
- peripheral.find("modem", rednet.open)
- term.redirect(monitor)
- term.clear()
- term.setCursorPos(1,1)
- textutils.slowWrite("BestBar loading", 10)
- term.setCursorPos(1,2)
- textutils.slowWrite("Connecting", 10)
- term.setCursorPos(1,3)
- local computers = {rednet.lookup("bar","maker")}
- if #computers > 0 then
- textutils.slowWrite("Sucefull connected", 10)
- else
- textutils.slowWrite("Connection problem. Shutdowning!", 10)
- sleep(1)
- term.clear()
- os.shutdown()
- end
- term.setCursorPos(1,4)
- textutils.slowWrite("Startup", 10)
- sleep(1)
- term.clear()
- while true do
- local eventData = {os.pullEvent()}
- local event = eventData[1]
- local colorsa = {colors.red,colors.green,colors.white,colors.orange}
- local array = {"Apple","Waterlemon","Coconut","Caramel"}
- term.setCursorPos(1,1)
- term.write("BestBar menu", 5)
- for i=1,4 do
- term.setTextColor(colorsa[i])
- term.setCursorPos(1,i+1)
- term.write(array[i])
- term.setTextColor(colors.white)
- end
- term.setCursorPos(1,1)
- if event == "monitor_touch" then
- for i=1,4 do
- if eventData[4] == i+1 then
- term.setTextColor(colorsa[i])
- term.setCursorPos(11,i+1)
- term.write("Requesting","bar")
- rednet.broadcast(array[i])
- sleep(1)
- term.clear()
- os.setAlarm(1)
- break
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement