Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.18 KB | None | 0 0
  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. });
  23. var i=true;
  24. var q=true;
  25.  
  26. map.getPlayer().setPhoneCallback(function () {
  27.  
  28. var player = map.getPlayer();
  29. var col = player.getColor();
  30.  
  31.  
  32.  
  33. if ( i ){
  34.  
  35. player.setColor("#f00");
  36.  
  37. i= false ;
  38.  
  39. }
  40. else{
  41. if( q) {
  42. player.setColor("#ff0");
  43. q= false;
  44. }
  45. else{
  46. player.setColor("#0f0");
  47. q= true;
  48. }
  49. i= true ;
  50. }
  51. // if ( col = "#0f0" ){ //verde
  52. // player.setColor('#ff0'); //amarillo
  53. // map.setSquareColor(2, 6, '#0f0');
  54. // end;
  55. // }
  56. // else {
  57. // if ( col = "#ff0" ){ // amarillo
  58. // player.setColor('#f00'); //rojo
  59. // map.setSquareColor(2, 2, '#f00');
  60. // }
  61. // else{
  62. //
  63. // player.setColor("#f00"); //amrillo
  64. // map.setSquareColor(2, 4, '#ff0');
  65.  
  66. // }
  67.  
  68.  
  69. });
  70.  
  71.  
  72. map.defineObject('redLock', {
  73. symbol: '☒',
  74. color: "#f00", // red
  75. impassable: function(player, object) {
  76. return player.getColor() != object.color;
  77. }
  78. });
  79.  
  80. map.defineObject('greenLock', {
  81. symbol: '☒',
  82. color: "#0f0", // green
  83. impassable: function(player, object) {
  84. return player.getColor() != object.color;
  85. }
  86. });
  87.  
  88. map.defineObject('yellowLock', {
  89. symbol: '☒',
  90. color: "#ff0", // yellow
  91. impassable: function(player, object) {
  92. return player.getColor() != object.color;
  93. }
  94. });
  95.  
  96. for (var x = 20; x <= 40; x++) {
  97. map.placeObject(x, 11, 'block');
  98. map.placeObject(x, 13, 'block');
  99. }
  100. map.placeObject(22, 12, 'greenLock');
  101. map.placeObject(25, 12, 'redLock');
  102. map.placeObject(28, 12, 'yellowLock');
  103. map.placeObject(31, 12, 'greenLock');
  104. map.placeObject(34, 12, 'redLock');
  105. map.placeObject(37, 12, 'yellowLock');
  106. map.placeObject(40, 12, 'exit');
  107. for (var y = 0; y < map.getHeight(); y++) {
  108. if (y != 12) {
  109. map.placeObject(40, y, 'block');
  110. }
  111. for (var x = 41; x < map.getWidth(); x++) {
  112. map.setSquareColor(x, y, '#080');
  113. }
  114. }
  115. }
  116.  
  117. function validateLevel(map) {
  118. map.validateExactlyXManyObjects(1, 'exit');
  119. }
  120.  
  121. function onExit(map) {
  122. if (!map.getPlayer().hasItem('phone')) {
  123. map.writeStatus("We need the phone!");
  124. return false;
  125. } else {
  126. return true;
  127. }
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement