Heracles421

Turtle Remote Control Tutorial

Nov 23rd, 2012
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.78 KB | None | 0 0
  1. function menu(id, text)
  2.     if sid == id then
  3.         print("["..text.."]")
  4.     else
  5.         print(" "..text)
  6.     end
  7. end
  8.  
  9. function RCmaster()
  10. sid = 0
  11. while true do
  12.     term.clear()
  13.     term.setCursorPos(1,1)
  14.     print("TurtleControl V "..version..". Mode: Broadcast")
  15.     menu(0, "Movement")
  16.     menu(1, "Block Placing")
  17.     menu(2, "Others")
  18.     menu(3, "Exit")
  19.     local sEvent, param = os.pullEvent("key")
  20.     if(sEvent == "key") then
  21.         if(param == 200) then
  22.             if sid > 0 then
  23.                 sid = sid - 1
  24.             elseif sid == 0 then
  25.                 sid = 3
  26.             end
  27.         elseif (param == 208) then
  28.             if sid < 3 then
  29.                 sid = sid + 1
  30.             elseif sid == 3 then
  31.                 sid = 0
  32.             end
  33.         elseif (param == 28) then
  34.             if (sid == 0 and section == 0) then
  35.                 sid = 0
  36.                 term.clear()
  37.                 term.setCursorPos(1,1)
  38.                 print("Correct! Now use the arrow keys to select the forward option")
  39.                 sleep(5)
  40.                 while true do
  41.                     term.clear()
  42.                     term.setCursorPos(1,1)
  43.                     print("TurtleControl V "..version..". Mode: Broadcast")
  44.                     menu(0, "Forward")
  45.                     menu(1, "Backward")
  46.                     menu(2, "Turn Left")
  47.                     menu(3, "Turn Right")
  48.                     menu(4, "Up")
  49.                     menu(5, "Down")
  50.                     menu(6, "Attack")
  51.                     menu(7, "Mine")
  52.                     menu(8, "Return to main menu")
  53.                     local sEvent, param = os.pullEvent("key")
  54.                     if(sEvent == "key") then
  55.                         if(param == 200) then
  56.                             if sid > 0 then
  57.                                 sid = sid - 1
  58.                             elseif sid == 0 then
  59.                                 sid = 8
  60.                             end
  61.                         elseif (param == 208) then
  62.                             if sid < 8 then
  63.                                 sid = sid + 1
  64.                             elseif sid == 8 then
  65.                                 sid = 0
  66.                             end
  67.                         elseif (param == 28) then
  68.                             if (sid == 0 and section == 0) then
  69.                                 term.clear()
  70.                                 term.setCursorPos(1,1)
  71.                                 rednet.broadcast("TS Forward")
  72.                                 print("Right! Now go on and select the backward option")
  73.                                 section = 1
  74.                                 sleep(5)
  75.                             elseif (sid ~= 0 and section == 0) then
  76.                                 term.clear()
  77.                                 term.setCursorPos(1,1)
  78.                                 print("I said forward!")
  79.                                 sleep(4)
  80.                             elseif (sid == 1 and section == 1) then
  81.                                 term.clear()
  82.                                 term.setCursorPos(1,1)
  83.                                 rednet.broadcast("TS Backward")
  84.                                 print("You're learning fast! Now select the up option")
  85.                                 section = 2
  86.                                 sleep(5)
  87.                             elseif (sid ~= 1 and section == 1) then
  88.                                 term.clear()
  89.                                 term.setCursorPos(1,1)
  90.                                 print("Backward you dummy!")
  91.                                 sleep(4)
  92.                             elseif (sid == 4 and section == 2) then
  93.                                 term.clear()
  94.                                 term.setCursorPos(1,1)
  95.                                 rednet.broadcast("TS Up")
  96.                                 print("You got it! Go for the down option")
  97.                                 section = 3
  98.                                 sleep(5)
  99.                             elseif (sid ~= 4 and section == 2) then
  100.                                 term.clear()
  101.                                 term.setCursorPos(1,1)
  102.                                 print("*Facepalm* You know what UP is right?")
  103.                                 sleep(4)
  104.                             elseif (sid == 5 and section == 3) then
  105.                                 term.clear()
  106.                                 term.setCursorPos(1,1)
  107.                                 rednet.broadcast("TS Down")
  108.                                 print("You mastered it! One last test, choose the return to main menu option and then exit the tutorial")
  109.                                 section = 4
  110.                                 sleep(5)
  111.                             elseif (sid ~= 5 and section == 3) then
  112.                                 term.clear()
  113.                                 term.setCursorPos(1,1)
  114.                                 print("....... I won't tell anything else")
  115.                                 sleep(4)
  116.                             elseif (sid == 8 and section == 4) then
  117.                                 RCmaster()
  118.                             elseif (sid ~= 8 and section == 4) then
  119.                                 term.clear()
  120.                                 term.setCursorPos(1,1)
  121.                                 print("FAIL!")
  122.                                 sleep(4)
  123.                             end
  124.                         end
  125.                     end
  126.                 end
  127.             elseif (sid ~= 0 and section == 0) then
  128.                 term.clear()
  129.                 term.setCursorPos(1,1)
  130.                 print("I asked for the movement menu!")
  131.                 sleep(4)
  132.             elseif (sid == 3 and section == 4) then
  133.                 term.clear()
  134.                 term.setCursorPos(1,1)
  135.                 print("Congrats! You're now an official turtle driver. You know the basics, now it's time to explore the real program and all it's power")
  136.                 sleep(12)
  137.                 term.clear()
  138.                 term.setCursorPos(1,1)
  139.                 print("Collect your medal in the forum post and place it in your forum signature!")
  140.                 sleep(8)
  141.                 shell.run("delete", "startup")
  142.                 os.reboot()
  143.             elseif (sid ~= 3 and section == 4) then
  144.                 term.clear()
  145.                 term.setCursorPos(1,1)
  146.                 print("You were so close, derp!")
  147.                 sleep(4)
  148.             end
  149.         end
  150.     end
  151. end
  152. end
  153.  
  154. section=0
  155. version=1.0
  156. term.clear()
  157. term.setCursorPos(1,1)
  158. print("Welcome to the Turtle Remote V "..version.." tutorial, here you'll learn the basics to use the program. Make sure you have a turtle running the receiver program or you won't see how it moves. Now lets get started! NOTE: Some options have been disabled in this tutorial, explore them in the normal program")
  159. sleep(25)
  160. term.clear()
  161. term.setCursorPos(1,1)
  162. print("Ok! Your first task will be to head over to the movement menu. Use the arrow keys to change option and click enter to choose an option")
  163. sleep(10)
  164. RCmaster()
Advertisement
Add Comment
Please, Sign In to add comment