Ephenia / Pokeclicker-Scripts

Various scripts & enhancements for the game Pokéclicker.
https://github.com/Ephenia/Pokeclicker-Scripts
GNU General Public License v3.0
195 stars 261 forks source link

scripts loading twice #340

Closed deilwynna closed 1 year ago

deilwynna commented 1 year ago

some scripts are some times loading twice making its features appear twice among other things, in some cases breaking the game, persists through reloading the whole app (the app client, not the browser version)

example 1: double autoclick scripts image

example 2: double quick menu buttons image

umbralOptimatum commented 1 year ago

Huh! That's a new one! Please provide:

deilwynna commented 1 year ago

game version: 0.10.13

app version: image

warnings and errors: the drop down list to change the console log to show only errors AND warnings at the same time was grayed out and non-interactive image image

script loader version: image

script folder: image

umbralOptimatum commented 1 year ago

Uhhhhh what in the fresh hell is that error log

Okay, I have no idea what's causing this, so we'll have to get creative with troubleshooting. I want to see if I can reproduce this, so I'll need a copy of your save and settings. Easiest way to get that is running JSON.stringify(localStorage) in the console and saving the extremely-long output as a text file. (Do you have any custom scripts installed?) Next run the following code in the console to clear your script settings, and see if the issue comes back after reenabling scripts.

for (let i = 0; i < localStorage.length; i++) {
    const key = localStorage.key(i);
    if (!key.startsWith('save') && ! key.startsWith('player') && ! key.startsWith('settings')) {
        localStorage.removeItem(key);
        i--;
    }
}

If this doesn't yield useful results... I can make a special app.asar with more detailed logging, I guess. Do you know exactly when this started happening? Does it happen every time the app loads?

deilwynna commented 1 year ago

i think it started happening when i went beyond kalos, to alola and galar regions when my pokemon attack had skyrocketed to just under 2 billion. it doesnt happen ever time i load the app, when it does happens, its always different scripts that gets loaded twice, depending on which ones, it can make the game unplayable (like pokemons not getting registered as fainted at 0hp) until restarting the app deilwynna pokeclicker save.txt

umbralOptimatum commented 1 year ago

I'm not able to reproduce this with your save and settings. Next step: enable Verbose messages in the console log. The desktop script manager logs which scripts it runs there and hopefully it'll have useful info when this occurs.

deilwynna commented 1 year ago

deilwynna verbose log.txt

umbralOptimatum commented 1 year ago

Sorry if I wasn't clear; I need the full log to see the scripts loading and loaded-twice errors together. Here's a modified app.asar with extra logging:

https://github.com/umbralOptimatum/Pokeclicker-Scripts/raw/desktop-extra-logging/desktop/app.asar

deilwynna commented 1 year ago

noticed it happens more often than not if i click on my save fast enough after the app loaded that it hasnt loaded the scripts yet

deilwynna verbose log2.txt

umbralOptimatum commented 1 year ago

Poking around, I've narrowed down the possibilities a bit, but it looks like that log is just the verbose messages? I need the full log with all the log levels to get as much info as possible—you can download it by right clicking the console and choosing "save as".

deilwynna commented 1 year ago

-1692167680430.log this load in in this log i only got double the autohachery buttons, that doesnt affect my gameplay in anyway image

umbralOptimatum commented 1 year ago

Aha! The two initializations are happening at separate times, before and after the game loads. Only visible with the extra debug messages alongside the normal logging. Did you set App.debug = true somehow? That lets me reproduce it on my end.

This is a fundamental flaw with the way the scripts are currently set up: they all hook into Preload.hideSplashScreen() to run after the game loads, but for some reason debug mode calls that method a second time much earlier. The variation in which scripts break is presumably from timing differences in when they download relative to the unexpected function call. Problems that didn't exist before I forced the app to wait for downloads! I'll figure out a workaround tomorrow.