Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Disclaimer: Use at your own risk!
- Done for: Chrome (probably runs on others as well, no clue how those work, though)
- Done by: Dejv (Discord: Dejv#3141, feel free to ask, or pin-point some mistakes, cause I don't do javascript)
- Done why: For personal use, so thus lack of polish.
- How to run tl;dr: Once these functions are on MelvorIdle page (which you can do by just copy/pasting this into browsers console) just do setInterval(loopPlantByPriority, 60000); -> this checks for replanting every minute, if you want to stop it do clearInterval(number_that_setinterval_returned), if you want to run just once do loopPlantByPriority();
- IMPORTANT NOTE: Harvest function doesn't check if there are free bank slots to store the harvest!
- Note: This script is quite talkative in the console, if it's too annoying just comment out (//) the "console.log"s
- The other note: You can use the harvest function separatly by custHarvestAll();, or if you feel like that one's cheating, use the default instead, should work just alright.
- */
- // ** FARMING SCRIPTS **
- //Goes through all farming areas and plants the highest tier of seed unlocked and avaible in bank
- function loopPlantByPriority() {
- //These are the default lists of plant priorities taken from farmable stuff global lists -> see getFloraIDs
- //I've taken advantage of those being sorted from lowest skill to highest and just reverted those, then planting highest->lowest tier
- //Customization: If you want to have different priority, just make your own list! -> proly use custom function with plantHighestTier
- var floraSeeds = getFloraIDs();
- //First just harvesting what's grown
- custHarvestAll();
- //Going through all farming areas while planting seeds by priority
- for(var i = 0; i < floraSeeds.length; i++) {
- plantByPriority(i, floraSeeds[i]);
- }
- }
- //Id of area to plant seeds into and list of seeds sorted by their priority to plant (highest->lowest)
- function plantByPriority(area, seedList) {
- var seedPerPlant = 3 - area; //(allo)0 -> 3, (herb)1 -> 2, (tree)2 -> 1
- var floraWords = ["allotments", "herbs", "trees"];
- var farmingLevel = skillLevel[11];
- var areaLen = newFarmingAreas[area].patches.length;
- var seedLen = seedList.length;
- var currentSeed = 0;
- for(var i = 0; i < areaLen; i++) {
- //Only want to plant in unlocked farming slots and where's not anything growing atm
- if(newFarmingAreas[area].patches[i].unlocked && !newFarmingAreas[area].patches[i].seedID) {
- //Have high enough farming, have seed in bank, have enough seeds for planting
- if(seedList[currentSeed].level <= farmingLevel && checkBankForItem(seedList[currentSeed].itemID) && bank[getBankId(seedList[currentSeed].itemID)].qty >= seedPerPlant) {
- console.log("Currently planting " + items[seedList[currentSeed].itemID].name + ", into patch: " + i);
- selectSeed(seedList[currentSeed].itemID, false);
- selectedPatch[0] = area;
- selectedPatch[1] = i;
- plantSeed();
- } else {
- console.log("Cannot plant " + items[seedList[currentSeed].itemID].name + ", skipping.");
- i--; //Wanna repeat for the lower tier on the same slot
- currentSeed++; //Couldn't plant this tier, moving to lower tier seed
- if(currentSeed >= seedLen) { //If I reached the end of list while failing to plant, just exit the loop and post message
- console.log("Cannot finish planting " + floraWords[area] + " area, not enough seeds. Ended at slot: " + i);
- break;
- }
- }
- }
- }
- console.log("Planting " + floraWords[area] + " finished.");
- }
- //Makes a copy of all seed types and sorts them from highest skill to lowest required
- function getFloraIDs() {
- var floraSeedInfo = [];
- //Making a copy of each list of seeds so I don't mess up some stuffs
- floraSeedInfo[0] = [...allotmentSeeds];
- floraSeedInfo[1] = [...herbSeeds];
- floraSeedInfo[2] = [...treeSeeds];
- //They are sorted from lowest skill to highest, I want the highest value, eg. highest skill first
- //If in the future those'd stored different way there should be a sorting function
- floraSeedInfo[0].reverse();
- floraSeedInfo[1].reverse();
- floraSeedInfo[2].reverse();
- return floraSeedInfo;
- }
- //Goes through all areas and harvests what's grown
- function custHarvestAll() {
- for (var i = 0; i < newFarmingAreas.length; i++) {
- for (var j = 0; j < newFarmingAreas[i].patches.length; j++) {
- if(newFarmingAreas[i].patches[j].hasGrown) {
- harvestSeed(i, j);
- }
- }
- }
- console.log("Harvesting finished.");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement