9c2b58fce6349516a5aea8d9d30d507c4bd9303b
[supertux.git] / src / scripting / functions.hpp
1 //  SuperTux
2 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3 //
4 //  This program is free software: you can redistribute it and/or modify
5 //  it under the terms of the GNU General Public License as published by
6 //  the Free Software Foundation, either version 3 of the License, or
7 //  (at your option) any later version.
8 //
9 //  This program is distributed in the hope that it will be useful,
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 //  GNU General Public License for more details.
13 //
14 //  You should have received a copy of the GNU General Public License
15 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 #ifndef HEADER_SUPERTUX_SCRIPTING_FUNCTIONS_HPP
18 #define HEADER_SUPERTUX_SCRIPTING_FUNCTIONS_HPP
19
20 #ifndef SCRIPTING_API
21 #include <squirrel.h>
22 #include <string>
23
24 #define __suspend
25 #define __custom(x)
26 #endif
27
28 namespace Scripting {
29
30 /**
31  * Display the value of the argument. This is useful for inspecting tables.
32  */
33 SQInteger display(HSQUIRRELVM vm) __custom("t.");
34
35 /**
36  * Displays contents of the current stack
37  */
38 void print_stacktrace(HSQUIRRELVM vm);
39
40 /**
41  * returns the currently running thread
42  */
43 SQInteger get_current_thread(HSQUIRRELVM vm) __custom("t");
44
45 /**
46  * Display a text file and scrolls it over the screen (on next screenswitch)
47  */
48 void display_text_file(const std::string& filename);
49
50 /**
51  * Load and display a worldmap (on next screenswitch)
52  */
53 void load_worldmap(const std::string& filename);
54
55 /**
56  * Load and display a level (on next screenswitch)
57  */
58 void load_level(const std::string& filename);
59
60 /**
61  * Suspend the script execution for the specified number of seconds
62  */
63 void wait(HSQUIRRELVM vm, float seconds) __suspend;
64
65 /**
66  * Suspend the script execution until the current screen has been changed
67  */
68 void wait_for_screenswitch(HSQUIRRELVM vm) __suspend;
69
70 /**
71  * Exits the currently running screen (force exit from worldmap or scrolling
72  * text for example)
73  */
74 void exit_screen();
75
76 /**
77  * Does a fadeout for the specified number of seconds before next screenchange
78  */
79 void fadeout_screen(float seconds);
80
81 /**
82  * Does a shrinking fade towards the destposition for the specified number of
83  * seconds before next screenchange
84  */
85 void shrink_screen(float dest_x, float dest_y, float seconds);
86
87 /**
88  * Aborts any kind of previous screen fade; the screenchange will happen
89  * anyway.
90  */
91 void abort_screenfade();
92
93 /**
94  * Translate a text into the users language (by looking it up in the .po
95  * files)
96  */
97 std::string translate(const std::string& text);
98
99 /**
100  * Load a script file and executes it. This is typically used to import
101  * functions from external files.
102  */
103 void import(HSQUIRRELVM v, const std::string& filename);
104
105 /**
106  * Save world state to savegame
107  */
108 void save_state();
109
110 /**
111  * Update worldmap from worldmap state (state.world variable)
112  */
113 void update_worldmap();
114
115 /**
116  * enable/disable drawing of collision rectangles
117  */
118 void debug_collrects(bool enable);
119
120 /**
121  * enable/disable drawing of fps
122  */
123 void debug_show_fps(bool enable);
124
125 /**
126  * enable/disable drawing of non-solid layers
127  */
128 void debug_draw_solids_only(bool enable);
129
130 /**
131  * enable/disable worldmap ghost mode
132  */
133 void debug_worldmap_ghost(bool enable);
134
135 /**
136  * Changes music to musicfile
137  */
138 void play_music(const std::string& musicfile);
139
140 /**
141  * Plays a soundfile
142  */
143 void play_sound(const std::string& soundfile);
144
145 /**
146  *  Set the game_speed
147  */
148 void set_game_speed(float speed);
149
150 /**
151  * speeds Tux up
152  */
153 void grease();
154
155 /**
156  * makes Tux invincible for 10000 units of time
157  */
158 void invincible();
159
160 /**
161  * makes Tux a ghost, i.e. lets him float around and through solid objects
162  */
163 void ghost();
164
165 /**
166  * recall Tux's invincibility and ghost status
167  */
168 void mortal();
169
170 /**
171  * reinitialise and respawn Tux at the beginning of the current level
172  */
173 void restart();
174
175 /**
176  * print Tux's current coordinates in a level
177  */
178 void whereami();
179
180 /**
181  * move Tux near the end of the level
182  */
183 void gotoend();
184
185 /**
186  * show the camera's coordinates
187  */
188 void camera();
189
190 /**
191  * adjust gamma
192  */
193 void set_gamma(float gamma);
194
195 /**
196  * exit the game
197  */
198 void quit();
199
200 /**
201  * Returns a random integer
202  */
203 int rand();
204
205 /**
206  * Record a demo to the given file.
207  */
208 void record_demo(const std::string& filename);
209
210 /**
211  * Play back a demo from the given file.
212  */
213 void play_demo(const std::string& filename);
214
215 } // namespace Scripting
216
217 #endif
218
219 /* EOF */