Advertisement
kirkarr

Untitled

Apr 6th, 2023 (edited)
604
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.47 KB | None | 0 0
  1. local monitor = peripheral.find("monitor")
  2. local id = rednet.lookup("bar", "maker")
  3. if id then
  4.   print("Found my_host at computer #" .. id)
  5. else
  6.   printError("Cannot find my_host")
  7. end
  8. peripheral.find("modem", rednet.open)
  9. term.redirect(monitor)
  10. term.clear()
  11. term.setCursorPos(1,1)
  12. textutils.slowWrite("BestBar loading", 10)
  13. term.setCursorPos(1,2)
  14. textutils.slowWrite("Connecting", 10)
  15. term.setCursorPos(1,3)
  16. local computers = {rednet.lookup("bar","maker")}
  17. if #computers > 0 then
  18. textutils.slowWrite("Sucefull connected", 10)
  19. else
  20. textutils.slowWrite("Connection problem. Shutdowning!", 10)
  21. sleep(1)
  22. term.clear()
  23. os.shutdown()
  24. end
  25. term.setCursorPos(1,4)
  26. textutils.slowWrite("Startup", 10)
  27. sleep(1)
  28. term.clear()
  29. while true do
  30.     local eventData = {os.pullEvent()}
  31.     local event = eventData[1]
  32.     local colorsa = {colors.red,colors.green,colors.white,colors.orange}
  33.     local array = {"Apple","Waterlemon","Coconut","Caramel"}
  34.     term.setCursorPos(1,1)
  35.     term.write("BestBar menu", 5)
  36.     for i=1,4 do
  37.         term.setTextColor(colorsa[i])
  38.         term.setCursorPos(1,i+1)
  39.         term.write(array[i])
  40.         term.setTextColor(colors.white)
  41.     end
  42.     term.setCursorPos(1,1)
  43.     if event == "monitor_touch" then
  44.         for i=1,4 do
  45.             if eventData[4] == i+1 then
  46.                 term.setTextColor(colorsa[i])
  47.                 term.setCursorPos(11,i+1)
  48.                 term.write("Requesting","bar")
  49.                 rednet.broadcast(array[i])
  50.                 sleep(1)
  51.                 term.clear()
  52.                 os.setAlarm(1)
  53.                 break
  54.             end
  55.         end
  56.     end
  57. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement