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