Greasy Fork is available in English.

Neverwinter gateway - Profession Automation

Automatically selects professions for empty slots

< Feedback on Neverwinter gateway - Profession Automation

Review: Good - script works

t4k
§
Posted: 20-03-2015

Lvl 20 script stuck

Script can not start Destroy enemy camp task, f5 fixes this. RU gateway. Version 1.10 and 2.0
Here is console log

VM2426:2213 Searching for task: Leadership_Tier3_20r_Master3
VM2426:2435 Found required ingredient: Crafting_Resource_Mark_Of_Gratitude
VM2426:2444 Failed to resolve item requirements for task: Leadership_Tier3_20r_Master3
VM2426:2291 Finding next task
VM2426:2202 Selecting profile: Training
VM2426:2209 Leadership is level 20
VM2426:2210 createNextTask 11 3
VM2426:2213 Searching for task: Leadership_Tier3_20_Destroy
Uncaught TypeError: Cannot read property 'length' of undefined

Rotten_mindAuthor
§
Posted: 20-03-2015

Got same error,

 VM169793:1982 Uncaught TypeError: Cannot read property 'length' of undefined

, it points here,

    // start task if requirements are met
    if (!thisTask.failedrequirementsreasons.length) {
        return thisTask;
    }
t4k
§
Posted: 21-03-2015

Can try...catch quick back script to work? For temporary solution.

§
Posted: 21-03-2015
Edited: 21-03-2015

OK been sent here to have a look,

// If no task is returned we either have three of this task already, the task is a rare that doesn't exist currently, or we have the name wrong in tasklist
if (!thisTask) {
console.log('Could not find task for:', taskname);
return false;
}


Should probably be :

// If no task is returned we either have three of this task already, the task is a rare that doesn't exist currently, or we have the name wrong in tasklist
if (typeof thisTask == 'undefined') {
console.log('Could not find task for:', taskname);
return false;
}


Maybe the undefined check isn't working properly?

§
Posted: 21-03-2015
Edited: 21-03-2015

I have 2 questions:

1. Is this end of log, or is this part repeated?

VM2426:2291 Finding next task
VM2426:2202 Selecting profile: Training
VM2426:2209 Leadership is level 20
VM2426:2210 createNextTask 11 3
VM2426:2213 Searching for task: Leadership_Tier3_20_Destroy
Uncaught TypeError: Cannot read property 'length' of undefined

2. Is reload solves the problem?

In the last two weeks scripts stuck once for me but I notice this after couple of hours, and log was off, so I didn't resolve problem :D. I have idea how to detect this, but answers to above questions are welcome and required.

§
Posted: 21-03-2015
Edited: 21-03-2015

length undefined is happening because the script block I posted above [ if(!thisTask) ] isn't testing correctly for "undefined" and not returning false. As a result, the code moves on to the failedrequirementsreasons.length line which errors because you cannot get the length of an undefined variable.

§
Posted: 21-03-2015

I'm not sure what this block is testing. But You are probably not sure too...
So it's safer to write:

if (!thisTask || typeof thisTask == 'undefined') {
§
Posted: 21-03-2015

!thisTask is a way to test for undefined - but - depending on the way that the variable becomes undefined, the method "!thisTask" does not ALWAYS return true. typeof thisTask == 'undefined' will ALWAYS return true when the variable is undefined - which is the expected behaviour of the IF condition.

t4k
§
Posted: 21-03-2015

WloBeb, this is the end of log. And this error even stoped another script that runing in portable browser. Script runing and waiting, You can do actions in gateway. Not shure but then 2 hours reload fixes this bug. Refresh also fixes this.

Rotten_mindAuthor
§
Posted: 21-03-2015
Edited: 21-03-2015

Good observations for this error, what was found here too,


http://userscripts-mirror.org/topics/214472.html (we can call it prehistoric bug now!!!)


, not sure where to start.

Like @t4k stated,

  • script "autoreload" fix issue
  • F5 fix issue
  • it happens (most cases) with Destroy enemy camp (is possible to start)

  • my observation, it happens 1 - 6 times per week with 10x running script or less

IF this error occur we cant skip task what is currently most profitable.

If we restart tampermonkey, will we get risk for "infinite loop" ?

If we encounter this "error" can we reload only failing parts without "reload page"?

So should we deal with it like @WloBeb "failed to start" -counter and "Reload Page" if this error exist?

t4k
§
Posted: 21-03-2015

In my case it happens every time on each 20 lvl character :(

§
Posted: 21-03-2015

Should there be a To Do: added for this? Now that I don't play anymore I'd be happy to delve into things when I'm bored. For some reason I enjoy XML, though I'm a little rusty. Haven't had to write anything since I played FFXI for 7 years.

Rotten_mindAuthor
§
Posted: 21-03-2015
Should there be a To Do: added for this? Now that I don't play anymore I'd be happy to delve into things when I'm bored. For some reason I enjoy XML, though I'm a little rusty. Haven't had to write anything since I played FFXI for 7 years.

good to hear @Anele that you are still around...

xD, this game itself is allmost dead for me, but I try keep this script running.

Abetter automation is allways welcome...

§
Posted: 22-03-2015

Not an expert at Javascript but could failedrequirementsreasons be undefined for some reason? Seems like you'd just need to add a check to test that...

t4k
§
Posted: 22-03-2015

Looks like script can start destroy enemy camp in first prof. slot but cant in another.

Rotten_mindAuthor
§
Posted: 22-03-2015

Maybe we just do "Idle checker" work again?

        /* Can't use idle check with dataModel methods
         else if (location.href == last_location) {
         state_loading = 0;
         if (state_idle >= state_idle_time) {
         console.log("Page Idle too long");
         state_idle = 0;
         unsafeWindow.location.href = current_Gateway ; // edited by RottenMind
         }
         else {
         state_idle++;
         // comment out to avoid console spam
         //console.log("Page Idle ...", state_idle + "s");
         }
         }
         */
t4k
§
Posted: 22-03-2015

@Rotten_mind is there way to refresh only current character and dont start again whole cycle?

§
Posted: 23-03-2015
Edited: 23-03-2015

deleted

Rotten_mindAuthor
§
Posted: 23-03-2015
Edited: 23-03-2015

So here it is, not sure what cause it, but it looks interessting,

editeed script for console,

   console.log("failed req", thisTask); // here we get array before failure
    // start task if requirements are met
    if (!thisTask.failedrequirementsreasons.length) { // if undefined, script stuck
        console.log("failed req", thisTask); // array conten again but not show if stuck
        return thisTask;
    }

This fails,

Searching for task: Leadership_Tier4_25_Battleelementalcultists
VM142:1978 failed req Object {def: Object, weight: 1, required: Array[3], rewards: Array[5], isheader: 0…}def: Objectfailslevelrequirements: 0failslevelrequirementsfilter: 0failsresourcesrequirements: 0isheader: 0required: Array[3]rewards: Array[5]weight: 1__proto__: Object
VM142:1980 Uncaught TypeError: Cannot read property 'length' of undefined

Here exactly same part but Success,

Searching for task: Leadership_Tier4_24r_Killdragon
VM3855:1978 failed req Object {def: Object, failedrequirementsreasons: "You need 1 Scroll of Mass Protection from Dragons.", header: "", weight: 3, required: Array[3]…}consumables: Array[1]def: Objectfailedrequirementsreasons: "You need 1 Scroll of Mass Protection from Dragons."failslevelrequirements: 0failslevelrequirementsfilter: 0failsresourcesrequirements: 1header: ""isheader: 0nextupdatetime: "Sat, 01 Jan 2000 00:00:00 GMT"required: Array[3]rewards: Array[4]weight: 3__proto__: Object
VM3855:2078 Found required ingredient: Crafting_Resource_Scroll_Protection_Dragons

...so what you see?

BTW, I got multiple times "start task infinite loop" or should I say 20x loop and some other glitches too so Gateway itself feels really buggy now, :(.

§
Posted: 24-03-2015

The difference between the above is that the success one contains "failedrequirementreasons" as a parameter and therefore length can be checked. The failure one does not contain that wording and therefore becomes "undefined" - hence the error.

Rotten_mindAuthor
§
Posted: 24-03-2015
Edited: 24-03-2015
The difference between the above is that the success one contains "failedrequirementreasons" as a parameter and therefore length can be checked. The failure one does not contain that wording and therefore becomes "undefined" - hence the error.

Something like that...

This needs test, catching error, just replace this,

        if (!thisTask.failedrequirementsreasons.length) {
           return thisTask;
        }

with this, script reloads allways if error,

//console.log("failed req", thisTask);
    // start task if requirements are met, we try it because it might cause errors
    try {
        if (!thisTask.failedrequirementsreasons.length) {
            //console.log("failed req, success", thisTask);
            return thisTask;
        }
    } catch(e) { // try catch array load error
        console.log("Great FAILURE, so we restart");
        unsafeWindow.location.href = current_Gateway; // array loaderror will restart
        //return;
    }

, it is not good solution if you have 30 character, but better than wait 3 hours to reload...

§
Posted: 24-03-2015

Would the better solution simply to be to check whether failedrequirementsreasons is in thisTask or better still - make sure that failedrequirementsreasons is ALWAYS included when the variable is built and then test for empty string vs valid failed reason instead of length

§
Posted: 24-03-2015

OK.... impossible to make sure that is is ALWAYS returned since thisTask comes from the object model unsafeWindow.client.dataModel.model.craftinglist - therefore a test to see if failedrequirementsreasons is contained in thisTask first is the correct solution

§
Posted: 24-03-2015

No need to reload the gateway - if the object model doesn't contain the required information - just fail the function with "false" in the same way it would do if the level was too high etc....


//console.log("failed req", thisTask);
    // start task if requirements are met, we try it because it might cause errors
    try {
        if (!thisTask.failedrequirementsreasons.length) {
            //console.log("failed req, success", thisTask);
            return thisTask;
        }
    } catch(e) { // try catch array load error
        console.log("Could not locate requirements.  Aborting");
	return false;        
        //return;
    }
Rotten_mindAuthor
§
Posted: 24-03-2015
Edited: 24-03-2015
No need to reload the gateway - if the object model doesn't contain the required information - just fail the function with "false" in the same way it would do if the level was too high etc....

//console.log("failed req", thisTask);
    // start task if requirements are met, we try it because it might cause errors
    try {
        if (!thisTask.failedrequirementsreasons.length) {
            //console.log("failed req, success", thisTask);
            return thisTask;
        }
    } catch(e) { // try catch array load error
        console.log("Could not locate requirements.  Aborting");
    return false;        
        //return;
    }

That will cause task skip (I think), what means most profitable Leadership tasks are skipped, because most cases highest level task are those what fails.

And that way it is better reload if there is no better solution.

§
Posted: 25-03-2015

This fails,

Searching for task: Leadership_Tier4_25_Battleelementalcultists
VM142:1978 failed req Object {def: Object, weight: 1, required: Array[3], rewards: Array[5], isheader: 0…}def: Objectfailslevelrequirements: 0failslevelrequirementsfilter: 0failsresourcesrequirements: 0isheader: 0required: Array[3]rewards: Array[5]weight: 1__proto__: Object
VM142:1980 Uncaught TypeError: Cannot read property 'length' of undefined

Here exactly same part but Success,

Searching for task: Leadership_Tier4_24r_Killdragon
VM3855:1978 failed req Object {def: Object, failedrequirementsreasons: "You need 1 Scroll of Mass Protection from Dragons.", header: "", weight: 3, required: Array[3]…}consumables: Array[1]def: Objectfailedrequirementsreasons: "You need 1 Scroll of Mass Protection from Dragons."failslevelrequirements: 0failslevelrequirementsfilter: 0failsresourcesrequirements: 1header: ""isheader: 0nextupdatetime: "Sat, 01 Jan 2000 00:00:00 GMT"required: Array[3]rewards: Array[4]weight: 3__proto__: Object
VM3855:2078 Found required ingredient: Crafting_Resource_Scroll_Protection_Dragons

I notice that the above is for two different tasks.... the first is for a level 25 and the second for a level 24..... the level 24 is CORRECTLY failing due unmet requirements.... the level 25 in INCORRECTLY failing due to the "failedrequirementsreasons" not being present in the object.... so from this I can say the level 24 "success" is in fact no use here..... what I need to see is the level 25 success vs the level 25 fail - however - looking at the above.... that level 25 task doesn't appear to have any failed requirements and therefore should NOT fail..... therefore my solution would as you say abort the level 25 task and pick a lower one (not what we want). Therefore my first proposed solution of once we get the thisTask variable back from the object model, then we should test whether "failedrequirementsreasons" is contained in thisTask.... if it is not then we should assume that there are no failed reasons and therefore SHOULD NOT abort the task - maybe a double check - so first check for undefined - if undefined then it is not present so cannot be an unmet requirement so start the task, then if it is in the variable - check the length and if no reason is given - still ok - start the task.....

Try this and let me know :

    // start task if requirements are met
    //no unmet requirements in thisTask - all good
    if (typeof thisTask.failedrequirementsreasons == 'undefined') {
        return thisTask;
    }

    //second test, unmet requirements exist - now check if they have any value
    if (!thisTask.failedrequirementsreasons.length) {
        return thisTask;
    }
Rotten_mindAuthor
§
Posted: 25-03-2015

You can test them and they may work on one run or fail three(or more) run, as I allready told "there is no pattern" so failed part must be tested until "NO error" or "reload page" if error else we wait until "Auto reload".

Check how your change affects other profession task chains.

Rotten_mindAuthor
§
Posted: 25-03-2015
Edited: 25-03-2015

thisTask.failedrequirementsreasons.lenght // no error because, thisTask has "failedrequirementsreasons" what can have "lenght"

Searching for task: Leadership_Tier4_25_Battleelementalcultists
VM902:1987 failed req Object {def: Object, failedrequirementsreasons: "", header: "", weight: 1, required: Array[3]…}consumables: Array[0]def: Objectfailedrequirementsreasons: "No available slot to start the assignment in!"failslevelrequirements: 0failslevelrequirementsfilter: 0failsresourcesrequirements: 0header: ""isheader: 0nextupdatetime: "Sat, 01 Jan 2000 00:00:00 GMT"required: Array[3]rewards: Array[5]weight: 1__proto__: Object
VM902:1895 Task Found
VM902:2255 Clicked item

thisTask.failedrequirementsreasons.lenght // cause error because, thisTask has NO "failedrequirementsreasons" so "undefined" is failedrequirementsreasons, what is loaded here as "weight" what Lenght is "1"

Searching for task: Leadership_Tier4_25_Battleelementalcultists
VM902:1987 failed req Object {def: Object, weight: 1, required: Array[3], rewards: Array[5], isheader: 0…}def: Objectfailslevelrequirements: 0failslevelrequirementsfilter: 0failsresourcesrequirements: 0isheader: 0required: Array[3]rewards: Array[5]weight: 1__proto__: Object
VM902:1989 Uncaught TypeError: Cannot read property 'length' of undefined

This was catched in same session without restart.

If try that "undefined" it will cause other problems because

 !thisTask.failedrequirementsreasons."" (gives "undefined")  // lenght is not defined when task is possible to start

  !thisTask.failedrequirementsreasons."You need 1 Scroll of Mass Protection from Dragons." // lenght is  defined when task NOT possible to start
§
Posted: 25-03-2015

I don't have a playable account on preview server (which is why I cant test a level 25 preofession :P). Can you try the code block I posted above against your level 25 battle elemental cultists - as that will follow this pattern :

For the first instance : typeof thisTask.failedrequirementsreasons IS NOT undefined so will move on to the next part....!thisTask.failedrequirementsreasons.length is empty string so returns thisTask (which should then click the button and then start the task)

For the second instance : typeof thisTask.failedrequirementsreasons IS undefined so will return thisTask immediately (which should then click the button and start the task)

Which I believe is the required behaviour for the script.

t4k
§
Posted: 25-03-2015

Tried swap destroy camp and collect taxes in leadership array, on some characters it helps... But sometimes script starts tasks in different order from the same array and stuck comes back. Looks like some stucks are gone, but need more data.

Rotten_mindAuthor
§
Posted: 25-03-2015
Tried swap destroy camp and collect taxes in leadership array, on some characters it helps... But sometimes script starts tasks in different order from the same array and stuck comes back. Looks like some stucks are gone, but need more data.

Save your time and....

Replace this,

 // start task if requirements are met
        if (!thisTask.failedrequirementsreasons.length) {
            return thisTask;
        }

, with this line

    // start task if requirements are met, we try it because it might cause errors
    try {
        if (!thisTask.failedrequirementsreasons.length) {
            return thisTask;
        }
    } catch (e) {
        //console.log("");
        unsafeWindow.location.href = current_Gateway; // array loaderror will restart
    }

after that allways when tampermonkey fails execute script, it will restart and other function's are not affected.

I dont know why you get that much errors, it take several tries before I can reproduce that error.

§
Posted: 25-03-2015

LOL "just switch it off and back on again" - not really the idea - if you have an account with 50+ characters that will take ages to cycle round and collate all the information again every time the script breaks. Better to handle the error and move on than to just reset the script constantly.

Rotten_mindAuthor
§
Posted: 25-03-2015
Edited: 25-03-2015
LOL "just switch it off and back on again" - not really the idea - if you have an account with 50+ characters that will take ages to cycle round and collate all the information again every time the script breaks. Better to handle the error and move on than to just reset the script constantly.

Then find way loop until browser loads that data correctly,

if there is no restart then script wait untill reload, "undefined check" cause script skip task what cause problems with tasklist...

So it is,

catch error and reload,

or

catch error, make loop untill array data contains no error.

50 character takes 30 - 45 minutes cycle, Auto reload acts every three hours, this error may occur 1 - 10 times per week(tried catch it with 10 accounts).

So, here is working code, make it work with do-while or while loop what breaks if no error,

    // start task if requirements are met, we try it because it might cause errors
    try {
        if (!thisTask.failedrequirementsreasons.length) { //this must be "no error"
            return thisTask;
        }
    } catch (e) {
        //console.log("");
        unsafeWindow.location.href = current_Gateway; // array loaderror will restart, if loop outcomment
    }

Post reply

Sign in to post a reply.