6

I'm stuck on Level 15 of Untrusted.

I've gotten this far with no actual knowledge of Javascript beyond knowing C and assuming things are the same. I see no possible solution to this puzzle without some trick of the language I don't know about- no matter what I put in there, player.killedBy() is going to be called, and the Professor is going to die.

Any hints?

7 Answers 7

6

You can put anything in there that doesn't exist. eg

player.killedBy(nothing);

When you go in the water it will then throw an error message because nothing doesn't exist.

7

Actually you can pass the level without throwing any exception, just hacking the code:

[line 32] player.killedBy('
');},'onCollision':function(player){map.getWidth(
);

Just replacing the "onCollision" action again with a function that doesn't do anything.
enter image description here

Then you can walk on water!!

1
  • I hate that I love your solution. Congratulations for the ingenuity.
    – Cristopher
    Mar 10, 2019 at 7:20
3

You can use concatenation and short circuit the collision detection routine i.e.

map.defineObject('water', {
    'symbol': '░',
    'color': '#44f',
    'onCollision': function (player) {
        player.killedBy(''+map.placePlayer(1,1));
    }
});
2

Of course, the hint is in the name.

You've got to throw an exception.

2
  • But how? This answer is kinda useless without some instructions, don't you think? Apr 15, 2014 at 5:22
  • I was intending it as more of a hint.
    – Schilcote
    Apr 15, 2014 at 12:30
2

I like this way:

player.killedBy(function() { throw 'I am Jesus';} ());
1

You can't acrossing water, but you can pick it up.

map.defineObject('water', {
        'symbol': '░',
        'color': '#44f',
        'onCollision': function (player) {
            player.killedBy();},'type':'item','beha':function(me){me.move('up');
        }
    });
0

also u can use infinite recursion..

player.killedBy((function(){x=function(){x();};x();})());

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .