zebscripts/AFK-Daily

When encountering an error, try to continue from that point

Closed this issue · 6 comments

Whenever something doesn't go as expected (for example a expected RGB X but got Y error), I'd like the script to ask the user to finish the task (or something like that), and wait for user input to continue with the rest of the script.

The best would be to have the script try to fix itself! I will most likely try that.

Mmh, I think it's possible by doing some cheesy things.

  • Move the switchTab inside the functions, and check if we already are on the good tab.
  • Before each action (last call), set the equivalent config to false: doLootAfkChest=false
  • Add 2 functions:
    • init prepares the script (close/start/loop the tabs/wait for the update)
    • run the actual script (all the check on config, ...)
  • When verifyRGB encounter an error, restart the app: init; run;

I was thinking of adding that functionality during the refacto.

Ooh, so if o understood the code you linked correctly, you basically want to code the script in a synchronous way, that if it breaks during that it's simple to find it. Interesting... That could actually be a good idea, even if it's a cheesy one.

Each time you do a verifyRGB, if you fail, restart and keep going.

And what about the following idea:

Everytime the script encounters an error, it saves the place it had the error. So for example, the script did not manage to fight in the king's tower, it exits and temporarily saves to a file where it got the the error. Then, if a config.sh variable like tryAgainIfError is set to true, the script would attempt to create a new config.sh file that has everything set to false before the place where the error occurred. And it would try to run it again normally. We could give this config.sh file a specific name, so the script knows which one to use.

This way we don't have to move code around in the main script and potentially break something.

This is definitely again something we should work on after most of (if not all actually) PRs are merged.

I did put in during my refacto and it's working properly 😄 (was bored to edit the config, restart, ...)
It skips the broken parts when it's detected so it's just a trick 🩹

Only detecting the fails is not enough, you need to keep the counters in memory... It will be a better solution, but a headache to implement 😢

Oh OK! I didn't know you had it implemented already, cool! Dirty trick, but if it works reliably then why not.

And yes, you're right that it probably would be annoying to develop... Though I wasn't expecting anything easy for this issue either! 😁

Anyways, it seems you're working on it already and that this issue might get fixed when your refactoring gets merged. Thank you!