default.nut 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. print("default.nut loaded\n");
  2. fishbox_names <- ["hide_bonus", "worldmap", "home", "above", "groundwater", "playground", "end", "blueone", "bluetwo", "waterfalls", "temperature", "crazy", "afraid", "escape", "foreign", "hang", "latern", "colder", "spikes", "stars", "without", "harbor", "shaft", "slippery", "enjoy", "spooky", "staple", "bombastic", "carry", "windy", "freeze", "bonus", "hail", "lotus", "down", "bridge", "reaching"];
  3. if(! ("fishboxes" in state)){
  4. state.fishboxes <- {};
  5. print("fishbox state initiallized\n");
  6. }
  7. foreach(name in fishbox_names){
  8. if(!(name in state.fishboxes)){
  9. state.fishboxes[name] <- false;
  10. state.fishboxes["hide_bonus"] <- true;
  11. print("corrected fishbox state\n");
  12. }
  13. }
  14. state.fishboxes["worldmap"] <- true;
  15. progress <- state.fishboxes;
  16. //CUT SCENE FUNCTIONS
  17. if("secrettop" in this){
  18. state.skip_scene1 <- false;
  19. state.skip_scene2 <- false;
  20. state.skip_scene3 <- false;
  21. }
  22. function watch1(){
  23. temp <- state.skip_scene1;
  24. state.skip_scene1 <- true;
  25. return temp;
  26. }
  27. function watch2(){
  28. temp <- state.skip_scene2;
  29. state.skip_scene2 <- true;
  30. return temp;
  31. }
  32. function watch3(){
  33. temp <- state.skip_scene3;
  34. state.skip_scene3 <- true;
  35. return temp;
  36. }
  37. //MECHANIC FUNCTIONS
  38. function find_fish(box){
  39. if(!(progress[box])){
  40. progress[box] <- true;
  41. save_progress();
  42. display_fishbox(box);
  43. play_sound("sounds/clapping.ogg");
  44. }else{
  45. play_sound("sounds/warp.wav");
  46. }
  47. FISHBOX_IMAGE.set_visible(false);
  48. }
  49. function check_bonus(){
  50. if(progress["hide_bonus"] == false){
  51. secret.fade(1,0);
  52. secrettop.fade(0,0);
  53. }
  54. else{
  55. n <- 0;
  56. tot <- 0;
  57. foreach(name in fishbox_names){
  58. if(progress[name]){n++}
  59. tot ++;
  60. }
  61. if(n==tot){
  62. secret.fade(1,0);
  63. secrettop.fade(0,1.2);
  64. progress["hide_bonus"] <- false;
  65. save_progress();
  66. n <- 0;
  67. play_sound("sounds/invincible_start.ogg");
  68. }
  69. }
  70. }
  71. function query(box){return progress[box]}
  72. function save_progress(){state.fishboxes <- progress;}
  73. function delete_progress(){
  74. state.fishboxes <- {};
  75. foreach(name in fishbox_names){
  76. state.fishboxes[name] <- false;
  77. }
  78. state.fishboxes["hide_bonus"] <- true;
  79. state.fishboxes["worldmap"] <- true;
  80. progress <- state.fishboxes;
  81. }
  82. //DISPLAY FUNCTIONS
  83. function display_fishbox(box){
  84. local x = 10;
  85. local y = 10;
  86. if(!("fishbox" in this)){
  87. fishbox <- FloatingImage("images/engine/hud/fishbox_level.sprite");
  88. fishbox.set_anchor_point(ANCHOR_TOP_LEFT);
  89. fishbox.set_pos(x,y);
  90. }
  91. fishbox.set_visible(true);
  92. fishbox.set_action(progress[box] ? "found" : "normal");
  93. if("FISHBOX_IMAGE" in this){
  94. FISHBOX_IMAGE.set_action("undiscovered");
  95. FISHBOX_IMAGE.set_visible(progress[box] ? false : true);
  96. }
  97. }
  98. function display_fishbox_counter(){
  99. local x = 10+34;
  100. local y = 10+10;
  101. display_fishbox("worldmap");
  102. if(!("fishcount" in this)){
  103. fishcount <- {};
  104. fishcount["text"] <- FloatingImage("images/engine/hud/fishbox_world.sprite");
  105. fishcount["text"].set_anchor_point(ANCHOR_TOP_LEFT);
  106. fishcount["text"].set_pos(x+32,y);
  107. //found digits:
  108. fishcount["fTEN"] <- FloatingImage("images/engine/hud/fishbox_digit.sprite");
  109. fishcount["fTEN"].set_anchor_point(ANCHOR_TOP_LEFT);
  110. fishcount["fTEN"].set_pos(x,y);
  111. fishcount["fONE"] <- FloatingImage("images/engine/hud/fishbox_digit.sprite");
  112. fishcount["fONE"].set_anchor_point(ANCHOR_TOP_LEFT);
  113. fishcount["fONE"].set_pos(x+16,y);
  114. //total digits:
  115. fishcount["tTEN"] <- FloatingImage("images/engine/hud/fishbox_digit.sprite");
  116. fishcount["tTEN"].set_anchor_point(ANCHOR_TOP_LEFT);
  117. fishcount["tTEN"].set_pos(x+48,y);
  118. fishcount["tONE"] <- FloatingImage("images/engine/hud/fishbox_digit.sprite");
  119. fishcount["tONE"].set_anchor_point(ANCHOR_TOP_LEFT);
  120. fishcount["tONE"].set_pos(x+64,y);
  121. }
  122. fishcount["text"].set_visible(true);
  123. fishcount["fTEN"].set_visible(true);
  124. fishcount["fONE"].set_visible(true);
  125. fishcount["tTEN"].set_visible(true);
  126. fishcount["tONE"].set_visible(true);
  127. temp <- 0;
  128. tot <- 0;
  129. foreach(name in fishbox_names){
  130. if(progress[name])
  131. temp++;
  132. tot++
  133. }
  134. tot -= 2;
  135. temp--;//worldmap does not count toward total
  136. if(progress["hide_bonus"])
  137. temp--;//hide_bonus does not count toward total
  138. set_digit("fTEN",temp/10);
  139. set_digit("fONE",temp%10);
  140. set_digit("tTEN",tot/10);
  141. set_digit("tONE",tot%10);
  142. }
  143. function set_digit(digit,number){
  144. if(number==0){fishcount[digit].set_action("0");
  145. }else if(number==1){fishcount[digit].set_action("1");
  146. }else if(number==2){fishcount[digit].set_action("2");
  147. }else if(number==3){fishcount[digit].set_action("3");
  148. }else if(number==4){fishcount[digit].set_action("4");
  149. }else if(number==5){fishcount[digit].set_action("5");
  150. }else if(number==6){fishcount[digit].set_action("6");
  151. }else if(number==7){fishcount[digit].set_action("7");
  152. }else if(number==8){fishcount[digit].set_action("8");
  153. }else if(number==9){fishcount[digit].set_action("9");
  154. }else{print("fishbox counter error\n");}
  155. }