SparkVGX

tempUpdateS

Jan 10th, 2013
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. selectedItem = 1
  2. pressedOkay = false
  3.  
  4.  
  5.  
  6. local function userResponse()
  7.  
  8.  
  9.     event, param1 = os.pullEvent("key")
  10.  
  11. --down
  12.     if param1 == 208 then
  13.         selectedItem = selectedItem - 1
  14.  
  15. --up
  16.     elseif param1 == 200 then
  17.         selectedItem = selectedItem + 1
  18.  
  19. -- if they press enter
  20.     elseif param1 == 28 then
  21.         pressedOkay = true
  22.        
  23.     end
  24.  
  25. -- loop
  26.     if selectedItem == 3 then
  27.         selectedItem = 1
  28.  
  29.     elseif selectedItem == 0 then
  30.         selectedItem = 2
  31.     end
  32.  
  33.  
  34. updating()
  35. end
  36.  
  37. function updating()
  38. -- if we've chosen which to update
  39.   if pressedOkay == true then
  40.       if selectedItem == 1 then
  41.          turtleUpdate()
  42.    
  43.     elseif selectedItem == 2 then
  44.        computerUpdate()
  45.     end
  46.   end
  47. end
  48.  
  49.  
  50. function chooseUpdater()
  51. while not pressedOkay do
  52.     term.clear() -- Clear the screen
  53.     term.setCursorPos(1,1) -- Set the cursor pos
  54.  
  55.     print ("Which updater would you like to use?") -- Message to print above the menu
  56.     print()
  57.     print ("Controls:")
  58.     print ("Arrow Keys to move up and down, Enter to select") -- Message to print above the menu
  59.     print()
  60.     if selectedItem == 1 then
  61.        
  62.         print("-Turtle Updater-") -- Text to show if the cursor is on the first choice
  63.         print("Computer Updater")
  64.     print()        
  65.     elseif selectedItem == 2 then
  66.         print("Turtle Updater") -- Text to show if the cursor is on the second choice
  67.         print("-Computer Updater-")
  68.     print()        
  69.     end
  70.  
  71.     userResponse()
  72. end
  73. end
  74.  
  75.  
  76.  
  77.  
  78. function turtleUpdate()
  79. -- backwards compatible delete previous programs
  80. shell.run('delete startup')
  81. shell.run('delete excav')
  82. shell.run('delete bridge')
  83. shell.run('delete checkFuel')
  84.  
  85. --delete ones in folders
  86. fs.delete('sp')
  87.  
  88. --downloads updated files
  89. shell.run('pastebin get SatJv72h startup')
  90. shell.run('pastebin get hyFheSSf excav')
  91. shell.run('pastebin get ULK49FXh bridge')
  92. shell.run('pastebin get f7yDWLE5 checkFuel')
  93. shell.run('pastebin get TLLF4awU BENCH')
  94. -- move to folder
  95. shell.run('mkdir sp')
  96.  
  97. shell.run('move checkFuel sp')
  98. shell.run('move excav sp')
  99. shell.run('move bridge sp')
  100. shell.run('move BENCH sp')
  101. end
  102.  
  103. function computerUpdate()
  104. --delete ones in folders
  105. fs.delete('sp')
  106.  
  107. --downloads updated files
  108. shell.run('delete startup')
  109. shell.run('pastebin get rPXXw0pn startup')
  110. shell.run('pastebin get Sc1mUb9f lockDoor')
  111.  
  112. -- move to folder
  113. shell.run('mkdir sp')
  114. shell.run('move lockDoor sp')
  115. end
  116.  
  117. chooseUpdater()
Advertisement
Add Comment
Please, Sign In to add comment