Pokeclicker-Scripts icon indicating copy to clipboard operation
Pokeclicker-Scripts copied to clipboard

[Enhancement] Auto Farmer "Auto Replant" script

Open perkasthor opened this issue 3 years ago • 0 comments
trafficstars

Hi,

In order to maximize auras when farming gen 5 berries, I found that the "Simple Auto Farmer" script was not good enough: it harvests crops as soon as possible. So I added a 3rd button which toggles the "Auto Replant" script I imagined. The goal of this script is to wait until the death of the crops to harvest it. It iterates through all the plots, gets the planted seed and its timer, and check the age of the crop. If the crop is dead soon, it harvests it and replants the same. It is particularly efficient for the growth aura setup.

Here is the script I used:

function doReplant() {
    // Check each tile
    for (let i = 0; i < 25; i++) {
        // Get plot data
        var berry = App.game.farming.plotList[i].berry;
        if ( berry >= 0) {
            var age = App.game.farming.plotList[i].age;
            // Get berry data
            var growthTime = App.game.farming.berryData[berry].growthTime[App.game.farming.berryData[berry].growthTime.length - 1];
            if (growthTime - age < 100) {
                // Harvest, then replant same berry
                App.game.farming.harvest(i, false);
                App.game.farming.plant(i, berry, false);
            }
        }
    }
}

It needs to be adjusted correclty:

  • For now, the script assumes that all the plots are unlocked, maybe add some code to check that
  • I put "100" as the max age difference, maybe change this value to take into account the growth multiplier applied to the plot.

I only put the "doReplant" function, as the rest of the script is a copy/paste from other "auto" buttons. You can find the whole file attached here: Enhanced Auto Farmer.txt.

perkasthor avatar Aug 18 '22 07:08 perkasthor