[Solved] Lost Vikings: How to listen to the raven dynamically?

What the raven says is different for each player, right? Will it be different for me when I press submit, if so what do I use to get access to the paramters?

I was working on this listening function, including extracting the parameters, but it doesn’t work, as it seems there’s no hearing event… how is that? - Or am I doing something wrong?

function extractNumber(s){
    var number="";
    for(var i = 0; i < s.length; i++){
        if(!isNaN(s[i])){
            number += s[i];
        } else {
            continue;
        }
    }
    return parseInt(number, 10);
}

function onHear(event) {
    pet.say("heard");
    // The original message.
    var message = event.message;
    var parameters = message.split(',');
    var sl = extractNumbers(parameters[0]),
        sw = extractNumbers(parameters[1]),
        sk = extractNumbers(parameters[2]);
    pet.say("Parameters are " + sl + ", " + sw + ", and " + sk);
}
pet.on("hear", onHear);

Cheers,
Julian

Of course the parameters won’t change when you submit

don’t bother with hearing :stuck_out_tongue:

I see… fair enough - didn’t realize the bird was also going to keep talking - that could have messed with my code a lot :smiley:

2 Likes