daily pastebin goal
90%
SHARE
TWEET

Untitled

a guest Oct 19th, 2018 81 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  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.        
  24.         if (!map.colors) {
  25.         var green = '#0f0';
  26.         var red = '#f00';
  27.         var yellow = '#ff0';
  28.         map.colors = [green,red,yellow,green,red,yellow];
  29.         }
  30.        
  31.         player.setColor(map.colors.shift());
  32.  
  33.  
  34.  
  35.  
  36.  
  37.     });
  38.  
  39.  
  40.     map.defineObject('redLock', {
  41.         symbol: '☒',
  42.         color: "#f00", // red
  43.         impassable: function(player, object) {
  44.             return player.getColor() != object.color;
  45.         }
  46.     });
  47.  
  48.     map.defineObject('greenLock', {
  49.         symbol: '☒',
  50.         color: "#0f0", // green
  51.         impassable: function(player, object) {
  52.             return player.getColor() != object.color;
  53.         }
  54.     });
  55.  
  56.     map.defineObject('yellowLock', {
  57.         symbol: '☒',
  58.         color: "#ff0", // yellow
  59.         impassable: function(player, object) {
  60.             return player.getColor() != object.color;
  61.         }
  62.     });
  63.  
  64.     for (var x = 20; x <= 40; x++) {
  65.         map.placeObject(x, 11, 'block');
  66.         map.placeObject(x, 13, 'block');
  67.     }
  68.     map.placeObject(22, 12, 'greenLock');
  69.     map.placeObject(25, 12, 'redLock');
  70.     map.placeObject(28, 12, 'yellowLock');
  71.     map.placeObject(31, 12, 'greenLock');
  72.     map.placeObject(34, 12, 'redLock');
  73.     map.placeObject(37, 12, 'yellowLock');
  74.     map.placeObject(40, 12, 'exit');
  75.     for (var y = 0; y < map.getHeight(); y++) {
  76.         if (y != 12) {
  77.             map.placeObject(40, y, 'block');
  78.         }
  79.         for (var x = 41; x < map.getWidth(); x++) {
  80.             map.setSquareColor(x, y, '#080');
  81.         }
  82.     }
  83. }
  84.  
  85. function validateLevel(map) {
  86.     map.validateExactlyXManyObjects(1, 'exit');
  87. }
  88.  
  89. function onExit(map) {
  90.     if (!map.getPlayer().hasItem('phone')) {
  91.         map.writeStatus("We need the phone!");
  92.         return false;
  93.     } else {
  94.         return true;
  95.     }
  96. }
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