xX-AAAAAAAAAA-Xx

ComputerCraft Cupcake Recipe

Aug 18th, 2024 (edited)
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.90 KB | None | 0 0
  1. -- Recipe Browser with Pagination for Pocket Computer
  2.  
  3. local recipes = {
  4.     {
  5.         name = "Cupcake",
  6.         description = "A delicious and sweet treat!",
  7.         ingredients = {
  8.             "1 cup flour",
  9.             "1/2 cup sugar",
  10.             "1/4 cup butter",
  11.             "1/2 cup milk",
  12.             "1 egg",
  13.             "1 tsp vanilla extract",
  14.             "1 tsp baking powder",
  15.             "Pinch of salt"
  16.         },
  17.         process = {
  18.             "1. Preheat oven to 350°F (175°C).",
  19.             "2. Mix flour, baking powder, and salt together.",
  20.             "3. In another bowl, beat butter and sugar until creamy.",
  21.             "4. Add the egg and vanilla, and mix well.",
  22.             "5. Gradually add the dry ingredients and milk alternately.",
  23.             "6. Pour batter into cupcake molds.",
  24.             "7. Bake for 20-25 minutes, or until golden brown.",
  25.             "8. Let cool before serving."
  26.         }
  27.     },
  28.     {
  29.         name = "Pancakes",
  30.         description = "Fluffy breakfast pancakes.",
  31.         ingredients = {
  32.             "1 cup flour",
  33.             "2 tbsp sugar",
  34.             "2 tsp baking powder",
  35.             "1/4 tsp salt",
  36.             "1 egg",
  37.             "1 cup milk",
  38.             "2 tbsp melted butter",
  39.             "1 tsp vanilla extract"
  40.         },
  41.         process = {
  42.             "1. In a bowl, mix flour, sugar, baking powder, and salt.",
  43.             "2. In another bowl, whisk the egg, milk, melted butter, and vanilla.",
  44.             "3. Pour the wet ingredients into the dry ingredients and stir until combined.",
  45.             "4. Heat a non-stick pan over medium heat and lightly grease.",
  46.             "5. Pour 1/4 cup of batter for each pancake.",
  47.             "6. Cook until bubbles form, then flip and cook until golden brown.",
  48.             "7. Serve with syrup and toppings."
  49.         }
  50.     },
  51.     {
  52.         name = "Chocolate Chip Cookies",
  53.         description = "Classic chocolate chip cookies.",
  54.         ingredients = {
  55.             "1 cup butter, softened",
  56.             "1 cup sugar",
  57.             "1 cup brown sugar",
  58.             "2 eggs",
  59.             "2 tsp vanilla extract",
  60.             "3 cups flour",
  61.             "1 tsp baking soda",
  62.             "1/2 tsp baking powder",
  63.             "1/2 tsp salt",
  64.             "2 cups chocolate chips"
  65.         },
  66.         process = {
  67.             "1. Preheat oven to 350°F (175°C).",
  68.             "2. Cream together butter and sugars until smooth.",
  69.             "3. Beat in the eggs and vanilla.",
  70.             "4. Stir in the flour, baking soda, baking powder, and salt.",
  71.             "5. Fold in the chocolate chips.",
  72.             "6. Drop spoonfuls of dough onto baking sheets.",
  73.             "7. Bake for 10-12 minutes, or until edges are golden.",
  74.             "8. Cool on wire racks."
  75.         }
  76.     },
  77.     {
  78.         name = "Spaghetti Bolognese",
  79.         description = "Hearty and savory pasta dish.",
  80.         ingredients = {
  81.             "1 lb ground beef",
  82.             "1 onion, chopped",
  83.             "2 cloves garlic, minced",
  84.             "1 can crushed tomatoes",
  85.             "1/4 cup tomato paste",
  86.             "1 tsp dried oregano",
  87.             "1 tsp dried basil",
  88.             "Salt and pepper to taste",
  89.             "1 lb spaghetti",
  90.             "Parmesan cheese for serving"
  91.         },
  92.         process = {
  93.             "1. Cook the spaghetti according to package instructions.",
  94.             "2. In a large skillet, cook ground beef until browned.",
  95.             "3. Add chopped onion and minced garlic, cook until softened.",
  96.             "4. Stir in crushed tomatoes, tomato paste, oregano, basil, salt, and pepper.",
  97.             "5. Simmer the sauce for 20 minutes.",
  98.             "6. Serve the sauce over the cooked spaghetti.",
  99.             "7. Top with Parmesan cheese."
  100.         }
  101.     },
  102.     {
  103.         name = "Grilled Cheese Sandwich",
  104.         description = "A simple and classic sandwich.",
  105.         ingredients = {
  106.             "2 slices of bread",
  107.             "2 slices of cheese",
  108.             "2 tbsp butter"
  109.         },
  110.         process = {
  111.             "1. Heat a skillet over medium heat.",
  112.             "2. Butter one side of each slice of bread.",
  113.             "3. Place one slice of bread, buttered side down, on the skillet.",
  114.             "4. Add cheese slices on top of the bread.",
  115.             "5. Top with the second slice of bread, buttered side up.",
  116.             "6. Cook until golden brown on one side, then flip and cook the other side.",
  117.             "7. Serve hot."
  118.         }
  119.     },
  120.     {
  121.         name = "Banana Bread",
  122.         description = "Moist and flavorful banana bread.",
  123.         ingredients = {
  124.             "3 ripe bananas, mashed",
  125.             "1/3 cup melted butter",
  126.             "1 cup sugar",
  127.             "1 egg, beaten",
  128.             "1 tsp vanilla extract",
  129.             "1 tsp baking soda",
  130.             "Pinch of salt",
  131.             "1 1/2 cups flour"
  132.         },
  133.         process = {
  134.             "1. Preheat oven to 350°F (175°C).",
  135.             "2. In a bowl, mix mashed bananas with melted butter.",
  136.             "3. Stir in sugar, beaten egg, and vanilla.",
  137.             "4. Add baking soda and salt, and mix well.",
  138.             "5. Gradually add the flour and stir until combined.",
  139.             "6. Pour the batter into a greased loaf pan.",
  140.             "7. Bake for 60-65 minutes, or until a toothpick comes out clean.",
  141.             "8. Let cool before slicing."
  142.         }
  143.     },
  144.     {
  145.         name = "Caesar Salad",
  146.         description = "Crisp and refreshing salad.",
  147.         ingredients = {
  148.             "1 head romaine lettuce, chopped",
  149.             "1/4 cup grated Parmesan cheese",
  150.             "1/2 cup croutons",
  151.             "Caesar dressing",
  152.             "Salt and pepper to taste"
  153.         },
  154.         process = {
  155.             "1. In a large bowl, combine chopped lettuce, Parmesan cheese, and croutons.",
  156.             "2. Drizzle with Caesar dressing and toss to coat.",
  157.             "3. Season with salt and pepper if desired.",
  158.             "4. Serve immediately."
  159.         }
  160.     },
  161.     {
  162.         name = "Scrambled Eggs",
  163.         description = "Fluffy and quick scrambled eggs.",
  164.         ingredients = {
  165.             "4 eggs",
  166.             "1/4 cup milk",
  167.             "Salt and pepper to taste",
  168.             "1 tbsp butter"
  169.         },
  170.         process = {
  171.             "1. In a bowl, whisk together eggs, milk, salt, and pepper.",
  172.             "2. Heat butter in a non-stick pan over medium heat.",
  173.             "3. Pour the egg mixture into the pan.",
  174.             "4. Cook, stirring gently, until the eggs are set.",
  175.             "5. Serve hot."
  176.         }
  177.     },
  178.     {
  179.         name = "French Toast",
  180.         description = "A sweet and satisfying breakfast.",
  181.         ingredients = {
  182.             "2 eggs",
  183.             "1/2 cup milk",
  184.             "1 tsp vanilla extract",
  185.             "1/2 tsp cinnamon",
  186.             "4 slices of bread",
  187.             "Butter for frying",
  188.             "Maple syrup for serving"
  189.         },
  190.         process = {
  191.             "1. In a shallow bowl, whisk together eggs, milk, vanilla, and cinnamon.",
  192.             "2. Dip each slice of bread in the egg mixture, coating both sides.",
  193.             "3. Heat butter in a skillet over medium heat.",
  194.             "4. Cook the bread slices until golden brown on both sides.",
  195.             "5. Serve with maple syrup."
  196.         }
  197.     }
  198. }
  199.  
  200.  
  201. local function displayPage(items, page, itemsPerPage)
  202.     local start = (page - 1) * itemsPerPage + 1
  203.     local stop = math.min(start + itemsPerPage - 1, #items)
  204.  
  205.     for i = start, stop do
  206.         print(items[i])
  207.     end
  208.  
  209.     print("\nPage " .. page .. " of " .. math.ceil(#items / itemsPerPage))
  210. end
  211.  
  212. local function paginate(items)
  213.     local page = 1
  214.     local itemsPerPage = 4
  215.  
  216.     while true do
  217.         term.clear()
  218.         term.setCursorPos(1, 1)
  219.         displayPage(items, page, itemsPerPage)
  220.  
  221.         print("\nPress [n] for next, [p] for previous, or [q] to quit.")
  222.         local event, key = os.pullEvent("char")
  223.  
  224.         if key == "n" and page < math.ceil(#items / itemsPerPage) then
  225.             page = page + 1
  226.         elseif key == "p" and page > 1 then
  227.             page = page - 1
  228.         elseif key == "q" then
  229.             break
  230.         end
  231.     end
  232. end
  233.  
  234. local function displayRecipe(recipe)
  235.     print("Recipe: " .. recipe.name)
  236.     print("\nDescription:\n" .. recipe.description)
  237.     print("\nIngredients:")
  238.     paginate(recipe.ingredients)
  239.     print("\nProcess:")
  240.     paginate(recipe.process)
  241. end
  242.  
  243. local function browseRecipes()
  244.     for i, recipe in ipairs(recipes) do
  245.         print(i .. ". " .. recipe.name)
  246.     end
  247.     print("\nEnter the recipe number to view details:")
  248.     local choice = tonumber(read())
  249.     if choice and recipes[choice] then
  250.         term.clear()
  251.         term.setCursorPos(1, 1)
  252.         displayRecipe(recipes[choice])
  253.     else
  254.         print("Invalid choice.")
  255.     end
  256. end
  257.  
  258. browseRecipes()
  259.  
Add Comment
Please, Sign In to add comment