daily pastebin goal
19%
SHARE
TWEET

Untitled

a guest Jul 11th, 2018 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*************
  2. * colors.js *
  3.  *************
  4.  *
  5.  * You're almost at the exit. You just need to get past this
  6.  * color lock.
  7.  *
  8.  * Changing your environment is no longer enough. You must
  9.  * learn to change yourself. I've sent you a little something
  10.  * that should help with that.
  11.  */
  12.  
  13. function startLevel(map) {
  14.     map.placePlayer(0, 12);
  15.  
  16.     map.placeObject(5, 12, 'phone');
  17.  
  18.     // The function phone lets you call arbitrary functions,
  19.     // as defined by player.setPhoneCallback() below.
  20.     // The function phone callback is bound to Q or Ctrl-6.
  21.     map.getPlayer().setPhoneCallback(function () {
  22.     var player = map.getPlayer();
  23. player.turn = player.turn === undefined ? 0 : player.turn+1;
  24. colors=['#f00','#ff0','#0f0','#f00','#ff0'];
  25. player.setColor(colors[player.turn]);
  26.  
  27.  
  28.  
  29.  
  30.  
  31.     });
  32.  
  33.  
  34.     map.defineObject('redLock', {
  35.         symbol: '☒',
  36.         color: "#f00", // red
  37.         impassable: function(player, object) {
  38.             return player.getColor() != object.color;
  39.         }
  40.     });
  41.  
  42.     map.defineObject('greenLock', {
  43.         symbol: '☒',
  44.         color: "#0f0", // green
  45.         impassable: function(player, object) {
  46.             return player.getColor() != object.color;
  47.         }
  48.     });
  49.  
  50.     map.defineObject('yellowLock', {
  51.         symbol: '☒',
  52.         color: "#ff0", // yellow
  53.         impassable: function(player, object) {
  54.             return player.getColor() != object.color;
  55.         }
  56.     });
  57.  
  58.     for (var x = 20; x <= 40; x++) {
  59.         map.placeObject(x, 11, 'block');
  60.         map.placeObject(x, 13, 'block');
  61.     }
  62.     map.placeObject(22, 12, 'greenLock');
  63.     map.placeObject(25, 12, 'redLock');
  64.     map.placeObject(28, 12, 'yellowLock');
  65.     map.placeObject(31, 12, 'greenLock');
  66.     map.placeObject(34, 12, 'redLock');
  67.     map.placeObject(37, 12, 'yellowLock');
  68.     map.placeObject(40, 12, 'exit');
  69.     for (var y = 0; y < map.getHeight(); y++) {
  70.         if (y != 12) {
  71.             map.placeObject(40, y, 'block');
  72.         }
  73.         for (var x = 41; x < map.getWidth(); x++) {
  74.             map.setSquareColor(x, y, '#080');
  75.         }
  76.     }
  77. }
  78.  
  79. function validateLevel(map) {
  80.     map.validateExactlyXManyObjects(1, 'exit');
  81. }
  82.  
  83. function onExit(map) {
  84.     if (!map.getPlayer().hasItem('phone')) {
  85.         map.writeStatus("We need the phone!");
  86.         return false;
  87.     } else {
  88.         return true;
  89.     }
  90. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top