Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Function to clear the screen
- function clearScreen()
- term.clear()
- term.setCursorPos(1, 1)
- end
- -- Function to display the welcome screen
- function welcomeScreen()
- clearScreen()
- print("Welcome to the Automated Wheat Farm")
- print("==================================")
- print("MFarm by Marcus")
- print("This program will help you set up")
- print("and manage an automated wheat farm")
- print("using ComputerCraft turtles.")
- print("")
- print("Press any key to continue...")
- os.pullEvent("key")
- end
- -- Function to get user input for setup
- function setupUI()
- clearScreen()
- print("Wheat Farm Setup")
- print("================")
- print("Instructions:")
- print("1. Place the turtle over a chest.")
- print("2. Ensure the chest contains the seeds of your choice in the first slot.")
- print("3. Ensure the chest contains the fuel of your choice in the second slot.")
- print("4. Ensure the chest contains the fully grown crop in the third slot.")
- print("5. Any additional fuel can be placed in slots 4-16.")
- print("")
- print("Press any key to confirm and continue...")
- os.pullEvent("key")
- end
- -- Function to pick items from the chest and identify them
- function pickAndIdentifyItems()
- clearScreen()
- print("Picking items from the chest...")
- -- Pick all items from the first slot
- turtle.select(1)
- while turtle.suckDown() do end
- local seedItem = turtle.getItemDetail(1)
- -- Pick all items from the second slot
- turtle.select(2)
- while turtle.suckDown() do end
- local fuelItem = turtle.getItemDetail(2)
- -- Pick all items from the third slot
- turtle.select(3)
- while turtle.suckDown() do end
- local fullyGrownItem = turtle.getItemDetail(3)
- if seedItem and fuelItem and fullyGrownItem then
- print("Items identified successfully!")
- print("Seed: " .. seedItem.name)
- print("Fuel: " .. fuelItem.name)
- print("Fully Grown Crop: " .. fullyGrownItem.name)
- return seedItem.name, fuelItem.name, fullyGrownItem.name
- else
- print("Failed to pick items from the chest. Please check the chest setup.")
- return nil, nil, nil
- end
- end
- -- Function to return items to the chest
- function returnItems()
- for slot = 1, 16 do
- turtle.select(slot)
- turtle.dropDown()
- end
- end
- -- Main function
- function main()
- welcomeScreen()
- setupUI()
- local seedItem, fuelItem, fullyGrownItem = pickAndIdentifyItems()
- if seedItem and fuelItem and fullyGrownItem then
- print("Are the identified items correct? (yes/no)")
- local confirmation = string.lower(read())
- if confirmation == "yes" then
- print("Setup Complete! Ready to start farming.")
- local file = fs.open("farmSetup", "w")
- file.writeLine(seedItem)
- file.writeLine(fuelItem)
- file.writeLine(fullyGrownItem)
- print("Enter the size of your farm (e.g., 9 for a 9x9 farm):")
- local farmSize = tonumber(read())
- file.writeLine(farmSize)
- print("Enter the sleep time between farming cycles (in seconds):")
- local sleepTime = tonumber(read())
- file.writeLine(sleepTime)
- file.close()
- print("Setup data saved.")
- print("Fetching MFarm program...")
- shell.run("pastebin get gBeY5EyD MFarm")
- print("Running MFarm program...")
- shell.run("MFarm")
- else
- print("Setup failed. Returning items to the chest.")
- returnItems()
- end
- else
- print("Setup failed. Please try again.")
- end
- end
- -- Start the setup process
- main()
Add Comment
Please, Sign In to add comment