Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Recipe Browser with Pagination for Pocket Computer
- local recipes = {
- {
- name = "Cupcake",
- description = "A delicious and sweet treat!",
- ingredients = {
- "1 cup flour",
- "1/2 cup sugar",
- "1/4 cup butter",
- "1/2 cup milk",
- "1 egg",
- "1 tsp vanilla extract",
- "1 tsp baking powder",
- "Pinch of salt"
- },
- process = {
- "1. Preheat oven to 350°F (175°C).",
- "2. Mix flour, baking powder, and salt together.",
- "3. In another bowl, beat butter and sugar until creamy.",
- "4. Add the egg and vanilla, and mix well.",
- "5. Gradually add the dry ingredients and milk alternately.",
- "6. Pour batter into cupcake molds.",
- "7. Bake for 20-25 minutes, or until golden brown.",
- "8. Let cool before serving."
- }
- },
- {
- name = "Pancakes",
- description = "Fluffy breakfast pancakes.",
- ingredients = {
- "1 cup flour",
- "2 tbsp sugar",
- "2 tsp baking powder",
- "1/4 tsp salt",
- "1 egg",
- "1 cup milk",
- "2 tbsp melted butter",
- "1 tsp vanilla extract"
- },
- process = {
- "1. In a bowl, mix flour, sugar, baking powder, and salt.",
- "2. In another bowl, whisk the egg, milk, melted butter, and vanilla.",
- "3. Pour the wet ingredients into the dry ingredients and stir until combined.",
- "4. Heat a non-stick pan over medium heat and lightly grease.",
- "5. Pour 1/4 cup of batter for each pancake.",
- "6. Cook until bubbles form, then flip and cook until golden brown.",
- "7. Serve with syrup and toppings."
- }
- },
- {
- name = "Chocolate Chip Cookies",
- description = "Classic chocolate chip cookies.",
- ingredients = {
- "1 cup butter, softened",
- "1 cup sugar",
- "1 cup brown sugar",
- "2 eggs",
- "2 tsp vanilla extract",
- "3 cups flour",
- "1 tsp baking soda",
- "1/2 tsp baking powder",
- "1/2 tsp salt",
- "2 cups chocolate chips"
- },
- process = {
- "1. Preheat oven to 350°F (175°C).",
- "2. Cream together butter and sugars until smooth.",
- "3. Beat in the eggs and vanilla.",
- "4. Stir in the flour, baking soda, baking powder, and salt.",
- "5. Fold in the chocolate chips.",
- "6. Drop spoonfuls of dough onto baking sheets.",
- "7. Bake for 10-12 minutes, or until edges are golden.",
- "8. Cool on wire racks."
- }
- },
- {
- name = "Spaghetti Bolognese",
- description = "Hearty and savory pasta dish.",
- ingredients = {
- "1 lb ground beef",
- "1 onion, chopped",
- "2 cloves garlic, minced",
- "1 can crushed tomatoes",
- "1/4 cup tomato paste",
- "1 tsp dried oregano",
- "1 tsp dried basil",
- "Salt and pepper to taste",
- "1 lb spaghetti",
- "Parmesan cheese for serving"
- },
- process = {
- "1. Cook the spaghetti according to package instructions.",
- "2. In a large skillet, cook ground beef until browned.",
- "3. Add chopped onion and minced garlic, cook until softened.",
- "4. Stir in crushed tomatoes, tomato paste, oregano, basil, salt, and pepper.",
- "5. Simmer the sauce for 20 minutes.",
- "6. Serve the sauce over the cooked spaghetti.",
- "7. Top with Parmesan cheese."
- }
- },
- {
- name = "Grilled Cheese Sandwich",
- description = "A simple and classic sandwich.",
- ingredients = {
- "2 slices of bread",
- "2 slices of cheese",
- "2 tbsp butter"
- },
- process = {
- "1. Heat a skillet over medium heat.",
- "2. Butter one side of each slice of bread.",
- "3. Place one slice of bread, buttered side down, on the skillet.",
- "4. Add cheese slices on top of the bread.",
- "5. Top with the second slice of bread, buttered side up.",
- "6. Cook until golden brown on one side, then flip and cook the other side.",
- "7. Serve hot."
- }
- },
- {
- name = "Banana Bread",
- description = "Moist and flavorful banana bread.",
- ingredients = {
- "3 ripe bananas, mashed",
- "1/3 cup melted butter",
- "1 cup sugar",
- "1 egg, beaten",
- "1 tsp vanilla extract",
- "1 tsp baking soda",
- "Pinch of salt",
- "1 1/2 cups flour"
- },
- process = {
- "1. Preheat oven to 350°F (175°C).",
- "2. In a bowl, mix mashed bananas with melted butter.",
- "3. Stir in sugar, beaten egg, and vanilla.",
- "4. Add baking soda and salt, and mix well.",
- "5. Gradually add the flour and stir until combined.",
- "6. Pour the batter into a greased loaf pan.",
- "7. Bake for 60-65 minutes, or until a toothpick comes out clean.",
- "8. Let cool before slicing."
- }
- },
- {
- name = "Caesar Salad",
- description = "Crisp and refreshing salad.",
- ingredients = {
- "1 head romaine lettuce, chopped",
- "1/4 cup grated Parmesan cheese",
- "1/2 cup croutons",
- "Caesar dressing",
- "Salt and pepper to taste"
- },
- process = {
- "1. In a large bowl, combine chopped lettuce, Parmesan cheese, and croutons.",
- "2. Drizzle with Caesar dressing and toss to coat.",
- "3. Season with salt and pepper if desired.",
- "4. Serve immediately."
- }
- },
- {
- name = "Scrambled Eggs",
- description = "Fluffy and quick scrambled eggs.",
- ingredients = {
- "4 eggs",
- "1/4 cup milk",
- "Salt and pepper to taste",
- "1 tbsp butter"
- },
- process = {
- "1. In a bowl, whisk together eggs, milk, salt, and pepper.",
- "2. Heat butter in a non-stick pan over medium heat.",
- "3. Pour the egg mixture into the pan.",
- "4. Cook, stirring gently, until the eggs are set.",
- "5. Serve hot."
- }
- },
- {
- name = "French Toast",
- description = "A sweet and satisfying breakfast.",
- ingredients = {
- "2 eggs",
- "1/2 cup milk",
- "1 tsp vanilla extract",
- "1/2 tsp cinnamon",
- "4 slices of bread",
- "Butter for frying",
- "Maple syrup for serving"
- },
- process = {
- "1. In a shallow bowl, whisk together eggs, milk, vanilla, and cinnamon.",
- "2. Dip each slice of bread in the egg mixture, coating both sides.",
- "3. Heat butter in a skillet over medium heat.",
- "4. Cook the bread slices until golden brown on both sides.",
- "5. Serve with maple syrup."
- }
- }
- }
- local function displayPage(items, page, itemsPerPage)
- local start = (page - 1) * itemsPerPage + 1
- local stop = math.min(start + itemsPerPage - 1, #items)
- for i = start, stop do
- print(items[i])
- end
- print("\nPage " .. page .. " of " .. math.ceil(#items / itemsPerPage))
- end
- local function paginate(items)
- local page = 1
- local itemsPerPage = 4
- while true do
- term.clear()
- term.setCursorPos(1, 1)
- displayPage(items, page, itemsPerPage)
- print("\nPress [n] for next, [p] for previous, or [q] to quit.")
- local event, key = os.pullEvent("char")
- if key == "n" and page < math.ceil(#items / itemsPerPage) then
- page = page + 1
- elseif key == "p" and page > 1 then
- page = page - 1
- elseif key == "q" then
- break
- end
- end
- end
- local function displayRecipe(recipe)
- print("Recipe: " .. recipe.name)
- print("\nDescription:\n" .. recipe.description)
- print("\nIngredients:")
- paginate(recipe.ingredients)
- print("\nProcess:")
- paginate(recipe.process)
- end
- local function browseRecipes()
- for i, recipe in ipairs(recipes) do
- print(i .. ". " .. recipe.name)
- end
- print("\nEnter the recipe number to view details:")
- local choice = tonumber(read())
- if choice and recipes[choice] then
- term.clear()
- term.setCursorPos(1, 1)
- displayRecipe(recipes[choice])
- else
- print("Invalid choice.")
- end
- end
- browseRecipes()
Add Comment
Please, Sign In to add comment