assasin172

autocraft

Jun 23rd, 2013
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.96 KB | None | 0 0
  1. --Each recipe is indexed by name (stick, chest etc.)
  2. --Each recipe has the following values:
  3.     --count: The number of materials required to make it
  4.     --map: an indexed table of booleans, the index referring to the
  5.     --slot in the turtle's inventory (1 -> 11, sans 4 and 8)
  6. recipes = {
  7.     --The example recipe: Sticks!
  8.     ["wiring"] = {
  9.         count = 3,
  10.         map = {
  11.             [1] = false, [2] = false, [3] = false,
  12.             [5] = true, [6] = true, [7] = true,
  13.             [9] = false, [10]= false, [11]= false
  14.         }
  15.     }
  16. }
  17.  
  18. function craftRecipe(recipemap)
  19.  
  20. end
  21.  
  22. function readName()
  23.     while true do
  24.         shell.run("clear")
  25.         print("What do you want me to craft?")
  26.         local name = io.read()
  27.        
  28.         if not recipes[name] then
  29.             print("I don't know that recipe.")
  30.             sleep(2)
  31.         else
  32.             print("Please insert "..recipes[name].count.." materials to slot 1")
  33.             while turtle.getItemCount(1) ~= recipes[name].count do sleep(0.1) end
  34.            
  35.             craftRecipe(recipes[name].map)
  36.         end
  37.     end
  38. end
  39. readName()
Advertisement
Add Comment
Please, Sign In to add comment