default.nut 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //INITIALIZATION OF STATE VARIABLES
  2. key_names <- [ "darkness" "unlicensed"]
  3. if(!("keys" in state)){
  4. state.keys <- {};
  5. foreach(name in key_names){
  6. state.keys[name] <- false;
  7. }
  8. print("[DEBUG] key state initialized\n");
  9. }
  10. status <- state.keys;
  11. function set_darkness(night){
  12. dark.fade(night ? 0.6 : 0, 1);
  13. status.darkness <- night;
  14. save_keys();
  15. }
  16. function set_unlicensed(under){
  17. if(true||!(under && status.unlicensed)){
  18. speed <- 0.5;
  19. pathing.fade(under ? 0 : 1, speed);
  20. land_detail_far.fade(under ? 0 : 1, speed);
  21. land_detail_near.fade(under ? 0 : 1, speed);
  22. foreground_far.fade(under ? 0 : 1, speed);
  23. foreground_near.fade(under ? 0 : 1, speed);
  24. map.fade(under ? 0 : 1, speed);
  25. exit.fade(under ? 0 : (outpath ? 1 : 1), speed);
  26. noexit.fade(under ? 0 : (outpath ? 0 : 0), speed);
  27. u_pathing.fade(under ? 1 : 0, speed);
  28. u_map.fade(under ? 1 : 0, speed);
  29. u_background.fade(under ? 1 : 0, speed);
  30. u_foreground.fade(under ? 1 : 0, speed);
  31. status.unlicensed <- under;
  32. save_keys();
  33. //print("[DEBUG] un "+under+"\n");
  34. play_music(under ? "music/voc-night.music" : "music/voc-daytime2.music");
  35. }
  36. }
  37. function query(item){return status[item];}
  38. function fire_bonus(){
  39. Tux.deactivate();
  40. Tux.add_bonus("fireflower");
  41. play_sound("sounds/fire-flower.wav");
  42. print("fire bonus added\n");
  43. wait(1);
  44. Effect.fade_out(2);
  45. wait(2);
  46. Level.finish(true);
  47. }
  48. function ice_bonus(){
  49. Tux.deactivate();
  50. Tux.add_bonus("iceflower");
  51. play_sound("sounds/fire-flower.wav");
  52. print("ice bonus added\n");
  53. wait(1);
  54. Effect.fade_out(2);
  55. wait(2);
  56. Level.finish(true);
  57. }
  58. function save_keys(){state.keys <- status;}
  59. function reset_keys(){
  60. foreach(name in key_names){
  61. status[name] <- false;
  62. }
  63. save_keys();
  64. }
  65. if("map" in this){
  66. outpath <- state.worlds["/levels/bonus3/worldmap.stwm"].levels["sever_escape.stl"].solved;
  67. set_darkness(status.darkness);
  68. set_unlicensed(status.unlicensed);
  69. wait(0.1);
  70. if(!status.unlicensed){
  71. exit.fade(outpath ? 1 : 0, 0);
  72. noexit.fade(outpath ? 0 : 1, 0);
  73. }
  74. //print("[DEBUG] map set\n");
  75. }