console.nut 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /**
  2. * This script is loaded into the console script interpreter.
  3. * You should define shortcuts and helper functions that are useful for the
  4. * console here
  5. */
  6. function flip()
  7. {
  8. Level.flip_vertically();
  9. }
  10. function finish()
  11. {
  12. Level.finish(true);
  13. }
  14. function edit()
  15. {
  16. Level.edit(true);
  17. }
  18. function play()
  19. {
  20. Level.edit(false);
  21. }
  22. function worldmapfinish()
  23. {
  24. foreach(world in state.worlds) {
  25. foreach(levelname, level in world.levels) {
  26. level.solved = true;
  27. }
  28. }
  29. load_state();
  30. }
  31. function grow()
  32. {
  33. sector.Tux.add_bonus("grow");
  34. }
  35. function make_invincible()
  36. {
  37. sector.Tux.make_invincible();
  38. }
  39. function fire()
  40. {
  41. sector.Tux.add_bonus("fireflower");
  42. }
  43. function ice()
  44. {
  45. sector.Tux.add_bonus("iceflower");
  46. }
  47. function air()
  48. {
  49. sector.Tux.add_bonus("airflower");
  50. }
  51. function earth()
  52. {
  53. sector.Tux.add_bonus("earthflower");
  54. }
  55. function shrink()
  56. {
  57. sector.Tux.kill(false);
  58. }
  59. function kill()
  60. {
  61. sector.Tux.kill(true);
  62. }
  63. function lifeup()
  64. {
  65. sector.Tux.add_coins(100);
  66. }
  67. function none()
  68. {
  69. sector.Tux.set_bonus("none");
  70. }
  71. /**
  72. * Display a list of functions in the roottable (or in the table specified)
  73. */
  74. function functions(...)
  75. {
  76. local obj = this;
  77. if(vargv.len() == 1)
  78. obj = vargv[0];
  79. if(::type(obj) == "instance")
  80. obj = obj.getclass()
  81. foreach(key, val in obj) {
  82. if(::type(val) == "function")
  83. println(key);
  84. }
  85. }