638d77e183f34c14a8fe3a83e57960ed3b17e1aa
[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  * Suspend the script execution for the specified number of seconds
52  */
53 void wait(HSQUIRRELVM vm, float seconds) __suspend;
54
55 /**
56  * Suspend the script execution until the current screen has been changed
57  */
58 void wait_for_screenswitch(HSQUIRRELVM vm) __suspend;
59
60 /**
61  * Exits the currently running screen (force exit from worldmap or scrolling
62  * text for example)
63  */
64 void exit_screen();
65
66 /**
67  * Does a fadeout for the specified number of seconds before next screenchange
68  */
69 void fadeout_screen(float seconds);
70
71 /**
72  * Does a shrinking fade towards the destposition for the specified number of
73  * seconds before next screenchange
74  */
75 void shrink_screen(float dest_x, float dest_y, float seconds);
76
77 /**
78  * Aborts any kind of previous screen fade; the screenchange will happen
79  * anyway.
80  */
81 void abort_screenfade();
82
83 /**
84  * Translate a text into the users language (by looking it up in the .po
85  * files)
86  */
87 std::string translate(const std::string& text);
88
89 /**
90  * Load a script file and executes it. This is typically used to import
91  * functions from external files.
92  */
93 void import(HSQUIRRELVM v, const std::string& filename);
94
95 /**
96  * enable/disable drawing of collision rectangles
97  */
98 void debug_collrects(bool enable);
99
100 /**
101  * enable/disable drawing of fps
102  */
103 void debug_show_fps(bool enable);
104
105 /**
106  * enable/disable drawing of non-solid layers
107  */
108 void debug_draw_solids_only(bool enable);
109
110 /**
111  * enable/disable drawing of editor images
112  */
113 void debug_draw_editor_images(bool enable);
114
115 /**
116  * enable/disable worldmap ghost mode
117  */
118 void debug_worldmap_ghost(bool enable);
119
120 /**
121  * Changes music to musicfile
122  */
123 void play_music(const std::string& musicfile);
124
125 /**
126  * Plays a soundfile
127  */
128 void play_sound(const std::string& soundfile);
129
130 /**
131  *  Set the game_speed
132  */
133 void set_game_speed(float speed);
134
135 /**
136  * speeds Tux up
137  */
138 void grease();
139
140 /**
141  * makes Tux invincible for 10000 units of time
142  */
143 void invincible();
144
145 /**
146  * makes Tux a ghost, i.e. lets him float around and through solid objects
147  */
148 void ghost();
149
150 /**
151  * recall Tux's invincibility and ghost status
152  */
153 void mortal();
154
155 /**
156  * reinitialise and respawn Tux at the beginning of the current level
157  */
158 void restart();
159
160 /**
161  * print Tux's current coordinates in a level
162  */
163 void whereami();
164
165 /**
166  * move Tux near the end of the level
167  */
168 void gotoend();
169
170 /**
171  * show the camera's coordinates
172  */
173 void camera();
174
175 /**
176  * adjust gamma
177  */
178 void set_gamma(float gamma);
179
180 /**
181  * exit the game
182  */
183 void quit();
184
185 /**
186  * Returns a random integer
187  */
188 int rand();
189
190 /**
191  * Record a demo to the given file.
192  */
193 void record_demo(const std::string& filename);
194
195 /**
196  * Play back a demo from the given file.
197  */
198 void play_demo(const std::string& filename);
199
200 } // namespace scripting
201
202 #endif
203
204 /* EOF */