SHARE
TWEET

Untitled

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