SHARE
TWEET

startup

a guest May 23rd, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. rednet.open("top")
  2. djComputer = 714
  3. nSelect = 1
  4.  
  5. function cPrint(text)
  6.   local w, h = term.getSize()
  7.   local x, y = term.getCursorPos()
  8.   term.setCursorPos(math.ceil((w/2)-(text:len()/2)), y)
  9.   print(text)
  10. end
  11.  
  12. function clear()
  13.   term.clear()
  14.   term.setCursorPos(1,1)
  15. end
  16.  
  17. function mainLayout()
  18.   clear()
  19.   term.setTextColour(colours.white)
  20.   cPrint("What would you like to do?")
  21.   term.setCursorPos(1,3)
  22.   if nSelect == 1 then
  23.     term.setTextColour(colours.green)
  24.     cPrint("[ Play new song ]")
  25.   else
  26.     term.setTextColour(colours.white)
  27.     cPrint("  Play new song  ")
  28.   end
  29. end
  30.  
  31. function mainScreen()
  32.   while true do
  33.     mainLayout()
  34.     event, p1, p2, p3 = os.pullEvent()
  35.     if event == "key" then
  36.       key = p1
  37.       if key == 200 and nSelect > 1 then
  38.         nSelect = nSelect-1
  39.       elseif key == 208 and nSelect < 1 then
  40.         nSelect = nSelect+1
  41.       elseif key == 200 and nSelect == 1 then
  42.         nSelect = 1
  43.       elseif key == 208 and nSelect == 1 then
  44.         nSelect = 1
  45.       elseif key == 28 and nSelect == 1 then
  46.         rednet.send(djComputer, "StartNewSong")
  47.       end
  48.     end
  49.   end
  50. end
  51.  
  52. mainScreen()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top