UNOBTANIUM

uwcc0.9.5 prerelease

Apr 3rd, 2013
988
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.40 KB | None | 0 0
  1. --MENU
  2. --VARIABLES
  3.  
  4. local version = "ULTIMATE WOOD CHOPPER BETA 0.9.5 prerelease"
  5. local w,h = term.getSize()
  6. local select, menu = 1, 1
  7. local running = true
  8. rednet.open("back")
  9.  
  10. --PRINT
  11.  
  12. local function printCentered(str, ypos)
  13.  term.setCursorPos(w/2 - #str/2, ypos)
  14.  term.write(str)
  15. end
  16.  
  17. local function printRight(str, ypos)
  18.  term.setCursorPos(w-#str, ypos)
  19.  term.write(str)
  20. end
  21.  
  22. function clearScreen()
  23.  term.clear()
  24.  term.setCursorPos(1,1)
  25.  term.clear()
  26. end
  27.  
  28. function drawHeader(title, line)
  29.  printCentered(title, line)
  30.  printCentered(string.rep("-", w), line+1)
  31. end
  32.  
  33. function drawCopyright()
  34.  printRight("by UNOBTANIUM", h)
  35. end
  36.  
  37. --MENUS
  38.  
  39.  
  40. local menupoint = {
  41. {"Chop", "Turtle Interactions", "Help", "Credits", "Quit",nil,nil},
  42. {"Farm","Single Tree","Back",nil,nil,nil},
  43. {"Standard Farm","Expanded Farm","Variables","Back",nil,nil,nil},
  44. {},
  45. {"Standard Farm","Expanded Farm","Back",nil,nil,nil,nil},
  46. {"Debug","Move Down","Back",nil,nil,nil,nil},
  47. {"Help Programs","Help Interface","Back",nil,nil,nil,nil},
  48. {"General 1x1 Tree","General 2x2 Tree","Back",nil,nil,nil,nil},
  49. {"Movement","Actions","Back",nil,nil,nil,nil,nil},
  50. {"Forward","Back","Up","Down","Turn Left","Turn Right","Back"},
  51. {"Refuel","Dig","Select","Back",nil,nil,nil},
  52. {"Up","Front","Down","Back",nil,nil,nil}
  53. }
  54.  
  55. local menupointselected = {
  56. {">> Chop <<", ">> Turtle Interactions <<", ">> Help <<", "> Credits <", "> Quit <",nil, nil},
  57. {">> Farm <<",">> Single Tree <<","> Back <",nil,nil,nil,nil},
  58. {"> Standard Farm <","> Expanded Farm <","> Variables <","> Back <",nil,nil,nil},
  59. {},
  60. {"> Standard Farm <","> Expanded Farm <","> Back <",nil,nil,nil,nil},
  61. {">> Debug <<","> Move Down <","> Back <",nil,nil,nil,nil},
  62. {">> Help Programs <<","> Help Interface <","> Back <",nil,nil,nil,nil},
  63. {"> General 1x1 Tree <","> General 2x2 Tree <","> Back <",nil,nil,nil,nil},
  64. {">> Movement <<",">> Actions <<","> Back <",nil,nil,nil,nil},
  65. {"> Forward <","> Back <","> Up <","> Down <","> Turn Left <","> Turn Right <","> Back <"},
  66. {"> Refuel <",">> Dig <<","> Select <","> Back <",nil,nil,nil},
  67. {"> Up <","> Front <","> Down <","> Back <",nil,nil,nil}
  68. }
  69.  
  70. local menupointnext = {
  71. {2, 9, 7, "credits", "quit"},
  72. {3,8,1},
  73. {"standard","expanded","variables",2},
  74. {},
  75. {"debugstandard","debugexpanded",6},
  76. {5,"godown",7},
  77. {6,"helpinterface",1},
  78. {"onebyone","twobytwo",2},
  79. {10,11,1},
  80. {"forward","back","up","down","left","right",9},
  81. {"refuel",12,"select",9},
  82. {"digup","digfront","digdown",10}
  83. }
  84.  
  85. function drawMenu()
  86.  drawHeader(version, 1)
  87.  if menu == 1 then
  88.   drawCopyright()
  89.  end
  90.  
  91.  for i=1,7 do
  92.   if menupoint[menu][i] then
  93.    if select == i then
  94.     printCentered(menupointselected[menu][i], i+4)
  95.    else
  96.     printCentered(menupoint[menu][i], i+4)
  97.    end
  98.   end
  99.  end
  100. end
  101.  
  102.  
  103. --RUN MENU
  104.  
  105.  
  106. function waitseconds(i)
  107.  message = ""
  108.  clearScreen()
  109.  print("Sending command...")
  110.  id, message = rednet.receive(1)
  111.  if message == "started" then
  112.   print("Started program...")
  113.   sleep(0.1)
  114.   print("Program in process...")
  115.   sleep(i)
  116.  else
  117.   print("No waiting turtle around...")
  118.   sleep(2)
  119.  end
  120. end
  121.  
  122.  
  123.  
  124. function runMenu()
  125.  while running do
  126.   clearScreen()
  127.   drawMenu(menu)
  128.  
  129.   local id, key = os.pullEvent("key")
  130.   if key == 200  or key == 17 then
  131.    select = select-1
  132.   end
  133.   if key == 208 or key == 31 then
  134.    select = select+1
  135.   end
  136.  
  137.   if select == 0 then
  138.    for i=7,1,-1 do
  139.     if menupoint[menu][i] then
  140.      select = i
  141.      break
  142.     end
  143.    end
  144.   end
  145.  
  146.   if not menupoint[menu][select] then
  147.    select = 1
  148.   end
  149.  
  150.   if key == 14 or key == 30 then
  151.    for i=7,1,-1 do
  152.     if menupoint[menu][i] then
  153.      select = i
  154.      break
  155.     end
  156.    end
  157.    if type(menupointnext[menu][select]) == "string" then
  158.     clearScreen()
  159.     running = false
  160.     break
  161.    elseif type(menupointnext[menu][select]) == "number" then
  162.     menu = menupointnext[menu][select]
  163.     for i=7,1,-1 do
  164.      if menupoint[menu][i] then
  165.       select = i
  166.       break
  167.      end
  168.     end
  169.    end
  170.   end
  171.  
  172.   clearScreen()
  173.   if key == 28 or key == 32 then
  174.    if type(menupointnext[menu][select]) == "string" then
  175.     rednet.broadcast(menupointnext[menu][select])
  176.    
  177.     if menupointnext[menu][select] == "quit" then
  178.      running = false
  179.      break
  180.     elseif menupointnext[menu][select] == "credits" then
  181.      drawMenuCredits()
  182.     elseif menupointnext[menu][select]== "helpinterface" then
  183.      FWChelp()
  184.     elseif menupointnext[menu][select] == "godown"
  185.      or menupointnext[menu][select] == "standard"
  186.      or menupointnext[menu][select] == "expanded"
  187.      or menupointnext[menu][select] == "debugstandard"
  188.      or menupointnext[menu][select] == "debugexpanded"
  189.      or menupointnext[menu][select] == "onebyone"
  190.      or menupointnext[menu][select] == "twobytwo"
  191.      or menupointnext[menu][select] == "standardnobonemeal"
  192.      or menupointnext[menu][select] == "expandednobonemeal" then
  193.      waitseconds(3)
  194.     elseif menupointnext[menu][select] == "forward"
  195.      or menupointnext[menu][select] == "back"
  196.      or menupointnext[menu][select] == "up"
  197.      or menupointnext[menu][select] == "down"
  198.      or menupointnext[menu][select] == "left"
  199.      or menupointnext[menu][select] == "right"
  200.      or menupointnext[menu][select] == "refuel"
  201.      or menupointnext[menu][select] == "select"
  202.      or menupointnext[menu][select] == "digup"
  203.      or menupointnext[menu][select] == "digfront"
  204.      or menupointnext[menu][select] == "digdown" then
  205.      waitseconds(0)
  206.     elseif menupointnext[menu][select] == "variables" then
  207.      clearScreen()
  208.      print("Changing the variables are not available in the rednet version. Please use the normal uwc program to do that. The turtle will use these in the rednet version as well.")
  209.      sleep(5)
  210.     end
  211.    elseif type(menupointnext[menu][select]) == "number" then
  212.     menu = menupointnext[menu][select]
  213.     select = 1
  214.    end
  215.   end
  216.  end
  217. end
  218.  
  219.  
  220. function FWChelp()
  221.  print("Welcome to the UWC Help Interface!")
  222.  print("If you have any question, suggestions, bugs or feedback, let me know: Type")
  223.  print("computercraft forum ultimate wood chopper")
  224.  print("in Google and write a post or PM at me ;D")
  225.  read()
  226. end
  227.  
  228. function drawMenuCredits()
  229.  drawHeader(version,1)
  230.  printCentered("all nicknames from the CC forums!!",3)
  231.  printCentered("- IDEA, CODEING & PUBLISHER -",5)
  232.  printCentered("unobtanium",6)
  233.  printCentered("- HELPING WITH CODING -",8)
  234.  printCentered("theoriginalbit, Mtdj2, NitrogenFingers", 9)
  235.  printCentered("- SPECIAL THANKS GOES TO -",11)
  236.  printCentered("Hoppingmad9, xInDiGo, Seleck",12)
  237.  printCentered("Permutation, PhilHibbs, DavEdward ",13)
  238.  read()
  239.  clearScreen()
  240.  drawHeader(version,1)
  241.  printCentered("- MENTIONABLES -",3)
  242.  printCentered("HotGirlEAN, snoxx, steel_toed_boot,",4)
  243.  printCentered("Zagi, Kylun, Kravyn, PhaxeNor, ughzug",5)
  244.  printCentered("sjkeegs, atlas, Minithra, TheFan",6)
  245.  printCentered("grumpysmurf, Quickslash78, lewanator1",7)
  246.  printCentered("behedwin, TESTimonSHOOTER",8)
  247.  printCentered("Kevironi, Fuzzlewhumper, Bigdavie",9)
  248.  printCentered("Viproz, Bigjimmy12, bomanski, punchin",10)
  249.  printCentered("oxgon, ahwtx, zilvar2k11",11)
  250.  printCentered("The_Ianator, Coolkrieger3", 12)
  251.  read()
  252.  clearScreen()
  253.  drawHeader(version,1)
  254.  printCentered(version,1)
  255.  printCentered("And last but not least",6)
  256.  printCentered("You, the users and players :D",7)
  257.  printCentered("Thank you everybody!!!", 10)
  258.  read()
  259. end
  260.  
  261.  
  262. -- MAIN PROGRAM
  263.  
  264. while running == true do
  265.  runMenu()
  266. end
Advertisement
Add Comment
Please, Sign In to add comment