Skip to content

Instantly share code, notes, and snippets.

@Fortyseven
Created April 23, 2014 02:20
Show Gist options
  • Save Fortyseven/11200844 to your computer and use it in GitHub Desktop.
Save Fortyseven/11200844 to your computer and use it in GitHub Desktop.
Code that got me through Level 11 and 12 of Untrusted
var player = map.getPlayer();
if (this.init === undefined) {
this.player_last_x = player.getX();
this.player_last_y = player.getY();
this.init = true;
return;
}
if (player.getX() > this.player_last_x) me.move('right');
if (player.getX() < this.player_last_x) me.move('left');
if (player.getY() > this.player_last_y) me.move('down');
if (player.getY() < this.player_last_y) me.move('up');
this.player_last_x = player.getX();
this.player_last_y = player.getY();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment