Advertisement
GooGoo

Botania Flower Crafter - ComputerCraft Turtle Program

Apr 23rd, 2015
459
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.38 KB | None | 0 0
  1. -- ThaWade's Botania Flower making program version 1.1
  2. -- changelog: version 1.0 The first release
  3. -- version 1.1 added print to tell the user to place buckets in turtle.
  4. --TODO: Add functional flora.
  5. local function ss(s) turtle.select(s)   end
  6.  
  7. --code from Youtuber Kaikaku start--
  8. local function askForInputText(textt)
  9.   local at=""
  10.   -- check prompting texts
  11.   if textt==nil then textt="Enter text:" end
  12.  
  13.   -- ask for input
  14.   write(textt)
  15.   at=read()
  16.   return at
  17. end
  18. --code from Youtuber Kaikaku end--
  19.  
  20. function clearTerm()
  21.     term.clear()
  22.     term.setCursorPos(1,1)
  23. end
  24.  
  25. function isWaterBucket()
  26. local dropSlot = 1
  27. local waterBucket = 16
  28. local emptyBucket = 15
  29.  
  30. turtle.select(dropSlot)
  31.     while turtle.compareTo(waterBucket) == false do
  32.         if turtle.compareTo(waterBucket) == true then
  33.             turtle.drop()
  34.         elseif turtle.compareTo(waterBucket) == false and turtle.compareTo(emptyBucket) == true then
  35.             turtle.dropDown()
  36.         elseif turtle.getItemCount(1) == 0 then
  37.             turtle.suckDown()
  38.         elseif turtle.getItemCount(1) > 0 and turtle.compareTo(waterBucket) == false or turtle.compareTo(emptyBucket) == false then
  39.             turtle.transferTo(14)
  40.             turtle.suck()
  41.         end
  42.     end
  43. end
  44.  
  45. function grabBucket()
  46.     turtle.select(1)
  47.     turtle.suck()  
  48. end
  49.  
  50. function dropOneAndTwo()
  51.     turtle.select(1)
  52.     turtle.drop(1)
  53.     turtle.select(2)
  54.     turtle.drop(2)
  55. end
  56.  
  57. function howMany()
  58.     print("How many would you like to make?")
  59. amount = io.read()
  60. end
  61.  
  62. function bucketPlacement()
  63.     print("Put an empty bucket in slot 15")
  64.     print("Put a water bucket in slot 16")
  65. end
  66. --------------------------- generating flora Start ---------------------------
  67. function daybloom()--Tested 32
  68.     repeat
  69.         clearTerm()
  70.         print("DAYBLOOM")
  71.         print("Water bucket should be in slot 1")
  72.         print("Put yellow petals in slot 2.")
  73.         print("Put all other petals in slots 3 - 4.")
  74.         print("Put seeds in slot 5.")
  75.         bucketPlacement()
  76.     until askForInputText("Press enter when ready:")==""
  77.     howMany()
  78. for a = 1,amount do
  79.         isWaterBucket()
  80.         dropOneAndTwo()
  81.         for e = 3, 5 do
  82.             turtle.select(e)
  83.             turtle.drop(1)
  84.         end
  85.     grabBucket()
  86.     end
  87. end
  88.  
  89. function endoflame()--Tested 64
  90.     repeat
  91.         clearTerm()
  92.         print("ENDOFLAME")
  93.         print("Water bucket should be in slot 1")
  94.         print("Put petals in slots 2 - 6.")
  95.         print("Put seeds in slot 7.")
  96.         bucketPlacement()
  97.     until askForInputText("Press enter when ready:")==""
  98.         howMany()
  99.     for a = 1,amount do
  100.         isWaterBucket()
  101.         for e = 1, 7 do
  102.             turtle.select(e)
  103.             turtle.drop(1)
  104.         end
  105.     grabBucket()
  106.     end
  107. end
  108.  
  109. function entropinnyum() --Tested 64
  110.     repeat
  111.         clearTerm()
  112.         print("ENTROPINNYUM")
  113.         print("Water bucket should be in slot 1")
  114.         print("Put petals and runes in slots 2 - 9.")
  115.         print("Put seeds in slot 10.")
  116.         bucketPlacement()
  117.     until askForInputText("Press enter when ready:")==""
  118.         howMany()
  119.     for a = 1,amount do
  120.         isWaterBucket()
  121.         for e = 1, 10 do
  122.             turtle.select(e)
  123.             turtle.drop(1)
  124.         end
  125.     grabBucket()
  126.     end
  127. end
  128.  
  129. function gourmaryllis() --Tested 32
  130.     repeat
  131.         clearTerm()
  132.         print("GOURMARYLLIS")
  133.         print("Water bucket should be in slot 1")
  134.         print("Put yellow mana petals in slot 2.")
  135.         print("Put petals and runes in slots 3 - 8.")
  136.         print("Put seeds in slot 9.")
  137.         bucketPlacement()
  138.     until askForInputText("Press enter when ready:")==""
  139.         howMany()
  140.     for a = 1,amount do
  141.         isWaterBucket()
  142.         dropOneAndTwo()
  143.         for e = 3, 9 do
  144.             turtle.select(e)
  145.             turtle.drop(1)
  146.         end
  147.     grabBucket()
  148.     end
  149. end
  150.  
  151. function hydroangeas()--Tested 32
  152.     repeat
  153.         clearTerm()
  154.         print("HYDROANGEAS")
  155.         print("Water bucket should be in slot 1")
  156.         print("Put Cyan petals in slot 2.")
  157.         print("Put petals in slots 3 - 6.")
  158.         print("Put seeds in slot 7.")
  159.         bucketPlacement()
  160.     until askForInputText("Press enter when ready:")==""
  161.         howMany()
  162.     for a = 1,amount do
  163.         isWaterBucket()
  164.         dropOneAndTwo()
  165.         for e = 3, 7 do
  166.             turtle.select(e)
  167.             turtle.drop(1)
  168.         end
  169.     grabBucket()
  170.     end
  171. end
  172.  
  173. function kekimurus()--Tested 32
  174.     repeat
  175.         clearTerm()
  176.         print("KEKIMURUS")
  177.         print("Water bucket should be in slot 1")
  178.         print("Put Brown mana petals in slot 2.")
  179.         print("Put petals, rune and pixie dust in slots 3 - 8.")
  180.         print("Put seeds in slot 9.")
  181.         bucketPlacement()
  182.     until askForInputText("Press enter when ready:")==""
  183.         howMany()
  184.     for a = 1,amount do
  185.         isWaterBucket()    
  186.         dropOneAndTwo()
  187.         for e = 3, 9 do
  188.             turtle.select(e)
  189.             turtle.drop(1)
  190.         end
  191.     grabBucket()
  192.     end
  193. end
  194.  
  195. function munchdew() --Tested 64
  196.     repeat
  197.         clearTerm()
  198.         print("MUNCHDEW")
  199.         print("Water bucket should be in slot 1")
  200.         print("Put petals in slots 2 - 9.")
  201.         print("Put seeds in slot 10.")
  202.         bucketPlacement()
  203.     until askForInputText("Press enter when ready:")==""
  204.         howMany()
  205.     for a = 1,amount do
  206.         isWaterBucket()
  207.         for e = 1, 10 do
  208.             turtle.select(e)
  209.             turtle.drop(1)
  210.         end
  211.     grabBucket()
  212.     end
  213. end
  214.  
  215. function narslimmus() --Tested 64
  216.     repeat
  217.         clearTerm()
  218.         print("NARSLIMMUS")
  219.         print("Water bucket should be in slot 1")
  220.         print("Put petals in slots 2 - 8.")
  221.         print("Put seeds in slot 9.")
  222.         bucketPlacement()
  223.     until askForInputText("Press enter when ready:")==""
  224.         howMany()
  225.     for a = 1,amount do
  226.         isWaterBucket()
  227.         for e = 1, 9 do
  228.             turtle.select(e)
  229.             turtle.drop(1)
  230.         end
  231.     grabBucket()
  232.     end
  233. end
  234.  
  235. function nightshade() --tested 10
  236.     repeat
  237.         clearTerm()
  238.         print("NIGHTSHADE")
  239.         print("Water bucket should be in slot 1")
  240.         print("Put Black petals in slot 2.")
  241.         print("Put petals in slots 3 - 5.")
  242.         print("Put seeds in slot 6.")
  243.         bucketPlacement()
  244.     until askForInputText("Press enter when ready:")==""
  245.         howMany()
  246.     for a = 1,amount do
  247.         isWaterBucket()
  248.         dropOneAndTwo()
  249.         for e = 3, 5 do
  250.             turtle.select(e)
  251.             turtle.drop(1)
  252.         end
  253.     grabBucket()
  254.     end
  255. end
  256.  
  257. function rosaArcana()--Tested 10
  258.     repeat
  259.         clearTerm()
  260.         print("Rosa Arcana")
  261.         print("Water bucket should be in slot 1")
  262.         print("Put Pink Mana petals in slot 2.")
  263.         print("Put petals and runes in slots 3 - 7.")
  264.         print("Put seeds in slot 8.")
  265.         bucketPlacement()
  266.     until askForInputText("Press enter when ready:")==""
  267.         howMany()
  268.     for a = 1,amount do
  269.         isWaterBucket()
  270.         dropOneAndTwo()
  271.         for e = 3, 8 do
  272.             turtle.select(e)
  273.             turtle.drop(1)
  274.         end
  275.     grabBucket()
  276.     end
  277. end
  278.  
  279. function spectrolus()--Tested  10
  280.     repeat
  281.         clearTerm()
  282.         print("SPECTROLUS")
  283.         print("Water bucket should be in slot 1")
  284.         print("Put petals, runes and pixie dust in slots 2 - 12.")
  285.         print("Put seeds in slot 13.")
  286.         bucketPlacement()
  287.     until askForInputText("Press enter when ready:")==""
  288.         howMany()
  289.     for a = 1,amount do
  290.         isWaterBucket()
  291.         for e = 1, 13 do
  292.             turtle.select(e)
  293.             turtle.drop(1)
  294.         end
  295.     grabBucket()
  296.     end
  297. end
  298.  
  299. function thermalily()--Tested 10
  300.     repeat
  301.         clearTerm()
  302.         print("THERMALILY")
  303.         print("Water bucket should be in slot 1")
  304.         print("Put petals in slots 2 - 6.")
  305.         print("Put seeds in slot 7.")
  306.         bucketPlacement()
  307.     until askForInputText("Press enter when ready:")==""
  308.         howMany()
  309.     for a = 1,amount do
  310.         isWaterBucket()
  311.         for e = 1, 7 do
  312.             turtle.select(e)
  313.             turtle.drop(1)
  314.         end
  315.     grabBucket()
  316.     end
  317. end
  318.  
  319. function genFloraList()
  320.     repeat
  321.         clearTerm()
  322.         print("GENERATING FLOWERS:")
  323.         print("Daybloom: daybloom or dayb")
  324.         print("Endoflame: endoflame or endo")
  325.         print("Entropinnyum: entropinnyum or entr")
  326.         print("Gourmaryllis: gourmaryllis or gour")
  327.         print("Hydroangeas: hydroangeas or hydro")
  328.         print("Kekimurus: kekimurus or keki")
  329.         print("Munchdew: munchdew or munch")
  330.         print("Narslimmus: narslimmus or nars")
  331.         print("Nightshade: nightshade or nigh")
  332.         print("Rosa Arcana: rosa arcana or rosa")
  333.         print("Spectrolus: spectrolus or spec")
  334.         print("Thermalily: thermalily or therm")
  335.     until askForInputText("Press enter when ready:")==""
  336.         return mainProgram()
  337. end
  338. --------------------------- generating flora END ---------------------------
  339. function funcFloraList()
  340.     clearTerm()
  341.     print("No functional flora available yet")
  342.     sleep(2)
  343.     return mainProgram()
  344. end
  345.  
  346. function whichList()
  347.     clearTerm()
  348.     print("Which list would you like to view?")
  349.     print(" ")
  350.     print("Generating Flora: generating or gen")
  351.     print(" ")
  352.     print("Functional Flora: functional or func")
  353.     local inputList = io.read()
  354.     if inputList == "generating" or inputList == "gen" then
  355.     return genFloraList()
  356.     elseif inputList == "functional" or inputList == "func" then
  357.         return funcFloraList()
  358.     end
  359. end
  360.  
  361. function mainProgram()
  362.     repeat
  363.         clearTerm()
  364.         print("Avaiable commands:")
  365.         print(" ")
  366.         print("list : View a list of available flora")
  367.         print(" ")
  368.         print("exit : exits the program.")
  369.         print(" ")
  370.     until askForInputText("Press enter to continue.")==""
  371.         while true do
  372.             clearTerm()
  373.             print("Which Botania flower would you like to make?")
  374.             print(" ")
  375.             print("If you'd like a list of what's available type: list")
  376.         local flower = read()
  377.  
  378.             if flower == "list" then
  379.                 return whichList()
  380.             elseif flower == "functional flora" then
  381.                 return funcFloraList()
  382.             elseif flower == "generating flora" then
  383.                 return getFloraList()
  384. --------------------------- generating flora Start---------------------------
  385.             elseif flower == "daybloom" or flower == "dayb" then
  386.                 return daybloom()
  387.             elseif flower == "endoflame" or flower == "endo" then
  388.                 return endoflame()
  389.             elseif flower == "entropinnyum" or flower == "entr" then
  390.                 return entropinnyum()
  391.             elseif flower == "gourmaryllis" or flower == "gour" then
  392.                 return gourmaryllis()
  393.             elseif flower == "hydroangeas" or flower == "hydro" then
  394.                 return hydroangeas()
  395.             elseif flower == "kekimurus" or flower == "keki" then
  396.                 return kekimurus()
  397.             elseif flower == "munchdew" or flower == "munc" or flower == "munch" then
  398.                 return munchdew()
  399.             elseif flower == "narslimmus" or flower == "nars" then
  400.                 return narslimmus()
  401.             elseif flower == "nightshade" or flower == "nigh" then
  402.                 return nightshade()
  403.             elseif flower == "rosa arcana" or flower == "rosa" then
  404.                 return rosaArcana()
  405.             elseif flower == "spectrolus" or flower == "spec" then
  406.                 return spectrolus()
  407.             elseif flower == "thermalily" or flower == "therm" then
  408.                 return thermalily()
  409. --------------------------- generating flora END ---------------------------
  410.             elseif flower == "exit" then
  411.                 break
  412.             else
  413.             print("I don't know what you're talking about!")
  414.             print("If you would like a list of available flowers, type: list")
  415.             sleep(3)
  416.             end
  417.         end
  418. end
  419. mainProgram()
  420. isWaterBucket()
  421. turtle.suck()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement