Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
2bithacker

Detecting crop growth levels

Question

Good afternoon!

 

I've been thinking of using robots for fully automated farming, as the server I'm on uses Pam's HarvestCraft, which adds a ton of different crops, which a lot of the existing farming machines don't deal with terribly well. So I've been doing some research, and it looks like the planting and harvesting should be pretty straight forward, but I haven't been able to find any information on how to read the growth state of a crop to know if it's time to harvest it rather than breaking an immature crop.

 

Can anyone point me in the right direction on this? Am I just missing something obvious?

 

Thanks!

Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

I know this was asked months ago, but since nobody seems to be providing any answers, I just recently have been working on a robot to farm cocoa beans so I found out a bit about how to do this the hard way... Easy answer is to utilize a geolyzer component, and run the analyze function to get the metadata of the crop, comparing it to the metadata for a full grown crop that you can find on the Minecraft wiki. Complicated answer follows:

local analyze = component.geolyzer.analyze(3) -- 3 is the front of the robot

function getFacing()    -- Get the facing of the cocoa bean
    for k,v in pairs(analyze) do
        local i = k
        if i == "metadata" then
            local n = v
            return n
        end
    end
end

function growCocoa()    -- Fertilize as needed
    if robot.count(bonemeal) > 0 then   -- If bonemeal is in slot 2
        robot.select(bonemeal)
        for k,v in pairs(analyze) do
            local i = k
            if i == "metadata" then
                local n = v
                if n < getFacing()+8 then
                    robot.place()
                    os.sleep(1)
                    robot.place()
                end
            end
        end

    else if robot.count(bonemeal) == 0 then
        for k,v in pairs(analyze) do
            local i = k
            if i == "metadata" then
                local n = v
                if n < getFacing()+8 then
                    local x,y = robot.durability()
                    if y == "tool cannot be damaged" then
                        robot.use()
                        os.sleep(1)
                        robot.use()
                    else
                        for k,v in pairs(analyze) do
                            local i = k
                            if i == "metadata" then
                                local n = v
                                while n < getFacing()+8 do
                                    print("Waiting for growth to finish...")
                                        for k,v in pairs(analyze) do
                                            local i = k
                                            if i == "metadata" then
                                                local n = v
                                                if n == getFacing()+8 then
                                                    return
                                                end
                                            else
                                                os.sleep(10)
                                            end
                                        end
                                    end
                                end
                            end
                        end
                    end
                end
            end
        end
    end
end

(Please note that these functions are an excerpt from my cocoa harvesting script, and currently do not work when the robot has no bonemeal at all. If there is interest in it, I can post the whole thing if anyone wishes to assist me in finishing it off.)

 

So in getFacing(), I am checking which side of the tree the cocoa pod is growing on to use as a reference point (base metadata if you will), then during growCocoa() I check if the current metadata is equal to the reference point+8 (no matter which side of the tree the pod is on, base metadata+8 will be fully grown). If the current metadata is high enough to signal that is is matured, I can harvest and replant, or else I apply liberal amounts of bonemeal until it does return base+8. If this doesn't make sense, let me know and I will see about making another script for automated wheat harvesting as a less complicated example.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.