marcrobledo / acnl-editor

An Animal Crossing: New Leaf savegame editor made in HTML5
https://www.marcrobledo.com/acnl-editor/
MIT License
152 stars 33 forks source link

Script for filling your storage rooms with all the museum objects #92

Open AntennaeVY opened 1 year ago

AntennaeVY commented 1 year ago

Since the ACNL-SE lacks of the functionality to complete all the museum I created a JS script that fills your storage room with all the museum objects (331) so you can take them to the Owl in the museum and get your museum 100% completed.

You need to load your save and then go to the "Players" tab, hit CTRL + SHIFT + I and paste the following script in your browser's console.

PLEASE NOTE THAT THIS WILL OVERWRITE YOUR STORAGE ROOMS

async function run(e) {
    /*
        Bugs: 8846 - 8927
        Fish: 8929 - 9004
        Marine Creatures: 9005 - 9035
        Art: 12498 - 12552
        Fossils: 12592 - 12678
    */

    let bugStart = 8846, bugEnd = 8927;
    let fishStart = 8929, fishEnd = 9004;
    let marineStart = 9005, marineEnd = 9035;
    let artStart = 12498, artEnd = 12552;
    let fossStart = 12592, fossEnd = 12678;

    const itemSelector = document.getElementById("items");

    for (let id=0; id < 4; id++) {
        const element = document.getElementById("storage" + id).children[0];

        for(let i=0; i <= 4; i++) {
            for(let j=0; j <= 17; j++) {
                if (bugStart <= bugEnd) {
                    itemSelector.value = bugStart++;
                } else if (fishStart <= fishEnd) {
                    itemSelector.value = fishStart++;
                } else if (marineStart <= marineEnd) {
                    itemSelector.value = marineStart++;
                } else if (artStart <= artEnd) {
                    itemSelector.value = artStart++;
                } else if (fossStart <= fossEnd) {
                    itemSelector.value = fossStart++;
                } else {
                    break;
                }

                let clientX = parseInt(Math.ceil(element.getBoundingClientRect().x)) + 3;
                let clientY = parseInt(Math.ceil(element.getBoundingClientRect().y)) + 3;

                const event = new MouseEvent("mousedown", {
                    view: window,
                    bubbles: true,
                    cancelable: true,
                    clientX: clientX + i*16,
                    clientY: clientY + j*16,
                });

                element.dispatchEvent(event);
                element.dispatchEvent(new MouseEvent("mouseup"));
                await new Promise(r => setTimeout(r, 50));
            }
        } 
    }
}

run()