Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bot fails at the command of stop watch #38

Open
lastuniverse opened this issue Feb 28, 2016 · 23 comments
Open

bot fails at the command of stop watch #38

lastuniverse opened this issue Feb 28, 2016 · 23 comments
Labels

Comments

@lastuniverse
Copy link

/home/......./rbot/task/blockTask.js:96
bot.removeListener('blockUpdate',wa[1]);
^

TypeError: Cannot read property '1' of undefined
at stopWatch (/home/......./rbot/task/blockTask.js:96:37)
at /home/......./rbot/achieve.js:53:11
at /home/......./rbot/lib/stringTo.js:39:192
at /home/......./rbot/node_modules/async/lib/async.js:232:13
at async.each (/home/......./rbot/node_modules/async/lib/async.js:107:20)
at _asyncMap (/home/......./rbot/node_modules/async/lib/async.js:226:9)
at Object.map (/home/......./rbot/node_modules/async/lib/async.js:204:23)
at Object.stringTo (/home/......./rbot/lib/stringTo.js:39:8)
at applyAction (/home/......./rbot/achieve.js:52:12)
at Immediate._onImmediate (/home/......./rbot/achieve.js:87:28)

@rom1504
Copy link
Owner

rom1504 commented Feb 28, 2016

Yeah I know that's broken, not sure why.
I'll try fixing it sometime.

@lastuniverse
Copy link
Author

rom
I tried to understand myself. in the code function watch, wa the array is initialized.

wa = ["done", function ...... ]

can't understand why in the stopWatch it is not already initialized

@lastuniverse
Copy link
Author

just tell me where to look

@rom1504
Copy link
Owner

rom1504 commented Feb 28, 2016

maybe because https://github.com/rom1504/rbot/blob/master/task/blockTask.js#L74 is never executed.

Try adding some console.log there maybe.

@lastuniverse
Copy link
Author

did so:

var watch_result = {};

function watch(ent,done)
{
    console.log("start watch");
    var firstPosition=ent.position.floored();
    com="";
    bot.on('blockUpdate',function(firstPosition){
        watch_result.status = done;
        watch_result.cb = function(oldBlock,newBlock){
            if(newBlock==null) return;
            if(ent.position.floored().distanceTo(newBlock.position.floored())<5)
            {
                var action;
                if(isBlockEmpty(newBlock)) action="dig";
                else if(isBlockNotEmpty(newBlock)) action="build";
                else action="";
                if(action!="")
                {
                    var d=newBlock.position.floored().minus(firstPosition);
                    var c=action+" r"+positionToString(d)
                    console.log(c);
                    com+=(com!="" ? " then " : "")+c;
                }
            }
        };

        return watch_result.cb;
    }(firstPosition));
}

function stopWatch(done)
{
    console.log("stoped watch");
    bot.removeListener('blockUpdate',watch_result.cb);
    watch_result.status();
    com="do "+com+" done";
    console.log(com);
    done();
}

in console got:

watch lastuniverse
undefined
stop watch
["stop watch",[]]
I'm going to achieve task ["stop watch",[]]
stoped watch
events.js:276
        throw new TypeError('listener must be a function');
        ^

TypeError: listener must be a function
    at Bot.removeListener (events.js:276:15)
    at stopWatch (/home/roman/work/electron/apps/minecraft.proxy.bot/src/bot/rbot/task/blockTask.js:103:6)
    at /home/roman/work/electron/apps/minecraft.proxy.bot/src/bot/rbot/achieve.js:53:11
    at /home/roman/work/electron/apps/minecraft.proxy.bot/src/bot/rbot/lib/stringTo.js:39:192
    at /home/roman/work/electron/apps/minecraft.proxy.bot/src/node_modules/async/lib/async.js:232:13
    at async.each (/home/roman/work/electron/apps/minecraft.proxy.bot/src/node_modules/async/lib/async.js:107:20)
    at _asyncMap (/home/roman/work/electron/apps/minecraft.proxy.bot/src/node_modules/async/lib/async.js:226:9)
    at Object.map (/home/roman/work/electron/apps/minecraft.proxy.bot/src/node_modules/async/lib/async.js:204:23)
    at Object.stringTo (/home/roman/work/electron/apps/minecraft.proxy.bot/src/bot/rbot/lib/stringTo.js:39:8)
    at applyAction (/home/roman/work/electron/apps/minecraft.proxy.bot/src/bot/rbot/achieve.js:52:12)

it is seen that
console.log("watch start");
the functions of the watch didn't work.
that is, the function watch(...) was never called.

where calls the function watch(...)?

@rom1504
Copy link
Owner

rom1504 commented Feb 28, 2016

It's after watch_result.status = done; that you should try to put a console.log("test"); to see if it goes there.

@lastuniverse
Copy link
Author

changed:

function watch(ent,done)
{
    console.log("start watch");
    var firstPosition=ent.position.floored();
    com="";
    bot.on('blockUpdate',function(firstPosition){
        watch_result.status = done;
        console.log("test watch");

in console:

watch lastuniverse
undefined
stop watch
["stop watch",[]]
I'm going to achieve task ["stop watch",[]]
stoped watch
events.js:276
        throw new TypeError('listener must be a function');

all the same. in the console did not get any start watch and test watch

if the function call is the watch(......) in the console is to be displayed start watch

function watch(ent,done)
{
    console.log("start watch");
...

@lastuniverse
Copy link
Author

therefore it can be argued that the function call to watch(...) is not performed

perhaps it is because the command watch is the argument <entity>.
And as a result entry "watch":blockTask.watch in the file task.js does not work.

this may be the cause?

@lastuniverse
Copy link
Author

found a place which may be an error:

modified the function processMessage in file achieve.js

function processMessage(message,username,done)
{
    console.log("task debug ["+message+"] in achieve.js 161");
    if(username !=bot.username && (username===master || master===undefined))
    {
        console.log(message);
        var parsedMessage;
        try
        {
            parsedMessage=parse(message);
        }
        catch(error)
        {
            console.log(error.stack);
            return;
        }
        if(parsedMessage[0] in tasks ||parsedMessage[0] in parameterized_alias) achieve(parsedMessage,username,done);
    }
    console.log("task debug ["+message+"] in achieve.js 177");
}

adding the following line:
console.log("task debug ["+message+"] in achieve.js 161");
console.log("task debug ["+message+"] in achieve.js 177");

in console:

task debug [watch lastuniverse] in rbot.js 41
task debug [watch lastuniverse] in achieve.js 161
watch lastuniverse
undefined

it is seen that execution of the line XXX is not happening for the following reason:

        catch(error)
        {
            console.log(error.stack);
            return;
        }

it remains only to find the bug :(

@rom1504
Copy link
Owner

rom1504 commented Feb 28, 2016

oh yes of course.
it's watch <entity>
if you want to watch a player, the entity should be player <playerName>

so for example watch player lastuniverse

@lastuniverse
Copy link
Author

still crashes. But the watch command is already processing

watch player lastuniverse
["watch",[["entity","player lastuniverse"]]]
task debug [watch] in achieve.js 78
task debug [watch] in achieve.js 67
I'm going to achieve task ["watch",[["entity","player lastuniverse"]]]
task debug [watch player lastuniverse] in achieve.js 177
start watch
test watch
build r2,0,1
build r2,1,1
build r2,1,0
task debug [stop watch] in rbot.js 41
task debug [stop watch] in achieve.js 161
stop watch
["stop watch",[]]
task debug [stop watch] in achieve.js 78
task debug [stop watch] in achieve.js 67
I'm going to achieve task ["stop watch",[]]
task debug [stop watch] in achieve.js 177
stoped watch
/home/roman/work/electron/apps/minecraft.proxy.bot/src/bot/rbot/task/blockTask.js:105
        watch_result.status();
                     ^

TypeError: watch_result.status is not a function
    at stopWatch (/home/roman/work/electron/apps/minecraft.proxy.bot/src/bot/rbot/task/blockTask.js:105:15)
    at /home/roman/work/electron/apps/minecraft.proxy.bot/src/bot/rbot/achieve.js:53:11
    at /home/roman/work/electron/apps/minecraft.proxy.bot/src/bot/rbot/lib/stringTo.js:39:192
    at /home/roman/work/electron/apps/minecraft.proxy.bot/src/node_modules/async/lib/async.js:232:13
    at async.each (/home/roman/work/electron/apps/minecraft.proxy.bot/src/node_modules/async/lib/async.js:107:20)
    at _asyncMap (/home/roman/work/electron/apps/minecraft.proxy.bot/src/node_modules/async/lib/async.js:226:9)
    at Object.map (/home/roman/work/electron/apps/minecraft.proxy.bot/src/node_modules/async/lib/async.js:204:23)
    at Object.stringTo (/home/roman/work/electron/apps/minecraft.proxy.bot/src/bot/rbot/lib/stringTo.js:39:8)
    at applyAction (/home/roman/work/electron/apps/minecraft.proxy.bot/src/bot/rbot/achieve.js:52:12)
    at Immediate._onImmediate (/home/roman/work/electron/apps/minecraft.proxy.bot/src/bot/rbot/achieve.js:89:28)

@rom1504
Copy link
Owner

rom1504 commented Feb 28, 2016

hmm can you print the done of watch_result.status = done; ? see what's in it

@lastuniverse
Copy link
Author

in watch_result.status my nick :)

stop watch
["stop watch",[]]
task debug [stop watch] in achieve.js 78
task debug [stop watch] in achieve.js 67
I'm going to achieve task ["stop watch",[]]
task debug [stop watch] in achieve.js 177
stoped watch
test stopwatch [lastuniverse] in blockTask.js 106
lastuniverse

what there should be?

@lastuniverse
Copy link
Author

in done my nick too

function watch(ent,done)
{
    console.log("start watch. done = "+done);

console:

start watch. done = lastuniverse

@rom1504
Copy link
Owner

rom1504 commented Feb 28, 2016

Really ? there's your nick in done ???
It should be a function.

@rom1504
Copy link
Owner

rom1504 commented Feb 28, 2016

I was talking about the done of watch.

@lastuniverse
Copy link
Author

sorry, I took the kids to roller skate.
Yes, there really is my nickname. I see what function is required. But couldn't find where it comes from this option.

@lastuniverse
Copy link
Author

Now the wife sends you to the market. She is one of those women who can not refuse :)
As the store comes, I will look for an error further.

@lastuniverse
Copy link
Author

I came.
Tell me which of the files is the primary function call watch?
And in what file the setting is done privatives function?

@rom1504
Copy link
Owner

rom1504 commented Feb 28, 2016

@lastuniverse
Copy link
Author

this is without the latest commit

in code:

function watch(ent,done,done1,done2)
{
    console.log("start watch")
    console.log("done = "+done);
    console.log("done1 = "+done1);
    console.log("done2 = "+done2);

in console:

start watch. 
done = lastuniverse 
done1 = function (result){
                                if(result!=null && !result) {applyAction(task,username,parsedTask,done);} 
                                else {
                                        if(result) reportFailOfTask(parsedTask)(); 
                                        else reportEndOfTask(parsedTask,done)()
                                }
                        } 
done2 = undefined

@lastuniverse
Copy link
Author

thank you very much. Children already overcome with requests to make them a bot:)

@lastuniverse
Copy link
Author

now errors out when using any commands.
Mostly errors about type mismatch of one of the passed arguments to the expected type.
And the lack of initialized parameters.

To post here the errors?

@rom1504 rom1504 added the bug label May 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants